fix: make malformed tool call arguments trigger retry instead of agent exit#3103
Open
hyknerf wants to merge 1 commit intotailcallhq:mainfrom
Open
fix: make malformed tool call arguments trigger retry instead of agent exit#3103hyknerf wants to merge 1 commit intotailcallhq:mainfrom
hyknerf wants to merge 1 commit intotailcallhq:mainfrom
Conversation
…t exit When MiniMax (or other providers) send malformed tool call arguments, the agent would exit prematurely instead of retrying the request. This fix: - Adds ToolCallArguments::parse_json() with proper error handling - Updates try_from_parts() to return Retryable errors on parse failure - Adds Error::tool_call_json_error() helper Closes tailcallhq#2641 Co-Authored-By: ForgeCode <noreply@forgecode.dev>
Contributor
|
Hi! I'm I would like to apply some automated changes to this pull request, but it looks like I don't have the necessary permissions to do so. To get this pull request into a mergeable state, please do one of the following two things:
|
Contributor
|
@hyknerf could you please allow maintainers to push autofix is not able to push the changes |
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
Fixes intermittent agent exit when MiniMax (or other providers) send malformed tool call arguments.
Problem
When a model sends invalid JSON in tool call arguments, the agent would exit prematurely instead of retrying the request. This was reported in issue #2641 where MiniMax M2.7 would occasionally exit with "Finished" after a tool call instead of continuing with the tool result.
Root Cause
ToolCallFull::try_from_parts()was usingToolCallArguments::from_json()which silently stores invalid JSON asUnparsed. This meant malformed arguments weren't being detected, leading to silent failures.Solution
Added
ToolCallArguments::parse_json()- Properly parses JSON strings with error handling, attemptingserde_jsonfirst then falling back tojson_repairfor recoveryUpdated
try_from_parts()to useparse_json()- Parse failures now returnRetryableerrors that trigger automatic retriesAdded
Error::tool_call_json_error()helper - Creates properly wrappedRetryableerrors for malformed JSONTesting
test_into_full_with_tool_call_parse_failure_creates_retryable_errorto verify retryable error behaviorCloses #2641