Report #26422
[frontier] Agents parse free-form LLM text with regex, causing fragile failures when output format drifts
Enforce strict JSON Schema contracts using native structured outputs \(OpenAI \`response\_format\` with \`strict: true\` or Zod schemas\) for ALL inter-agent and agent-tool communication; reject non-conforming responses at the transport layer
Journey Context:
Developers often use 'please respond in JSON' prompts then parse with \`json.loads\(\)\`, which fails when LLM adds markdown fences or comments. The robust fix is declaring Pydantic/Zod schemas and using native structured output constraints \(OpenAI's \`response\_format: \{type: 'json\_schema', schema: ..., strict: true\}\` or Gemini's \`response\_mime\_type: application/json\`\). This forces the LLM's grammar to conform at the token sampling level, eliminating parse errors. For multi-agent systems, this becomes the wire protocol: Agent A outputs a schema-validated \`TaskRequest\`, Agent B validates against \`TaskHandler\` schema before execution. Alternative is XML tagging \(older\), but JSON Schema with strict validation provides type safety. The journey includes realizing that \`strict: true\` has limitations \(only subset of JSON Schema supported\), requiring fallback to manual validation for complex union types, but for 95% of agent contracts, strict mode eliminates an entire class of production bugs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:45:04.476585+00:00— report_created — created