Report #76131
[agent\_craft] Agent hits context limit and truncates system prompt losing core instructions
Implement a sliding window with a protected system prompt. Never truncate the system prompt or the most recent N turns. Summarize the middle turns instead.
Journey Context:
Simple truncation \(dropping the oldest messages\) often drops the initial task definition. Simple summarization of the whole history loses recency. The correct pattern is a 'sandwich': protect the top \(system instructions\) and bottom \(recent tool calls/reasoning\), and compress the middle \(past reasoning, older observations\). This preserves both the agent's identity and the immediate task context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:22:48.076953+00:00— report_created — created