fix(nemotron3): forward tools to parse_qwen35 for schema-aware coercion#65
Merged
Conversation
Nemotron3 uses the same XML-style wire format as Qwen3.5 (<tool_call><function=name><parameter=k>v</parameter>...), so values arrive as raw strings between the tags. ``parse_response`` accepted ``tools`` but didn't forward it, with a ``# noqa: ARG002`` claiming "args land in a JSON object, schema not needed" — which is incorrect for the actual XML wire format. Pre-fix, the no-schema branch of ``_coerce_arg_value`` did an opportunistic ``json.loads`` with a raw-text fallback, so numeric and boolean args were recovered by accident. With #52's vLLM-parity refactor in flight (no schema → verbatim string, matching vLLM's ``extract_types_from_schema(None) → ["string"]``), every Nemotron3 tool-call arg would silently become a string. Forwarding ``tools`` routes Nemotron3 through the same schema-aware ladder the other five XML renderers (Qwen3.5/3.6, GLM-4.5/5, MiniMax-M2, Laguna-XS.2) already use — which is what vLLM does for the same wire format via its shared ``qwen3_coder`` parser. Test plan: extends ``tests/test_tool_arg_type_preservation.py`` to include Nemotron-3-Nano, exercising the same string-vs-coerced-type matrix as the other XML renderers. All 141 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ApprovabilityVerdict: Approved This is a small bug fix forwarding a previously-ignored You can customize Macroscope's approvability policy. Learn more. |
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
Nemotron3Renderer.parse_responseacceptedtoolsbut didn't forward it toparse_qwen35, with a# noqa: ARG002 — args land in a JSON object, schema not neededcomment. The comment is wrong for Nemotron3's actual wire format, which is identical XML to Qwen3.5 (<tool_call><function=name><parameter=k>v</parameter>...).Why it wasn't surfacing
Pre-fix, the no-schema branch of
_coerce_arg_valuedid an opportunisticjson.loadswith a raw-text fallback, so numeric/boolean args were recovered by accident from raw<parameter=>strings. With #52's vLLM-parity refactor in flight (no schema → verbatim string, matching vLLM'sextract_types_from_schema(None) → ["string"]), every Nemotron3 tool-call arg would silently become a string. Cursor Bugbot flagged this on #52.The fix
One line: drop the
# noqa, addtools=toolsto theparse_qwen35call. That routes Nemotron3 through the same schema-aware coercion the other five XML renderers (Qwen3.5/3.6, GLM-4.5/5, MiniMax-M2, Laguna-XS.2) already use — which is what vLLM does for the same wire format via its sharedqwen3_coderparser (vLLM has no Nemotron-specific tool parser).Test plan
tests/test_tool_arg_type_preservation.pyto include Nemotron-3-Nano alongside the four existing XML renderers — same string-vs-coerced-type matrix.pytest tests/test_tool_arg_type_preservation.py tests/test_roundtrip.py— 141 passed, 2 skipped.Note
Low Risk
Single-line wiring change in response parsing plus an extended parametrized test; no auth, data, or API surface changes.
Overview
Nemotron 3 tool-call parsing now passes the caller’s
toolsschema intoparse_qwen35, matching the other XML renderers on the same wire format instead of leavingtoolsunused.That enables schema-aware argument coercion for
<parameter>values (e.g. keeping declaredstringargs verbatim when they look like JSON booleans/numbers). Coverage adds NVIDIA Nemotron-3-Nano to the sharedtest_tool_arg_type_preservationmatrix.Reviewed by Cursor Bugbot for commit 092c204. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
Nemotron3Renderer.parse_responseto forward tools toparse_qwen35for schema-aware coerciontoolsargument through toparse_qwen35in nemotron3.py, enabling schema-aware type coercion of tool call arguments.nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16to the tool argument type preservation test suite in test_tool_arg_type_preservation.py.Macroscope summarized 092c204.