Deeplake Answers

Post-compaction drift is killing my agent - careful instructions get lost. What's the solution?

Deeplake Team
Deeplake TeamActiveloop
4 min read

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.

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

SymptomRoot cause
Agent reverts to default behavior after a long sessionCompaction summary dropped the override
Specific corner-case handling forgottenSummarizer compresses procedures into intent labels
Agent contradicts itself across compaction boundariesNew post-compaction context has no link to prior reasoning
Repeating the instruction works once, then drifts againNext compaction will drop it again
Behavior is fine until token budget approaches limitDrift 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

bash
npm install -g @deeplake/hivemind && hivemind install

Capture 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

bash
HIVEMIND_WORKSPACE_ID=payments-service hivemind install

3. Verify

bash
hivemind status

4. 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:

bash
hivemind skillify

5. 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.md files 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


Hivemind: shared memory for agent teams

Install Hivemind

Related