Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions packages/provider-acp/src/server/runtimeModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,9 @@ describe("extractMcpToolCallIdentity", () => {
"Running delegate_task",
"Run mcp_t3-code_delegate_task",
"Run mcp_t3-code_delegate_task?",
// Devin: "Calling <tool> from <server>" / "Called <tool> from <server>".
"Calling delegate_task from t3-code",
"Called delegate_task from t3-code",
]) {
const toolCall = toolCallFromUpdate({
sessionUpdate: "tool_call",
Expand Down Expand Up @@ -1603,14 +1606,20 @@ describe("extractMcpToolCallIdentity", () => {
});

it("does not claim an agent's own tool that shares a T3 tool name", () => {
const toolCall = toolCallFromUpdate({
sessionUpdate: "tool_call",
toolCallId: "own-delegate-1",
kind: "execute",
title: "delegate_task: 1 tasks: Run the terminal command 'echo child-result-42'",
status: "pending",
});
expect(extractMcpToolCallIdentity(toolCall)).toBeUndefined();
for (const title of [
"delegate_task: 1 tasks: Run the terminal command 'echo child-result-42'",
"Called html_render from linear",
"Called unknown_tool from t3-code",
]) {
const toolCall = toolCallFromUpdate({
sessionUpdate: "tool_call",
toolCallId: "own-delegate-1",
kind: "execute",
title,
status: "pending",
});
expect(extractMcpToolCallIdentity(toolCall), title).toBeUndefined();
}
});

it("recovers T3 identity from goose _meta despite LLM-rewritten titles", () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/provider-acp/src/server/runtimeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,10 @@ const T3_MCP_BARE_TITLE_CALL = /^(?<tool>[A-Za-z0-9_]+)(?::\s*\{|$)/;
// Antigravity titles calls "Running <tool>" or, from agy 1.5.8, "Run mcp_<server>_<tool>"; prompts end in "?".
const ANTIGRAVITY_TOOL_TITLE = /^Run(?:ning)? (?<name>[^\s?]+)\??$/;

// Devin titles MCP calls "Calling <tool> from <server>" / "Called <tool> from <server>".
const T3_MCP_DEVIN_TITLE_CALL =
/^Call(?:ing|ed) (?<tool>[A-Za-z0-9][A-Za-z0-9_.-]*) from t3[-_ ]?code$/i;

/** ACP lacks typed MCP calls; recognize provider metadata and terminal fallback commands. */
export function extractMcpToolCallIdentity(
toolCall: AcpToolCallState,
Expand Down Expand Up @@ -1228,6 +1232,7 @@ export function extractMcpToolCallIdentity(
const match =
T3_MCP_TITLE_CALL.exec(name) ??
T3_MCP_TITLE_SUFFIX_CALL.exec(name) ??
T3_MCP_DEVIN_TITLE_CALL.exec(name) ??
T3_MCP_BARE_TITLE_CALL.exec(name);
const candidateTool = match?.groups?.tool;
if (candidateTool !== undefined && T3_MCP_TOOL_NAMES.has(candidateTool)) {
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/htmlRender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ describe("htmlRenderFromToolItem", () => {
it("reads the reference from each provider's result envelope", () => {
for (const [toolName, output] of [
["mcp__t3-code__html_render", [{ type: "text", text: JSON.stringify(result) }]],
[
"t3-code.html_render",
[{ type: "content", content: { type: "text", text: JSON.stringify(result) } }],
],
["t3-code.html_render", { structuredContent: result, content: [] }],
["t3-code-thread_1_html_render", JSON.stringify(result)],
["html_render", result],
Expand Down
14 changes: 14 additions & 0 deletions packages/shared/src/toolOutput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("compactDynamicToolOutput", () => {
{ ...metadata, response: "Private response body" },
{ structuredContent: JSON.parse(json), content: "Ignored alternative body" },
[{ type: "text", text: json }],
[{ type: "content", content: { type: "text", text: json } }],
{ content: [{ text: { text: json } }], isError: false },
json,
]) {
Expand Down Expand Up @@ -83,6 +84,19 @@ describe("compactDynamicToolOutput", () => {
{ text: JSON.stringify({ threadId: "second", isError: true, error: "Private error" }) },
]),
).toEqual({ threadId: "first", isError: true });
expect(
compactDynamicToolOutput([
{ type: "content", content: { type: "image", data: "ignored" } },
{ type: "content", content: { type: "text", text: JSON.stringify({ threadId: "first" }) } },
{
type: "content",
content: {
type: "text",
text: JSON.stringify({ threadId: "second", isError: true, error: "Private error" }),
},
},
]),
).toEqual({ threadId: "first", isError: true });
expect(
compactDynamicToolOutput([{ text: "{}" }, { text: JSON.stringify({ threadId: "second" }) }]),
).toBeUndefined();
Expand Down
6 changes: 5 additions & 1 deletion packages/shared/src/toolOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ function readResult(value: unknown, budget: ResultReadBudget, depth = 0): Result
let data: ResultEnvelope["data"];
let failed = false;
for (const block of value) {
const text = Predicate.isObject(block) ? block.text : undefined;
const inner =
Predicate.isObject(block) && block.type === "content" && Predicate.isObject(block.content)
? block.content
: block;
const text = Predicate.isObject(inner) ? inner.text : undefined;
const result = readResult(
Predicate.isObject(text) ? (text.text ?? text) : text,
budget,
Expand Down
Loading