Skip to content

fix: avoid TOOL_NAME keyword echo in system tool prompts#11107

Open
MumuTW wants to merge 4 commits intocontinuedev:mainfrom
MumuTW:fix-tool-name-echo-11072
Open

fix: avoid TOOL_NAME keyword echo in system tool prompts#11107
MumuTW wants to merge 4 commits intocontinuedev:mainfrom
MumuTW:fix-tool-name-echo-11072

Conversation

@MumuTW
Copy link
Contributor

@MumuTW MumuTW commented Mar 6, 2026

Summary

  • remove the TOOL_NAME: prefix from generated tool codeblock examples and tool definitions
  • emit plain tool names as the first line in tool / tool_definition blocks
  • keep parser backward compatible by accepting both TOOL_NAME: and plain-name formats
  • update and expand vitest coverage for system-message generation, start detection, parsing, and interception

Testing

  • npm run vitest -- tools/systemMessageTools/toolCodeblocks/buildSystemMessage.vitest.ts tools/systemMessageTools/toolCodeblocks/detectToolCallStart.vitest.ts tools/systemMessageTools/toolCodeblocks/parseSystemToolCall.vitest.ts tools/systemMessageTools/toolCodeblocks/interceptSystemToolCalls.vitest.ts

@MumuTW MumuTW requested a review from a team as a code owner March 6, 2026 02:47
@MumuTW MumuTW requested review from sestinj and removed request for a team March 6, 2026 02:47
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 6, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="core/tools/systemMessageTools/toolCodeblocks/parseSystemToolCall.vitest.ts">

<violation number="1" location="core/tools/systemMessageTools/toolCodeblocks/parseSystemToolCall.vitest.ts:13">
P2: Test changes removed end-to-end coverage for legacy `TOOL_NAME:` parsing in the combined `"```tool\n..."` buffer path, reducing backward-compatibility regression protection.</violation>
</file>

<file name="core/tools/systemMessageTools/toolCodeblocks/buildSystemMessage.vitest.ts">

<violation number="1" location="core/tools/systemMessageTools/toolCodeblocks/buildSystemMessage.vitest.ts:29">
P2: Tests verify the new plain tool-name format is present but never verify deprecated `TOOL_NAME:` tokens are absent, so mixed legacy output regressions can pass.</violation>
</file>

<file name="core/tools/systemMessageTools/toolCodeblocks/parseSystemToolCall.ts">

<violation number="1" location="core/tools/systemMessageTools/toolCodeblocks/parseSystemToolCall.ts:48">
P2: Malformed tagged tool-name lines like `tool_name:` are now accepted as literal tool names due to the fallback to `line.trim()`, instead of being rejected as invalid. This regresses input validation and can lead to invalid tool identifiers downstream.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@MumuTW
Copy link
Contributor Author

MumuTW commented Mar 6, 2026

Addressed the review feedback with a follow-up commit.\n\n### What changed\n- Restored legacy parser coverage for combined buffer input with + format.\n- Added assertions that generated tool-call examples/system message output do not emit deprecated tokens.\n- Tightened tool-name parsing so tagged lines like with an empty value now throw instead of being treated as literal names.\n\n### Validation\n-  ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND  No package.json (or package.yaml, or package.json5) was found in "/home/opc/.paperclip/instances/default/workspaces/7948d02f-b91e-4189-b9eb-32bf0b5923d2".

@MumuTW
Copy link
Contributor Author

MumuTW commented Mar 6, 2026

Addressed the review feedback with a follow-up commit.

What changed

  • Restored legacy parser coverage for combined buffer input with the ```tool + TOOL_NAME: format.
  • Added assertions that generated tool-call examples/system message output do not emit deprecated TOOL_NAME: tokens.
  • Tightened tool-name parsing so tagged lines like TOOL_NAME: with an empty value now throw Invalid tool name instead of being treated as literal names.

Validation

  • pnpm vitest tools/systemMessageTools/toolCodeblocks/parseSystemToolCall.vitest.ts tools/systemMessageTools/toolCodeblocks/buildSystemMessage.vitest.ts

@MumuTW
Copy link
Contributor Author

MumuTW commented Mar 6, 2026

Pushed a formatting follow-up to address the failure.\n\n- Ran repository-configured Prettier on the PR-changed tool parser files.\n- Resulting formatting updates were committed in .\n- Re-ran targeted tests:  ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND  No package.json (or package.yaml, or package.json5) was found in "/home/opc/.paperclip/instances/default/workspaces/7948d02f-b91e-4189-b9eb-32bf0b5923d2". (pass).

@MumuTW
Copy link
Contributor Author

MumuTW commented Mar 6, 2026

Pushed a formatting follow-up to address the prettier-check failure.

  • Ran repository-configured Prettier on the PR-changed tool parser files.
  • Resulting formatting updates were committed in a092f58.
  • Re-ran targeted tests: pnpm vitest tools/systemMessageTools/toolCodeblocks/parseSystemToolCall.vitest.ts tools/systemMessageTools/toolCodeblocks/buildSystemMessage.vitest.ts (pass).

Line was too long — break `implements` clause onto its own line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@RomneyDa
Copy link
Collaborator

RomneyDa commented Mar 9, 2026

@MumuTW what is the intention for this PR, did you find that the TOOL_NAME keyword was causing issues? Is it just to reduce token cost / increase speed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants