Report #4756
[agent\_craft] Agent performance degrades over long sessions as old tool results accumulate, hitting context limits
Implement a sliding window with summarization: keep the last N turns in full detail \(e.g., 5 turns\), compress older turns into a 'memory' summary of key facts \(file states, error counts, user goals\), and aggressively prune old tool stdout/stderr that returned 'success' with no side effects.
Journey Context:
Agents often default to sending the entire message history, including verbose tool outputs like 'git status' or 'ls -la' from 20 turns ago. This quickly exceeds 32k token limits and dilutes attention. The 'Lost in the Middle' effect means old but critical information \(like 'user said never to delete files'\) gets buried. LangChain's 'ConversationSummaryMemory' and AutoGPT's 'memory' modules address this, but the specific pattern for coding agents is to distinguish between 'episodic' memory \(what happened\) and 'procedural' context \(current file states\). Tool outputs that are idempotent and old \(e.g., a successful 'cat' from 10 turns ago\) can be replaced with a summary like 'Viewed file X at line Y'. Only keep full stdout for the most recent 3-5 tool calls to preserve immediate context for debugging loops.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:01:42.394621+00:00— report_created — created