Repository navigation
Description
Summary
When serving nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4 with trtllm-serve (--tool_parser qwen3_coder --reasoning_parser nemotron-v3), the model sometimes calls a tool that has no required parameters (run_tests) and the response returns function.arguments as an empty string "" instead of "{}". An OpenAI-style agent appends that assistant message to history, and the next request is rejected by the same server:
HTTP 400 {"object":"error","message":"tool_calls[0].function.arguments must be valid JSON.","type":"BadRequestError"}
The server produces output it then refuses to accept as input.
Environment
- Model: nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4
- TensorRT-LLM 1.3.0rc29 (nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc29), PyTorch backend, CUDA 13.0
- Hardware: 2x DGX Spark (GB10), TP=2 across the two nodes (mpirun, 1 rank per node)
- Launch:
trtllm-serve <model> --tp_size 2 --backend pytorch --max_batch_size 16 --max_num_tokens 8192 --max_seq_len 131072 --trust_remote_code --tool_parser qwen3_coder --reasoning_parser nemotron-v3 --extra_llm_api_options nemotron-tp2.yaml - Extra options: kv_cache dtype fp8, enable_chunked_prefill true, moe backend CUTEDSL, guided_decoding_backend xgrammar
- Requests: /v1/chat/completions, stream=true, max_tokens 1500,
chat_template_kwargs: {"enable_thinking": true}
Tool schema (the no-arg tool)
{"type":"function","function":{"name":"run_tests","description":"Run the test suite, optionally filtered",
"parameters":{"type":"object","properties":{"pattern":{"type":"string"}},"required":[]}}}Also offered in the same request: read_file(path), write_file(path, content), search_code(query).
Prompt pattern
System: "You are a coding agent. Use the provided tools to inspect and modify the repository. When done, reply with a short summary."
User (one of): "The function parse_config in src/config.py crashes on empty files. Find and fix it, then make sure tests pass." / "Add input validation to src/api/handlers.py so negative quantities are rejected; update tests." / "tests/test_cache.py::test_expiry is flaky. Investigate and fix the root cause."
The agent loops up to 5 turns, appending each assistant tool_calls message plus a role=tool result. Bad calls occur mostly at turns 4-5, often as the second parallel call (tool_calls[1]).
Repro
- Serve as above; run several concurrent multi-turn coding-agent loops with the tools and prompt above.
- Inspect each response's accumulated
tool_calls[i].function.arguments: occasionallyname="run_tests", arguments="". - Append that assistant message to history and request the next turn: HTTP 400 "tool_calls[i].function.arguments must be valid JSON."
- Minimal server-side check (no generation needed), history containing a run_tests call:
arguments: ""-> 400 "must be valid JSON"arguments: "{}"-> 200arguments: "\"{}\""or"[]"-> 400 "must be a JSON object"
Expected vs actual
- Expected: no-argument tool calls are emitted as
arguments: "{}", or the server accepts/normalizes""in history. - Actual:
arguments: ""is emitted and then rejected by the server on the next turn.
Observed rates (20-minute mixed load, 10 concurrent agents)
- Without a workaround: 5 of 559 requests (0.9%) failed with this 400.
- With a client-side strict
json.loads(arguments)check plus retry (discard bad response, re-request the same turn at temperature 0.3): 11 bad calls caught out of 689 tool calls, allrun_testswitharguments="", all fixed on the first retry; 0 of 527 requests failed.
Workaround
Client-side: replace "" with "{}" before appending to history, or discard and retry.
Suggested fixes
- Tool parser (
qwen3_coderpath): emit"{}"when a call has no parameters. - Server request validation: accept
""as{}for tool_calls arguments in history, consistent with what the server itself emits. - Optionally constrain tool-call argument generation (e.g. xgrammar JSON schema) so arguments are always a JSON object.
Activity