Repository navigation
fix: don't crash rollouts on malformed tool-call arguments and missing message content - #1180
Merged
bxyu-nvidia merged 2 commits intoApr 30, 2026
Conversation
…g message content
simple_agent: when a model produces tool-call arguments that are not valid
JSON, the agent crashed the entire batch on `json.loads`. Catch the parse
error and feed it back as a `function_call_output` so the rollout can
continue (or terminate naturally with a low reward). Adds a unit test.
vllm_model: in the reasoning-parser code path, prepending the wrapped
reasoning to `choice_dict["message"]["content"]` would `KeyError` if the
upstream response omitted `content` entirely. Use `.get("content")` so a
missing key behaves the same as `None`.
Signed-off-by: jthomson04 <[email protected]>
bxyu-nvidia
requested changes
Apr 29, 2026
…lways shown
Per review feedback: str(e) is empty for exceptions constructed without
args (e.g. `Exception()` -> ""), which would leave the model staring at
"Invalid tool call arguments: " with no signal about what went wrong.
repr(e) always includes the exception class name, so the model sees
"...JSONDecodeError('Expecting value: line 1 column 1 (char 0)')" or at
worst "...JSONDecodeError()" rather than an empty string.
Signed-off-by: jthomson04 <[email protected]>
bxyu-nvidia
approved these changes
Apr 30, 2026
cmunley1
pushed a commit
that referenced
this pull request
May 1, 2026
…g message content (#1180) ## Summary Two small defensive fixes that came up while running rollouts; both were triggering crashes on otherwise-recoverable model outputs. - **`simple_agent`**: when the model emits tool-call `arguments` that aren't valid JSON, the agent crashed the whole rollout batch on `json.loads(output_function_call.arguments)`. Catch `JSONDecodeError`/`TypeError`, surface the parse error back to the model as a `function_call_output`, and let the loop continue (it will either self-correct on the next turn or terminate naturally with a low reward). Adds a unit test exercising this path. - **`vllm_model`**: in the reasoning-parser branch, `choice_dict["message"]["content"] or ""` would `KeyError` if the upstream response omitted the `content` key entirely (some vLLM responses do this when only `reasoning_content` is set). Switched to `choice_dict["message"].get("content") or ""` so a missing key behaves the same as `None`. Both are pulled out of a longer-running branch as standalone, isolated fixes; no behavior changes for the happy paths. ## Test plan - [x] `pytest responses_api_agents/simple_agent/tests/test_app.py` — all 6 tests pass, including the new `test_responses_continues_on_malformed_tool_call_arguments`. - [x] `pytest responses_api_models/vllm_model/tests/test_app.py` — all 66 tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: jthomson04 <[email protected]> Signed-off-by: cmunley1 <[email protected]>
tdene
added a commit
that referenced
this pull request
Jul 30, 2026
Follow-up to #2139 and #1180 Signed-off-by: Teodor-Dumitru Ene <[email protected]>
OlegSudakov
pushed a commit
to OlegSudakov/Gym
that referenced
this pull request
Aug 7, 2026
Follow-up to NVIDIA-NeMo#2139 and NVIDIA-NeMo#1180 Signed-off-by: Teodor-Dumitru Ene <[email protected]>
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
Two small defensive fixes that came up while running rollouts; both were triggering crashes on otherwise-recoverable model outputs.
simple_agent: when the model emits tool-callargumentsthat aren't valid JSON, the agent crashed the whole rollout batch onjson.loads(output_function_call.arguments). CatchJSONDecodeError/TypeError, surface the parse error back to the model as afunction_call_output, and let the loop continue (it will either self-correct on the next turn or terminate naturally with a low reward). Adds a unit test exercising this path.vllm_model: in the reasoning-parser branch,choice_dict["message"]["content"] or ""wouldKeyErrorif the upstream response omitted thecontentkey entirely (some vLLM responses do this when onlyreasoning_contentis set). Switched tochoice_dict["message"].get("content") or ""so a missing key behaves the same asNone.Both are pulled out of a longer-running branch as standalone, isolated fixes; no behavior changes for the happy paths.
Test plan
pytest responses_api_agents/simple_agent/tests/test_app.py— all 6 tests pass, including the newtest_responses_continues_on_malformed_tool_call_arguments.pytest responses_api_models/vllm_model/tests/test_app.py— all 66 tests pass.🤖 Generated with Claude Code