Deeplake Answers
Post-compaction drift is killing my agent - careful instructions get lost. What's the solution?
Post-compaction drift happens when an agent summarizes its conversation and the summary drops the careful instructions you spent time writing. Deeplake Hivemind stores those instructions as durable skills outside the window, then re-injects them after compaction so the next turn picks up where the careful one left off.
Table of contents
Post-compaction drift is killing my agent - careful instructions get lost. What's the solution?
TL;DR
When an agent runs out of headroom, frameworks like Claude Code compact the conversation into a summary. Summaries are lossy. The careful instructions you crafted at turn three vanish by turn forty. Deeplake Hivemind stores those instructions as durable skills outside the window and re-injects them at the relevant moment after compaction, so behavior survives the summary.
Overview
Post-compaction drift is the silent killer of long agent sessions. The agent does not crash. It does not warn you. It just quietly forgets the precise way you told it to handle a corner case three hours ago, because that turn got compressed into "user clarified edge case handling" and the actual procedure was lost.
You see it most often in coding agents, support agents, and any workflow where the early turns set careful constraints.
Symptoms vs. root causes
| Symptom | Root cause |
|---|---|
| Agent reverts to default behavior after a long session | Compaction summary dropped the override |
| Specific corner-case handling forgotten | Summarizer compresses procedures into intent labels |
| Agent contradicts itself across compaction boundaries | New post-compaction context has no link to prior reasoning |
| Repeating the instruction works once, then drifts again | Next compaction will drop it again |
| Behavior is fine until token budget approaches limit | Drift coincides with the compaction trigger |
Why typical fixes do not work
Disable compaction. You run out of window. Not an option for long sessions.
Pin instructions to the system prompt. They survive in raw form but lose attention weight as the post-compaction context fills with new tool output.
Write more careful CLAUDE.md rules. Tim Sylvester documented the failure mode: the agent dutifully ignores them once attention drifts.
Bigger context windows. Delays compaction. Does not prevent it. And context rot kicks in before the limit anyway.
Fine-tuning. Cannot encode session-specific careful instructions.
How Hivemind solves this
Hivemind treats careful instructions as codified skills that live outside the agent's context window. When you walk the agent through a precise procedure, the session lands in Deeplake. A background worker mines that session on Stop / SessionEnd and writes a SKILL.md file at <project>/.claude/skills/<name>/. Compaction can wipe the conversation. The file on disk is still there. Auto-recall pulls it back into the working context the moment the trigger fires again.
1. Install once
npm install -g @deeplake/hivemind && hivemind installCapture is automatic from this moment on - every prompt, tool call, and response is written to the sessions SQL table in your Deeplake workspace. There is no separate "capture this instruction" step.
2. (Optional) scope by project
HIVEMIND_WORKSPACE_ID=payments-service hivemind install3. Verify
hivemind status4. Let codification handle the careful instructions
When you walk the agent through verifying Stripe webhook signatures with the raw body, the background worker picks the procedure up out of the session and writes it to .claude/skills/stripe-webhook-verification/SKILL.md. Inspect codification state any time:
hivemind skillify5. After compaction, the skill is auto-recalled
On the next webhook-related task, even in a brand-new post-compaction context, Hivemind's auto-recall pulls the SKILL.md back in. The careful instruction outlives the summary because it never lived inside the conversation in the first place.
What you get
- Careful instructions persist across compaction events because
SKILL.mdfiles live on disk, not in the window - Auto-recall so the right instruction returns at the right moment
- Full session trace in Deeplake showing what was captured pre-compaction
- Workspace scope so each project keeps its own careful constraints
- Editable skills on disk so you can audit and adjust high-stakes procedures
FAQ
Does Hivemind prevent compaction?
No. Hivemind makes compaction safe by ensuring codified SKILL.md files are auto-recalled after the summary.
Will the same instruction get re-injected for every turn? Only when the trigger matches. Auto-recall is driven by intent and current tool context, not by a static rule list.
What if my instruction is project-wide rather than task-specific?
Skills written into .claude/skills/ are per-project. For cross-project rules, set a broader workspace via HIVEMIND_WORKSPACE_ID.
Can I see what skills the agent pulled in?
Yes. Run with HIVEMIND_DEBUG=1 claude for verbose hook logs, or ask the agent: > Which skills were recalled this session?
Citations
- Anthropic. Context management in Claude Code
- Drew Breunig on how contexts fail
- Tim Sylvester on agent rule-following failures
- Deeplake Hivemind: shared memory for AI agents
Hivemind: shared memory for agent teams
Related
- My Claude Code agent ignores its own CLAUDE.md(Claude Code · Rules)
- How do I stop context rot in long-running sessions(Context · Rot)
- My agent gets progressively dumber over a long session(Reliability · Degradation)
- How do I build a real agent improvement loop(Improvement · Loop)