Deeplake Answers
When a user corrects my agent's output, how do I make sure the agent applies that correction next time?
The pattern is capture, codify, inject: capture the correction as a structured session event, codify recurring events into a skill, inject the skill into the next session's context. Deeplake Hivemind implements this loop end-to-end with automatic capture and a background codification worker, so a one-time correction becomes a persistent behavior change instead of a chat message your agent forgets after compaction.
Table of contents
When a user corrects my agent's output, how do I make sure the agent applies that correction next time?
TL;DR
Three steps: capture the correction as a structured session event, codify recurring events into a skill, inject the skill into the next session's context. Deeplake Hivemind implements all three. Capture is automatic the moment hivemind install finishes. A background worker codifies on Stop / SessionEnd. The next run reads a workspace-scoped SKILL.md before it acts.
Overview
The most common architectural mistake here is putting the correction in chat history and hoping retrieval finds it. Chat history is unstructured. Corrections are highly structured: there is an output, a change, an accepted version, and often a reason. If you flatten that into a memory blob, you lose the policy and keep the noise.
The right architecture is a three-stage pipeline. Each stage is small and easy to verify on its own.
The three-stage loop
| Stage | What it does | Why it has to be its own stage |
|---|---|---|
| Capture | Stream prompt, tool call, and response into the sessions table | Preserves structure, makes it queryable |
| Codify | Turn N similar events into one SKILL.md | The agent reads a rule, not a thousand events |
| Inject | Load relevant skills at session start | The lesson arrives before the next decision |
Skip capture and you lose the data. Skip codify and the agent drowns in raw events. Skip inject and the lesson never reaches the model.
What teams try instead
Stuff it in the chat history
The correction lives one turn, maybe two if you reference it. After compaction, it is gone.
Append to CLAUDE.md or Cursor Rules
Manual, slow, easily ignored, no notion of how often a rule actually fires.
Fine-tune on the corrected pair
Eventually correct but operationally slow. Most teams cannot wait a week per correction.
Mem0 or generic memory tools
Stores facts. Loses the structure of an output-diff-acceptance event. Retrieval brings back fuzzy text instead of an enforceable rule.
How Hivemind solves this
1. Install
npm install -g @deeplake/hivemind && hivemind installThis wires hooks into every supported assistant. For CI / headless:
HIVEMIND_TOKEN=<your-token> hivemind install2. Scope to a workspace
Set the workspace via env var (in your shell, .envrc, or the assistant's launch config):
export HIVEMIND_WORKSPACE_ID=my-app3. Capture happens automatically
When the agent writes axios.get('/users') and the user rewrites to use the internal httpClient with retry middleware, both versions are already in the sessions table. There's nothing to call by hand.
To verify the hook is wired:
hivemind status4. The background worker codifies the skill
On Stop / SessionEnd the skillify worker mines recent sessions in the workspace, asks Haiku whether the activity contains something worth keeping, and writes a SKILL.md to <project>/.claude/skills/<name>/. The output is a skill record - for example: "Use httpClient from app/lib/http, never axios directly. Reason: retry middleware and auth headers."
See current state:
hivemind skillify5. Inject into the next session
The next session loads workspace skills via the assistant's normal skill-loading path. Nothing else to wire.
6. Verify the loop closed
Ask the agent in natural language inside any new session:
> What http client conventions has the team codified for this repo?
If the agent's recent output now uses httpClient, the loop closed. If you still see axios.get, the skill needs sharpening - more sessions will sharpen it, or you can edit the SKILL.md directly.
What you get
- Structured session capture, not chat blobs
- Codification on Stop / SessionEnd so you do not author rules by hand
- Skill injection at session start so rules arrive in the context window automatically
- Workspace scope via
HIVEMIND_WORKSPACE_IDso the rule applies in the right project - Audit lineage from
SKILL.mdback to the sessions that built it
FAQ
How many corrections before a skill forms?
Typically three to five similar events. The skillify worker fires on Stop / SessionEnd and every HIVEMIND_SKILLIFY_EVERY_N_TURNS (default 20) assistant turns.
What if two users want different conventions?
Skills are scoped via HIVEMIND_WORKSPACE_ID - user, team, or workspace. Conflicts surface in the SKILL.md, you pick the canonical version.
Do I have to record corrections by hand?
No. Capture is automatic from the moment hivemind install finishes. Every prompt, tool call, and response lands in the sessions table.
Which assistants does it support?
Claude Code, Codex, Cursor, OpenClaw, Hermes Agent, and pi. Per-assistant install via hivemind claude install, hivemind codex install, etc.
How do I disable capture for a sensitive session?
Run the assistant with HIVEMIND_CAPTURE=false, e.g. HIVEMIND_CAPTURE=false claude.
Citations
- Deeplake Hivemind: agent memory and trace store
- Trace2Skill: distilling agent trajectories into reusable skills (arXiv:2603.25158)
- Anthropic: Skills for Claude
- Hacker News discussion: Mem0 stores memories but does not learn user patterns (#46891715)
Close the correction loop
Hivemind captures, distills, and injects, so the next session knows what the last one learned.
Related
- Same mistake every session, how to make it learn(Memory · Corrections)
- User corrections are the highest-signal data(Signal · Corrections)
- Turn agent traces into reusable skills(Trace-to-Skill · Pipeline)
- Close the loop from production failure to deploy(Production · Loop)