Skip to content

Fix system-message tools parser when tool call is non-terminal#11092

Open
MumuTW wants to merge 6 commits intocontinuedev:mainfrom
MumuTW:fix-system-tools-non-terminal-11074
Open

Fix system-message tools parser when tool call is non-terminal#11092
MumuTW wants to merge 6 commits intocontinuedev:mainfrom
MumuTW:fix-system-tools-non-terminal-11074

Conversation

@MumuTW
Copy link
Contributor

@MumuTW MumuTW commented Mar 5, 2026

Summary

  • stop treating a completed system-message tool call as terminal for the entire stream
  • reset parser state after each completed tool call so later chunks/messages continue to be processed
  • preserve assistant content that appears after a parsed tool call
  • add regression coverage for post-tool content and mid-message tool-call placement

Testing

@continuedev/core@1.1.0 vitest /home/opc/.paperclip/instances/default/workspaces/7948d02f-b91e-4189-b9eb-32bf0b5923d2/continue/core
vitest run core/tools/systemMessageTools/toolCodeblocks/interceptSystemToolCalls.vitest.ts

 ELIFECYCLE  Command failed.
 WARN  Local package.json exists, but node_modules missing, did you mean to install? (fails in this workspace because is missing and is unavailable)


Continue Tasks: 🔄 7 running — View all


Summary by cubic

Fix system-message tool-call parsing so completed calls don’t end the stream and text before/after a call is preserved, including mid-message calls. Also dedupe dynamic tool definitions, emit trailing newlines as text, and map "reasoning-delta" to reasoning_content.

  • Bug Fixes
    • System tools: make tool calls non-terminal; reset state after each call; preserve surrounding text; emit the trailing newline after a closed tool-call codeblock; avoid duplicate predefined tools in the dynamic section; add and correct tests for post-tool and mid-message cases.
    • OpenAI adapter: map "reasoning-delta" to delta.reasoning_content; simplify a test-only TS assertion.

Written for commit 97eeedc. Summary will update on new commits.

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

github-actions bot commented Mar 5, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

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 MumuTW force-pushed the fix-system-tools-non-terminal-11074 branch from 15c0036 to cc09312 Compare March 5, 2026 23:37
@MumuTW
Copy link
Contributor Author

MumuTW commented Mar 5, 2026

I have read the CLA Document and I hereby sign the CLA

MumuTW and others added 2 commits March 5, 2026 23:44
The `as typeof X & Y` type assertion was ambiguous to the TypeScript
parser without parentheses, causing TS1005 errors across all CI checks.
Simplify to `as any` since this is a test assertion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 I think looks good, just a nitpick on unrelated changes

});

case "reasoning-delta":
return chatChunk({
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change looks unrelated to PR description, could you remove this and the test file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch — removed in ee012d3. Will open a separate PR for the reasoning-delta fix.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Mar 10, 2026
Per reviewer feedback — keeping this PR focused on the
system-message tools parser fix.
@MumuTW MumuTW force-pushed the fix-system-tools-non-terminal-11074 branch from b4fe40c to ee012d3 Compare March 10, 2026 23:38
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 10, 2026
@MumuTW
Copy link
Contributor Author

MumuTW commented Mar 17, 2026

@RomneyDa Just checking in — the unrelated changes have been removed per your feedback (ee012d3). Let me know if anything else needs adjustment!

The 'preserves content after a tool call' test incorrectly consumed the
trailing newline and preserved text within the tool-call loop. Adjusted
the loop count from 6 to 4 (actual tool-call deltas) and added explicit
assertions for the trailing newline and preserved content chunks.

The 'mid-message' test was missing an assertion for the newline chunk
emitted between the closing codeblock fence and trailing text.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 18, 2026
@MumuTW
Copy link
Contributor Author

MumuTW commented Mar 18, 2026

Fixed the failing core-checks CI — the two post-tool-call content tests had incorrect iteration counts:

  • preserves content after a tool call: The loop consumed 6 iterations but only 4 are tool-call deltas. The trailing "\n" from \``\n` and the preserved text were being consumed inside the loop. Fixed by reducing the loop to 4 and adding explicit assertions for the newline and preserved content chunks.
  • parses a tool call that appears mid-message and preserves trailing content: Added the missing assertion for the "\n" chunk between the closing code fence and "After tool".

All 46 system-message-tools tests pass locally. Commit: 97eeedc.

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: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants