Skip to content

fix(rollout): handle invalid tool arguments - #2709

Open
MinhaoLi0318 wants to merge 4 commits into
radixark:mainfrom
MinhaoLi0318:fix/invalid-tool-arguments
Open

fix(rollout): handle invalid tool arguments#2709
MinhaoLi0318 wants to merge 4 commits into
radixark:mainfrom
MinhaoLi0318:fix/invalid-tool-arguments

Conversation

@MinhaoLi0318

@MinhaoLi0318 MinhaoLi0318 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Parse arguments for recognized SGLang and OpenAI tool-call envelopes before execution.
  • Invoke the executor only when the decoded arguments are a JSON object.
  • Return a deterministic tool-error response for malformed or non-object JSON so the rollout can continue and the model can correct the call on the next turn.
  • Preserve existing behavior for valid objects, empty arguments, sampled assistant output/tokens, and envelope recognition.

Behavior

  • JSON object: Call the executor with the parsed mapping and return the existing tool response.
  • Empty string: Call the executor with an empty mapping and return the existing tool response.
  • Malformed JSON: Do not call the executor; return a deterministic tool-error response.
  • JSON list or number: Do not call the executor; return a deterministic tool-error response.

Tests

  • Added parameterized regression coverage for both ToolCallItem and ChatCompletionMessageToolCall.
  • Targeted regression cases: 10 passed.
  • Pre-commit, Ruff, Black, isort, autoflake, and py_compile passed.
  • The full CPU suite is left to PR CI because the local macOS environment does not contain the pinned SGLang/PyTorch source stack used by Miles CI.

Fixes #2689

@yueming-yuan

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@MinhaoLi0318

Copy link
Copy Markdown
Contributor Author

@guapisolo @yueming-yuan please help take a look when you have time~

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(rollout): handle malformed and non-object tool arguments before execution

1 participant