Skip to content

fix: make malformed tool call arguments trigger retry instead of agent exit#3103

Open
hyknerf wants to merge 1 commit intotailcallhq:mainfrom
hyknerf:fix/minimax-tool-call-retry
Open

fix: make malformed tool call arguments trigger retry instead of agent exit#3103
hyknerf wants to merge 1 commit intotailcallhq:mainfrom
hyknerf:fix/minimax-tool-call-retry

Conversation

@hyknerf
Copy link
Copy Markdown

@hyknerf hyknerf commented Apr 21, 2026

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 using ToolCallArguments::from_json() which silently stores invalid JSON as Unparsed. This meant malformed arguments weren't being detected, leading to silent failures.

Solution

  1. Added ToolCallArguments::parse_json() - Properly parses JSON strings with error handling, attempting serde_json first then falling back to json_repair for recovery

  2. Updated try_from_parts() to use parse_json() - Parse failures now return Retryable errors that trigger automatic retries

  3. Added Error::tool_call_json_error() helper - Creates properly wrapped Retryable errors for malformed JSON

Testing

  • All existing tests pass (586 in forge_domain, 661 in forge_app)
  • Added test test_into_full_with_tool_call_parse_failure_creates_retryable_error to verify retryable error behavior

Closes #2641

…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>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 21, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the type: fix Iterations on existing features or infrastructure. label Apr 21, 2026
@autofix-ci
Copy link
Copy Markdown
Contributor

autofix-ci Bot commented Apr 21, 2026

Hi! I'm autofix logoautofix.ci, a bot that automatically fixes trivial issues such as code formatting in pull requests.

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:

  1. Allow edits by maintainers for your pull request, and then re-trigger CI (for example by pushing a new commit).
  2. Manually fix the issues identified for your pull request (see the GitHub Actions output for details on what I would like to change).

@amitksingh1490
Copy link
Copy Markdown
Contributor

@hyknerf could you please allow maintainers to push autofix is not able to push the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: weird intermittent exit with minimax 2.7

3 participants