fix: handle missing </tool_call> closing tag in parse_tool_call#121
Merged
fix: handle missing </tool_call> closing tag in parse_tool_call#121
Conversation
Two fixes:
1. Handle missing </tool_call> closing tag when it's used as stop string
2. Check that json.loads returns dict before calling .get()
Bug 1: When stop=['</tool_call>'], vLLM stops before outputting the closing
tag. The regex required both tags, so valid tool calls were rejected.
Bug 2: json.loads() can return any JSON type (string, list, number, etc).
If model generates <tool_call>"string"</tool_call>, json.loads returns a
Python string, and parsed.get("name") crashes with AttributeError.
Evidence:
- Run fleet_tool_use_287cf214 crashed at step 10 with:
AttributeError: 'str' object has no attribute 'get'
- Run fleet_tool_use_024ac38b had 0% reward because all tool calls
rejected with "No tool call found"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
be82abf to
a403810
Compare
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
parse_tool_call()causing training crashes and 0% rewardBug 1: Missing closing tag (stop string issue)
When using
</tool_call>as the stop string:generator.sampling_params.stop='["</tool_call>"]'vLLM stops generation before outputting the closing tag. Model generates:
But regex required both tags → every tool call rejected as "No tool call found" → 0% reward.
Evidence: Run
fleet_tool_use_024ac38b- all trajectories show model generating valid tool calls but environment rejecting them.Bug 2: Non-dict JSON type crash
json.loads()can return any valid JSON type (string, list, number, etc). If model generates:Then
json.loads()returns a Python string, andparsed.get("name")crashes:Evidence: Run
fleet_tool_use_287cf214crashed at step 10 with this exact error during training rollout.Fix
Test plan
🤖 Generated with Claude Code