Report #6027
[agent\_craft] Agent forgets initial system instructions after reading multiple large files
Implement a context sandwich or periodic re-injection. Place the core task and constraints at the very beginning AND the very end of the context window. For long trajectories, periodically re-inject the top-level goal as a system reminder before the next tool call.
Journey Context:
LLMs suffer from the 'lost in the middle' phenomenon. As an agent reads files, the context window fills with intermediate tool outputs, pushing the original goal to the middle. Agents then drift, hallucinating new goals or violating initial constraints. Re-injecting at the end ensures the model's next token prediction is anchored to the actual task. Alternatives like simply increasing context size just delay the problem, while naive summarization risks losing the exact original constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:03:06.211303+00:00— report_created — created