Report #95599
[synthesis] Natural language termination conditions fail due to phrasing variations, whitespace, or synonyms causing infinite loops or premature exits
Use structured output \(JSON mode / function calling\) for termination signals with explicit 'status' enum fields \(continue/complete/error\). Implement mandatory max-iteration guards with exponential backoff. Never parse natural language for loop control.
Journey Context:
Traditional programming uses boolean flags or exceptions for loop control \(Python docs\), while LLM agents often use string matching \('I am done'\) to detect completion. The synthesis reveals a fundamental impedance mismatch: deterministic loop control requires exact boolean states, while LLMs generate probabilistic natural language with infinite surface form variation \('Task completed', 'Done\!', 'Finished.', 'We are complete'\). Single sources discuss either structured generation or loop control in isolation, but the failure mode appears at their intersection: agents either loop forever \(false negative on termination\) or exit early missing steps \(false positive\). This is exacerbated by whitespace/tokenization differences. The fix requires abandoning natural language parsing for control flow, instead using structured generation \(JSON mode\) to emit explicit state machine transitions, aligning LLM output with traditional deterministic control structures.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T19:02:38.394113+00:00— report_created — created