fix: enable tool execution with stop sequences, name mapping, and XML suppression#3
Merged
fix: enable tool execution with stop sequences, name mapping, and XML suppression#3
Conversation
… suppression Three issues prevented tools from working: 1. No stop sequences — the model would generate tool call XML then keep generating (imagining errors, retrying, giving up). Adding stop=["</tool_call>"] makes the model stop after a tool call so Claude Code can execute it and send back results. 2. Tool name mismatch — the model called tools by mallex names (read_file, bash, grep) but Claude Code expects its own names (Read, Bash, Grep). Added name mapping in the parser. 3. Raw XML in stream — tool call XML (<tool_call><function=...>) was streamed as visible text before tool_use blocks were emitted. The stream translator now buffers text once it detects a tool call marker and suppresses the XML from text deltas. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stop: ["</tool_call>"]to OpenAI requests so the model pauses after a tool call instead of continuing to hallucinate errorsread_file,bash,grep) to Claude Code format (Read,Bash,Grep) in parsed responses<tool_call>/<function=markers and buffers instead of emitting them as visible textThe problem
The model would generate tool call XML, then keep going — imagining the tool failed, trying again, and eventually giving up and answering manually. Claude Code never got a chance to execute anything. Additionally, raw XML tags were visible to the user during streaming.
Test plan
<tool_call>,<function=) appears in the streamed outputbashmaps toBash🤖 Generated with Claude Code