Skip to content

fix: avoid intercepting quoted TOOL_NAME syntax in system tool parser#11105

Open
MumuTW wants to merge 2 commits intocontinuedev:mainfrom
MumuTW:fix-tools-parser-quoted-11070
Open

fix: avoid intercepting quoted TOOL_NAME syntax in system tool parser#11105
MumuTW wants to merge 2 commits intocontinuedev:mainfrom
MumuTW:fix-tools-parser-quoted-11070

Conversation

@MumuTW
Copy link
Contributor

@MumuTW MumuTW commented Mar 6, 2026

Summary

  • gate non-standard TOOL_NAME: start detection so it is only allowed at the beginning of assistant output
  • keep standard ```tool fenced detection unchanged
  • add regression coverage to ensure explanatory/quoted tool syntax is not intercepted

Tests

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

Closes #11070.


Continue Tasks: 🔄 7 running — View all


Summary by cubic

Prevented the system tools parser from intercepting quoted “TOOL_NAME:” syntax by only allowing loose tool starts at the very beginning of assistant output. Standard ```tool fenced detection remains unchanged. Addresses Linear #11070.

  • Bug Fixes
    • Add allowAlternateStarts option to detectToolCallStart and disable it after any non-whitespace assistant text.
    • Track non-whitespace assistant text to confine loose "TOOL_NAME:" detection to the output start.
    • Add tests to skip non-standard starts when alternates are disabled and ensure quoted/explanatory tool syntax is emitted as plain text.

Written for commit 71083c6. Summary will update on new commits.

@MumuTW MumuTW requested a review from a team as a code owner March 6, 2026 01:54
@MumuTW MumuTW requested review from sestinj and removed request for a team March 6, 2026 01:54
@dosubot dosubot bot added the size:M This PR changes 30-99 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.

No issues found across 4 files

@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 all PR-changed files; one test file required formatting updates.\n- Committed the fix 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 all PR-changed files; one test file required formatting updates.
  • Committed the fix in 71083c6.
  • Re-ran targeted tests: pnpm vitest tools/systemMessageTools/toolCodeblocks/detectToolCallStart.vitest.ts tools/systemMessageTools/toolCodeblocks/interceptSystemToolCalls.vitest.ts (pass).

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

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

@MumuTW this one is interesting, I think the way the system prompt is formatted we would sometimes expect to see text before the tool call starts (interleaving text with tool call for lower-performance models was actually a major motivation for system tool calls). Could you provide an example for where this goes wrong or more thoughts on it?

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

System message tools parser intercepts quoted tool syntax as real tool calls

2 participants