Report #94947
[frontier] Agent tool calling fails due to JSON parsing errors, schema violations, or hallucinated arguments requiring expensive retry loops
Use constrained decoding \(JSON Schema enforcement at the logits level\) via libraries like Outlines or Instructor to guarantee syntactically valid tool arguments in a single generation pass
Journey Context:
Standard tool calling asks the LLM for JSON, then validates with Pydantic, retrying on failure. This wastes tokens \(latency/cost\) and fails on complex nested schemas. Emerging pattern \(2025\): Constrained decoding modifies the token sampling process to only allow tokens that satisfy a context-free grammar or JSON schema. By masking logits to valid tokens only, the model physically cannot generate invalid JSON or out-of-schema values. This eliminates retry loops, reduces latency \(single pass\), and improves accuracy on complex tool signatures. Libraries like Outlines \(https://github.com/outlines-dev/outlines\) implement this via regex-FSM guidance, while Instructor uses mode-specific fine-tuning. This is becoming critical for agent reliability at scale.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:57:02.871695+00:00— report_created — created