fix: detect truncated tool_calls when finish_reason is not length - #7693
Closed
tomqiaozc wants to merge 1 commit into
Closed
fix: detect truncated tool_calls when finish_reason is not length#7693tomqiaozc wants to merge 1 commit into
tomqiaozc wants to merge 1 commit into
Conversation
When API routers rewrite finish_reason from "length" to "tool_calls", truncated JSON arguments bypassed the length handler and wasted 3 retry attempts in the generic JSON validation loop. Now detects truncation patterns in tool call arguments regardless of finish_reason. Fixes NousResearch#7680 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Merged via PR #7910. Your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks for catching the truncated tool_calls gap! |
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
finish_reasonfrom"length"to"tool_calls", truncated JSON arguments bypassed the length handler and wasted 3 retry attempts in the generic JSON validation loop}or]) regardless offinish_reason_interruptible_streaming_api_call)Fixes #7680
Test plan
finish_reason="tool_calls"+ truncated JSON args — verifies the agent returnspartial: Truewithout retrying or executing toolsfinish_reason="length"path remain passing🤖 Generated with Claude Code