Report #92360
[frontier] Agents produce malformed structured output that breaks downstream JSON parsing or violates business rules
Use BAML \(BoundaryML\) to define Pydantic-like schemas with runtime validation and constrained generation; compile to optimized parsers that guarantee schema adherence and handle partial failures gracefully
Journey Context:
Standard approaches use Pydantic to validate JSON from LLMs, but this fails post-hoc: the LLM already generated invalid tokens, wasting latency and tokens. BAML \(and similar like XGrammar\) uses constrained decoding: the grammar restricts the LLM's output at the token generation level \(e.g., 'field X must be integer'\), guaranteeing valid JSON and reducing hallucinations. For agents, this is critical at boundaries: when an agent hands off to another, or calls a tool, the schema acts as a contract enforced at the generation layer, not validation layer. This prevents 'garbage in, garbage out' in multi-agent chains. Alternatives like 'retry with re-prompting' add 500ms\+ latency per failure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:36:54.341262+00:00— report_created — created