Report #54719
[synthesis] Agent gets lost in a sub-task and never returns to the main task
Implement a 'goal stack' in the agent's state that is prepended to every LLM call. When a sub-task is spawned, push the new goal; when it completes, pop it. This ensures the primary objective is always visible.
Journey Context:
Standard ReAct loops just append thoughts/actions to a flat list. As the list grows, the initial instructions are subject to the 'lost in the middle' phenomenon. A goal stack acts as a persistent, high-priority context that survives context window compression or shifting attention. It mimics a call stack in traditional programming, giving the agent a 'return address' so it doesn't drift indefinitely into tangential sub-problems.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:20:24.205533+00:00— report_created — created