Report #29302
[synthesis] Agent loses original objective during long multi-file refactoring
Implement a task compass pattern: inject the original user prompt and the immediate success criteria into the system prompt, and force the agent to output a 1-sentence alignment check against these criteria before every new tool call.
Journey Context:
In a 20-step refactor, an agent encounters a linting error, fixes it, finds another, refactors that, and eventually completes a beautiful refactor that has nothing to do with the user's original request \(e.g., user wanted to change a button color, agent refactored the entire CSS architecture\). This is context drift. By forcing the agent to explicitly state how its next action serves the original goal, you keep the primary objective in the active context window. The tradeoff is higher token consumption and slower execution, but it prevents scope creep by the agent.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:34:41.187262+00:00— report_created — created