Skip to content

Commit 73ed549

Browse files
JWhitleyWorkclaude
andauthored
fix(provider-acp): stop claiming agents' own tools named like T3 tools (pingdotgg#20376)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent cdb761d commit 73ed549

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

‎packages/provider-acp/src/server/runtimeModel.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,12 @@ describe("extractMcpToolCallIdentity", () => {
15051505
't3-code__delegate_task: {"mode":"async"}',
15061506
"delegate_task_t3-code",
15071507
"t3-code/delegate_task",
1508+
"delegate_task",
15081509
'delegate_task: {"mode":"async"}',
1510+
// Kimi retitles on every streamed args chunk with the raw partial JSON,
1511+
// and middle-truncates args longer than 50 characters.
1512+
'delegate_task: {"mode":"async","task":"Ru',
1513+
'delegate_task: {"mode":"async","task":"Ru...cho child-result-42\'"}',
15091514
]) {
15101515
const toolCall = toolCallFromUpdate({
15111516
sessionUpdate: "tool_call",
@@ -1521,6 +1526,18 @@ describe("extractMcpToolCallIdentity", () => {
15211526
}
15221527
});
15231528

1529+
it("does not claim an agent's own tool that shares a T3 tool name", () => {
1530+
// Hermes' built-in delegate_task, titled "<tool>: <description>" like all its calls.
1531+
const toolCall = toolCallFromUpdate({
1532+
sessionUpdate: "tool_call",
1533+
toolCallId: "own-delegate-1",
1534+
kind: "execute",
1535+
title: "delegate_task: 1 tasks: Run the terminal command 'echo child-result-42'",
1536+
status: "pending",
1537+
});
1538+
expect(extractMcpToolCallIdentity(toolCall)).toBeUndefined();
1539+
});
1540+
15241541
it("recovers T3 identity from goose _meta despite LLM-rewritten titles", () => {
15251542
// goose enriches titles asynchronously, so only _meta.goose.toolCall is
15261543
// stable; shape from crates/goose/src/acp/server/tool_calls/conversion.rs.

‎packages/provider-acp/src/server/runtimeModel.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,10 +1062,14 @@ const T3_MCP_TITLE_SUFFIX_CALL =
10621062

10631063
/**
10641064
* glm-acp-agent and Kimi CLI register injected MCP tools under their bare
1065-
* names; Kimi additionally appends ": <raw args json>". Safe only because the
1066-
* match is gated on the known T3 tool inventory.
1065+
* names; Kimi additionally appends ": <raw args json>". The T3 inventory gate
1066+
* alone is not enough: an agent can have its own tool of the same name (Hermes
1067+
* has a built-in `delegate_task`) and title it "<tool>: <description>", so only
1068+
* a bare name or a JSON object after the colon counts. The match stops at the
1069+
* opening brace because Kimi retitles on every streamed args chunk, so the
1070+
* JSON is often still incomplete.
10671071
*/
1068-
const T3_MCP_BARE_TITLE_CALL = /^(?<tool>[A-Za-z0-9_]+)(?::\s|$)/;
1072+
const T3_MCP_BARE_TITLE_CALL = /^(?<tool>[A-Za-z0-9_]+)(?::\s*\{|$)/;
10691073

10701074
/**
10711075
* ACP has no typed MCP tool-call item, so agents surface MCP calls in agent-specific shapes:

0 commit comments

Comments
 (0)