Report #44202
[frontier] Agent tool calls are unreliable — LLMs return malformed JSON, wrong argument types, or hallucinate non-existent tool names
Enforce structured outputs using provider-level constrained decoding for all agent-tool interactions. Define strict JSON schemas for every tool input and use structured output features \(OpenAI Structured Outputs, Anthropic tool\_use with strict schemas\) rather than prompt-based formatting instructions.
Journey Context:
The common approach is to describe output formats in system prompts and hope the LLM complies. This breaks in production because LLMs occasionally produce malformed JSON, omit required fields, or hallucinate values that don't match the schema. These failures are rare per-request but certain at scale — with thousands of agent runs, you will hit them. The fix is constrained decoding at the model level: OpenAI's Structured Outputs with json\_schema support guarantees the output conforms to the provided JSON Schema, and Anthropic's tool\_use with input\_schema provides similar guarantees for tool arguments. Libraries like Instructor and Outlines provide model-agnostic constrained decoding. This is especially critical for agent-tool interactions where a malformed tool call crashes the entire pipeline. The tradeoff: strict schemas can occasionally force the model into less natural reasoning paths, and very complex nested schemas may confuse even constrained models. Best practice: use strict schemas on all tool inputs/outputs and external interfaces, but allow looser formats for internal chain-of-thought reasoning steps.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:39:59.457017+00:00— report_created — created