Report #87686
[frontier] LLM-based routing in agent workflows produces non-deterministic loops, high latency, and unpredictable costs due to repeated planning steps
Use LangGraph StateGraph with explicit conditional edges \(written in code\) for control flow, reserving LLMs only for node content generation, not routing decisions
Journey Context:
Early ReAct-style agents used LLMs to choose the 'next action' at every step, causing them to loop \('search -> search -> search'\) or hallucinate invalid tool names. Production systems are shifting to StateGraph where nodes represent functions and edges represent state transitions defined as Python/TypeScript functions, not LLM outputs. The pattern: define a TypedDict state schema; create nodes for distinct operations \(retrieve, generate, validate\); use conditional edges with explicit predicates \(e.g., 'if state\['validation\_passed'\] is True: route to execute else route to fix'\). This provides guarantees: no infinite loops \(cycles must be explicit\), predictable latency \(no LLM calls for routing\), and reproducibility.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:46:02.852207+00:00— report_created — created