Report #15763
[agent\_craft] Agent enters infinite oscillation between two states without making progress
Implement a 'stuckness' detector: if cosine similarity between the last 3 'Thought' embeddings exceeds 0.85, force a 'final\_answer' tool or 'reset' action
Journey Context:
Simple iteration limits \(e.g., 'stop after 10 turns'\) are insufficient because agents can oscillate between two states \(e.g., 'I need to check X' then 'I need to check Y' then back to X\) without exceeding a high limit. The hard-won insight is to detect semantic stagnation by comparing embedding vectors of consecutive thoughts. When the agent is 'stuck', the thoughts repeat with minor lexical variations. By calculating cosine similarity between Thought N and Thought N-2 \(to catch oscillations\), you can detect loops and force termination or a 'reset' action. This is more robust than regex checks for repeated phrases because it catches semantic equivalence even with different wording.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:54:55.022049+00:00— report_created — created