How to automatically consolidate duplicate instructions in an AI agent's knowledge base?
A team keeps the same rule in a CLAUDE.md file, in an agent's own notes and in a second rules file, and the copies slowly stop agreeing. Several hosts and memory services now document a pass that cleans such notes up on its own, and they differ most in what a person can see and undo before the next session loads the result. This page compares what they document about duplicates, rules of different scope and contradictions, and ends with a procedure for a pass you can inspect and reverse. The sources were read on 25 November 2026.
TL;DR
- Check scope before merging identical text. Claude Code concatenates discovered instruction files rather than overriding them, and when a user rule and a project rule conflict, "Claude may follow either one" (memory).
- Choose a pass by its review boundary. Copilot Dreaming, in public preview, changes memories "without approval for each change" and proposes changes to checked-in instructions in a pull request (Copilot Dreaming).
- Check the write mode. Anthropic Dreams, in research preview, writes to a new store by default, but its API also documents
update_existing, which writes into the existing store (API).- Keep must-apply rules in files and accumulated detail in memory. GitHub advises custom instructions for important rules and memory for the accumulated detail; Kiro says "If a rule must apply consistently, write it in Steering." (Copilot Memory, Kiro memory)
A consolidation pass is a background or on-demand run that reads the notes an agent has accumulated and merges, replaces or deletes entries.
Duplicate agent instructions: scope comes before similarity
Instruction files are host-loaded files that state rules for an agent. Agent memory is persisted information an agent can use across sessions. These working categories distinguish maintained instructions from accumulated notes, following the separation in Claude Code's memory documentation and Copilot's memory guidance.
A consolidation pass needs more than matching sentences. Consider a rule present in both a personal file and a repository file. Removing the repository copy is a decision about where the rule belongs, even when the wording matches.
Hosts do not resolve overlapping instructions uniformly:
- Claude Code: discovered files are concatenated. Neither user nor project rules override the other; when they conflict, Claude may follow either. Claude Code memory
- Kiro steering: workspace instructions take priority over conflicting global instructions. Kiro steering
- Cline: global and workspace rules are combined, with workspace rules taking precedence on conflict. Cline rules
- GitHub Copilot: Copilot CLI, Visual Studio Code and Visual Studio combine applicable instruction files without defining a general precedence order; Copilot Chat on GitHub.com gives personal instructions the highest precedence. Copilot custom instructions
This page's conclusion: identical wording at different scopes is a candidate for review, not permission to delete a copy. A named winner on conflict also does not make the lower-priority scope redundant everywhere.
Duplicate loading is a separate issue. Claude Code skips an AGENTS.md it has already loaded through an import or symlink, and its auto memory skips material already stated in CLAUDE.md. Neither behavior establishes that two independently maintained rules have the same scope. Claude Code memory
For the file inventory, use the instruction-file comparison and the AGENTS.md host-support guide.
Automatic memory consolidation: compare changes, review, and recovery
Memory consolidation is a pass that reorganizes stored information by merging duplicates and handling stale or conflicting entries. Anthropic's Dreams documentation describes such a pass over an existing store and past session transcripts. Dreams guide
The table is documentation read on 25 November 2026, not behaviour we tested. It asks three questions of every row: what the pass can change and over what scope, what a person can review before the change takes effect, and what can be inspected or recovered afterwards. Text in quotation marks is verbatim; the rest is paraphrased. Some rows are consolidation passes and others are review or write controls, so they are not equivalent operations. Our own row is in it, under the same columns.
"Not stated on the pages read" marks the limit of this reading, not a gap in the product.
| System and status | What it can change, and over what scope | Review before the change | Inspection or recovery afterwards |
|---|---|---|---|
| Anthropic Dreams, research preview | Reads one memory store and past transcripts and produces a reorganized store: "duplicates merged", "stale or contradicted entries replaced with the latest value" | By default the output is a new store and the dream "doesn't change the input memory store"; with update_existing it writes into the store (API) | Every change to a memory creates an immutable version; rollback means writing an earlier version's content back (memory stores) |
Claude Code /doctor prompt-audit (host), memory | Instruction files; it looks for "files that contradict each other". The documentation read describes no dreaming pass | "You get a report of findings with proposed edits, and nothing in your files changes until you ask Claude to apply them." | Not stated on the pages read |
| GitHub Copilot Dreaming, public preview, disabled by default (admin page) | Adds, updates and deletes memories; proposes changes to checked-in instructions and skills, including AGENTS.md and CLAUDE.md | Memories change "without approval for each change"; "Files remain unchanged until you merge the pull request" | A run log lists Added, Updated and Removed memories; run details "are not a complete activity history and do not include an option to undo a run" |
| Databricks memory pipeline, Beta | "deduplicates the new facts and merges them"; it "can rewrite, merge, split, or delete any entry under an actor_id it processes" | Not stated on the pages read | Not stated on the pages read |
| Mem0 Dream | Memories scoped to a user_id alone; it targets "the same preference stated three different ways" | A no-write preview shows the scope synthesis would analyze, not the merged result | Recent runs, patterns and their source memories, and the memories that were superseded or merged can be reviewed after a run |
| Devin Dreaming | "Consolidates overlapping notes", about once a day; memory is on by default | Not stated on the pages read | Memory files and recent dreaming sessions "with what each one changed" |
| Codex memories | A global memory consolidation step whose model is configurable; how it merges: not stated on the pages read. "Local Codex memories are off by default." | Not stated on the pages read | Its memory files are to be treated as "generated state"; recovery: not stated on the pages read |
| Kiro Crew, a separate Kiro product for teams of agents | On conflict, "higher confidence wins; same confidence → newer wins." | Not stated on the pages read | Earlier versions stay; a restore shows "Now" and "After restoring" before it is confirmed |
| Mnemoverse hosted API, reference | No pass: consolidation is "off on the hosted service" and its endpoint responds 503. A write "too close to a memory already stored in the same domain" is not stored | A correction is named by the caller with supersedes; the old memory "is not deleted" | The old memory "stays fetchable by ID"; hiding replaced memories from default reads "is off by default"; a chain endpoint returns the linked revisions |
Anthropic Dreams: read the guide beside the API
The Dreams guide says: "The input store is never modified, so you can review the output and discard it if you don't like the result."
Beside that statement, the API reference documents both the default new-store behavior and output_behavior: update_existing, which writes the result into the store. Anthropic Dreams is a research preview, and the API warns that request and response shapes may change without the stable-endpoint deprecation period.
Do not turn the guide's sentence into an unconditional safety guarantee. Inspect the requested output mode.
The memory-version documentation says every mutation creates an immutable version. Its rollback procedure is to retrieve an earlier version and write that content back; there is no dedicated restore endpoint, and nothing on the pages read undoes a whole dream in one step.
This page's conclusion: existing-store updates remain recoverable through versioned content, but recovery is different from reviewing a separate output before adopting it. The broader interface is covered in Managed Agents memory and Dreams.
Copilot Dreaming: approval depends on the destination
Copilot Dreaming, in public preview, draws a clear boundary between automatic memory changes and file changes proposed through pull requests. Administrators can inspect memory updates labeled Added, Updated, or Removed; updated memories show Before and After text when available. That inspection should not be mistaken for approval before the write. Operation, review controls
Repository customization can also propose edits to AGENTS.md and CLAUDE.md. The practical implication is cross-host: review what those edits will mean for other agents that load the files, not only for Copilot. Copilot Dreaming
How to run a consolidation pass you can inspect and reverse
The following is a recommended operating procedure, not a claim that any listed product implements the whole workflow.
Inventory the material and its scope
Record each instruction's source file or memory identifier, intended user or project, loading conditions, and authority. Group candidate duplicates within those boundaries before considering their wording.
Respect the product's control surface. Codex says to treat local memory files as generated state rather than relying on hand edits as the primary control. Local Codex memories are off by default, and its documented controls govern whether existing memories enter future sessions. Codex memories
Do not transfer controls between similarly named products. The separate Kiro IDE documentation describes a Memory view and confirmation before deleting a memory; the Crew restore behavior belongs to Crew's documentation. Kiro IDE, Kiro Crew
Start file cleanup with proposed edits
On 25 November 2026 the Claude Code documentation read describes no dreaming pass. Its /doctor prompt-audit produces "a report of findings with proposed edits, and nothing in your files changes until you ask Claude to apply them." It looks for "files that contradict each other". Claude Code memory
That gives file cleanup a useful review point. Ask the proposed change to explain which scope survives and why the removed instruction is redundant.
For memory, distinguish a scope preview from an output preview. Mem0's no-write preview answers what synthesis would analyze. It does not show the merged result awaiting approval. Mem0 Dream preview
Preserve conflicts unless a correction is established
Use a conservative merge policy:
- Merge repeated rules only after confirming equivalent meaning and scope.
- Retain the surviving rule's provenance.
- Replace an older statement only when the evidence identifies a correction.
- Otherwise, retain both statements and label the conflict for review.
This policy follows the cookbook recipe, "Dreaming with a dynamic workflow," rather than a promise about managed product behavior. The recipe instructs the pass to keep the current value when one statement is plainly a later correction, retaining dates and sources. Otherwise, it says to keep both and mark the conflict. Recipe
The same recipe explicitly rejects treating a passing session remark or an unsuccessful search as a later correction to a recorded project decision. Its workflow updates the store in place, and the cookbook says "There's no review by default." so adopting the recipe also requires choosing your own review boundary. Recipe
Save originals before allowing broad writes
Preserve the original content and identifiers before a pass can mutate live memory. Check the proposed change against that baseline, not merely against a summary saying duplicates were removed.
This matters especially when the mutation scope exceeds newly extracted facts. Databricks documents that its Beta memory pipeline can rewrite, merge, split, or delete any entry under a processed actor, including entries the agent saved directly. Pipeline, managed memory
Where recovery is documented, rehearse that procedure before relying on it. Where it is not stated on the pages read, preserve a separate baseline rather than assuming the activity view is a backup.
Review what the next session will receive
Inspect the resulting instructions and memory that the host will load, not only the pass's execution log.
Anthropic's research article warns that an incorrect note can be carried into every session. It also describes dreaming elevating notes that the harness can load at session start. Anthropic research
This page's conclusion: a bad merge written into always-loaded guidance creates a repeated exposure, not merely a bad record sitting in storage. Require explicit review before promoting synthesized material into must-apply instructions.
Keep that instruction surface small enough to inspect. Copilot recommends custom instructions for important requirements and memory for accumulated detail. Kiro similarly says a rule that must apply consistently belongs in Steering. This article recommends that division as the default setup. A file does not enforce a rule either; GitHub adds that "Neither memories nor custom instructions guarantee that Copilot will follow a rule every time, so review its work." Copilot, Kiro
What this page does not claim
No benchmark of any consolidation pass and no experiment. Splitting duplicate instructions into host-loaded files and agent-written notes, treating the same rule at another scope as not a duplicate, and comparing passes by what a person can review before the next session are this page's framing and conclusions from the quoted documents. Where a vendor's pages say nothing about a case, the table says "not stated on the pages read"; that is not a claim the product lacks it. Several passes are in preview and their documentation may change; the behaviours are the vendors' documented ones on the date in Sources. Cursor's rules pages and practitioners' reports were not read for this page.
Common questions
How to automatically consolidate duplicate instructions in an AI agent's knowledge base?
Split the problem in two. Files that a host loads every session (CLAUDE.md, AGENTS.md, Copilot instruction files, Cline and Kiro rules) are cleaned by a review that proposes edits. Notes the agent writes for itself are cleaned by a consolidation pass, which several vendors now document: Anthropic Dreams, GitHub Copilot Dreaming, a Databricks memory pipeline, Mem0 Dream, Devin Dreaming and Codex memory consolidation. Choose the pass by what you can review before the next session, and keep a rule that must always apply in a file, not in memory.
Is it a problem to keep the same advice in both a rules file and memory?
It can be, when the two copies drift apart. In Claude Code neither a user rule nor a project rule overrides the other, and Claude may follow either one. Claude Code also skips, in its own auto memory, anything the CLAUDE.md files already say, and GitHub and Kiro both advise writing the rule that must always apply in a file and leaving accumulated detail to memory.
What happens when a project rule and a global rule say different things?
It depends on the host, and it is not a duplicate: both rules are loaded. Kiro and Cline say the workspace rule wins. Claude Code says neither set overrides the other and Claude may follow either. GitHub says most Copilot surfaces combine instruction files without defining a general precedence order. Keep rules of different scope consistent, or in one place.
Can I review what an automatic memory consolidation pass changed before my agent uses it?
It depends on the pass. By default an Anthropic dream writes to a new store and leaves the input unchanged, but with update_existing it writes into the store, and the changes then stay as memory versions. Copilot Dreaming changes memories without approval for each change and proposes file changes in pull requests. Mem0 shows what Dream did after a run, and its no-write preview shows the scope, not the result. For the Databricks memory pipeline, review and rollback are not stated on the pages read.
Can GitHub Copilot Dreaming change my CLAUDE.md or AGENTS.md?
It can propose changes. Repository customization can review tracked files including AGENTS.md, CLAUDE.md and GEMINI.md, and changes to checked-in instructions are proposed in a pull request, so the files stay unchanged until you merge it. Dreaming is a public preview and is disabled by default; once enabled it applies to all repositories covered by the repository access setting, and turning off personal Dreaming does not stop runs for organization-owned repositories.
Sources
Read on 25 November 2026.
Hosts and instruction files
- Anthropic, Claude Code: memory.
- GitHub: custom instructions, Copilot Memory.
- Kiro: steering, memory, Kiro Crew memory.
- Cline: rules.
- Devin: CLI rules, memory.
Consolidation passes
- Anthropic: Dreams guide, Create a Dream, memory stores and versions, the components of agent memory, cookbook: Dreaming with a dynamic workflow.
- GitHub: Copilot Dreaming, managing as an administrator.
- Databricks: memory pipelines, managed memory.
- Mem0: Dream, Dream preview.
- OpenAI: Codex memories.
- Mnemoverse: API reference, API overview.
Related
- Agent memory consolidation compared
- What agent memory consolidation is
- AGENTS.md support by tool
- CLAUDE.md, AGENTS.md and Cursor rules
- Anthropic's memory API
- Agent memory write gate
Sources were read on 25 November 2026; the page describes them as of that date.
Who wrote this. Mnemoverse publishes this page and is one of the systems in its table, so we are an interested party. Every behaviour is quoted or paraphrased from the vendor's own documentation on the date in Sources, ours included. Send corrections through contact.
Edward Izgorodin · Mnemoverse · 28 November 2026
