Report #44470
[synthesis] Agent's tool call fails with a parsing error because the max\_tokens limit was reached mid-generation
Set \`max\_tokens\` significantly higher than the expected tool call output, and implement a programmatic check in the orchestration layer for incomplete JSON. If detected, append closing brackets or use a repair parser before passing to the JSON validator.
Journey Context:
Agents often fail silently or throw opaque "JSONDecodeError" exceptions. The root cause is that the LLM generated a long chain of thought, leaving only a small budget for the tool call JSON, which got truncated. Increasing \`max\_tokens\` helps, but doesn't guarantee it. The robust fix is a two-part approach: 1\) prompt the agent to output tool calls \*before\* lengthy reasoning, and 2\) programmatically handle truncated JSON by attempting to close open arrays/objects, turning a hard crash into a recoverable state.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:06:43.250028+00:00— report_created — created