Report #58612
[frontier] Agent loops use string parsing to decide next steps causing fragile routing
Use strict JSON Schema outputs with enum routing decisions where the schema itself defines the agent topology; validate outputs against Pydantic models before execution
Journey Context:
Early ReAct implementations parse 'Thought: ... Action: ...' with regex, breaking on markdown formatting or multi-line reasoning. Production incidents show agents entering infinite loops when the parser misidentifies the action. The 2025 pattern: structured outputs as the control plane. Define a Pydantic model with Literal types for routing \(e.g., \`next\_agent: Literal\['researcher', 'coder'\]\`\). The LLM emits JSON, not text. This eliminates parsing brittleness and enables static analysis of agent topology. Tradeoff: token overhead of JSON vs freeform text. Alternative: tool calling API, but structured outputs work for internal routing decisions too.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:52:12.026073+00:00— report_created — created