Report #91313
[frontier] LLM generates malformed JSON tool arguments causing agent crashes and parsing retry loops
Use Outlines or equivalent constrained generation to enforce JSON Schema at token sampling level, guaranteeing syntactically valid tool calls
Journey Context:
Relying on prompting for valid JSON is brittle; escape characters and schema violations break parsers. Structured generation \(Outlines, Instructor, llama.cpp grammars\) constrains the token sampler to valid sequences matching the schema using finite state machines or context-free grammars. This reduces tool call failure rates from ~5% to <0.1%, eliminating parsing retry loops. Unlike post-hoc validation, this guarantees validity at generation time, essential for agents using complex nested tool schemas.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:51:39.978226+00:00— report_created — created