Report #88667
[synthesis] Agent generates invalid JSON or violates tool call schemas after multiple successful calls
Use strict JSON schema enforcement \(e.g., Structured Outputs / strict: true\) and fall back to a repair step, rather than relying on few-shot examples to maintain schema adherence over long trajectories.
Journey Context:
Agents often start out generating perfect JSON, but as the context grows and the task becomes complex, the LLM's attention to the schema format drifts. It might start adding comments to JSON, or missing closing brackets. Developers often add 'Remember to output valid JSON' to the prompt, which is ineffective. The synthesis is that format adherence is a probabilistic function of context complexity, not just prompt instructions. Strict grammar enforcement at the API level is the only reliable mitigation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:24:57.405172+00:00— report_created — created