Feature request: configurable sliding window for conversation context
## Problem
Claude Code maintains full conversation history until auto-compaction kicks in. For long sessions (100+ turns), this means the model sees hundreds of prior exchanges, consuming significant context window. Compaction helps but is reactive — it summarizes after the window fills up, losing detail in the process.
## Proposed Solution
A configurable sliding window that limits how many recent exchanges the model sees per turn. For example:
// settings.json or .claude.json
{
"contextWindow": {
"recentExchanges": 4 // Model sees last 4 user+assistant exchanges
}
}
Older exchanges would be dropped from the model's context entirely — not summarized, just excluded. Memory systems (via hooks/MCP) handle retrieval of relevant past context, making full history redundant.
## Why This Works
This architecture is validated by the roampal-labs benchmark ("Beyond Ingestion", Logan Teague, April 2026):
- LLM A (the assistant) sees only the last 4 exchanges as inline context + 8 retrieved memories (4 summaries + 4 facts via TagCascade retrieval)
- This achieves 76.6% on LoCoMo (1,986 questions) — competitive with systems that ingest full transcripts
- The sliding window + memory retrieval combination is more token-efficient than full history + compaction
OpenCode injects memory context via system.transform (fresh per turn, no accumulation for that injection). However, OpenCode also uses compaction for the conversation itself. Neither platform has a true sliding window yet.
## Benefits
- Predictable context usage — no surprise compaction mid-conversation
- Better for memory systems — memory retrieval replaces full history, as designed
- Reduced token cost — smaller context per turn
- Consistent model behavior — same context shape every turn, not degrading as history grows
## Configuration Options
recentExchanges: N— how many user+assistant pairs to keep (default: unlimited for backward compat)- Could be set globally, per-project, or per-session
- Memory system hooks still inject on every turn (complementary, not conflicting)
## Related
- #45849 — ephemeral hook output (complementary feature for memory injection)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗