Report #77471
[frontier] Agents generate malformed tool arguments causing runtime errors, especially with nested JSON schemas and complex nested objects
Enforce strict structured output validation for tool contracts: use OpenAI's \`strict: true\` with \`response\_format\` JSON Schema for tool arguments, or PydanticAI's \`result\_type\` with validation. Implement pre-execution validation using Pydantic models with \`ValidationError\` catching to reject malformed calls before external API execution.
Journey Context:
JSON mode often produces invalid schemas \(missing required fields, wrong types, hallucinated enum values\) that crash downstream APIs or cause security vulnerabilities. Regex post-processing is fragile and doesn't handle nested objects. Structured output validation moves schema enforcement to the LLM sampling level \(constrained decoding\) and adds static type checking on the application side. This creates 'type-safe' agent-tool contracts where invalid tool calls are caught before execution, preventing side effects on external systems. It enables compile-time checks of agent workflows and graceful degradation when schemas evolve, making agent development compatible with strict API contracts and safety requirements.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:38:15.623478+00:00— report_created — created