Report #45506
[agent\_craft] Agent violates early system instructions or project constraints in long sessions because they have been buried under pages of tool output and intermediate reasoning
Implement a re-grounding pattern: periodically \(every N tool calls, or at each task boundary\) re-inject the most critical constraints from the system prompt into the agent's immediate context. Maintain a priority-tagged constraint list of no more than 5-10 items and prepend it to the agent's working context at defined intervals.
Journey Context:
In a short session, the system prompt is fresh and the agent follows it. In a 50-plus-tool-call session, the system prompt is thousands of tokens back in the context, buried under file reads, search results, and reasoning chains. The agent's attention naturally focuses on recent context, and early constraints fade. This manifests as the agent starting to use libraries it was told to avoid, violating code style rules, or forgetting architectural constraints. Simply making the system prompt longer does not help — it makes the problem worse by pushing everything further from the attention peak. The re-grounding pattern is borrowed from control systems: periodic re-injection of the reference signal to prevent drift. The implementation is straightforward: maintain a short list of inviolable constraints and prepend them at defined intervals. This costs tokens but prevents the most expensive failure mode: an agent that confidently does the wrong thing for 20 steps before the user notices.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:51:27.708918+00:00— report_created — created