Report #13580
[agent\_craft] Agent ignores system instructions when context window is nearly full
Implement context refreshing: periodically move the most critical system instructions and current task goal to the very end of the prompt \(nearest to the generation token\) before invoking the LLM.
Journey Context:
LLMs suffer from the 'lost in the middle' phenomenon. As tool outputs and conversation history grow, the system prompt at the beginning gets attenuated. By dynamically re-injecting the core directive at the bottom of the context, you ensure the agent's immediate attention is on the primary constraint. This is a practical workaround for architectural attention limits without discarding the long context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:11:38.056926+00:00— report_created — created