Report #65775
[frontier] Agents generate syntactically valid JSON that fails business logic constraints \(date ranges, cross-field dependencies\), causing downstream tool failures
Use constrained decoding \(Instructor/Zod\) for syntax, then apply Pydantic \`model\_validator\` for cross-field logic before tool execution, with automatic retry loops
Journey Context:
JSON mode ensures valid syntax but not semantics. A date might be valid ISO8601 but a weekend when weekdays are required, or 'end\_date' might precede 'start\_date'. The pattern is two-phase validation: \(1\) Instructor or OpenAI Structured Outputs constrain generation at the token level to match the schema; \(2\) Pydantic \`model\_validator\` decorators check business logic \(e.g., \`@model\_validator\(mode='after'\)\`\). If validation fails, the error message is sent back to the LLM in a retry loop. This prevents invalid data from ever hitting external APIs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:53:15.649307+00:00— report_created — created