SIAgentNews.com
← All news
DevelopingClaudeAgents

A small script keeps one AI agent's chat history out of the wiki the next agent reads

A dev.to builder wrote a Python checker that stops session memory leaking into shared Markdown notes, so a replacement agent starts from clean context.

4 min readMade with AI

The short version

  • The script is about 780 lines of standard-library Python and comes with eighteen tests.
  • Pages declare a layer: shared, agent-local, or raw. Only shared pages are passed to the next agent.
  • It flags session phrasing, muse:// connector links and agent-local paths on shared pages.
  • It blocks when two agents have unreviewed writes to the same shared page.
  • pack --for builds a budgeted CONTEXT.md and lists other agents' local notes by title only.

A new agent reads files, not chats

As dev.to reported, a builder looked at the popular advice to keep a git-backed Markdown wiki as shared memory for several AI agents. The advice is half right, the author argues. The wiki is the only memory that survives swapping one bot for another. But it only helps if the wiki holds knowledge rather than the previous bot's conversation.

The second agent cannot read the first agent's session. It also lacks the tool connections the first bot set up, and it cannot make sense of a scratch note written for another workspace. If any of that got pasted into a shared FAQ, the newcomer reads it as a rule. The author calls the result a contaminated source of truth.

The fix is a script called wiki_contract.py. It is about 780 lines of Python that use only the standard library, so nothing extra has to be installed. Eighteen tests cover its behavior, and it never rewrites a wiki page.

11blocking findings on the author's deliberately messy sample wiki

Why it matters

Sharing a git repo of notes between AI agents sounds like portable memory, but the next agent can only read files, not the last agent's chat. If the first agent's session leaked into shared pages, the second agent treats that leftover as policy. Separating shared knowledge from private scratch is a habit you can adopt without this script.

Three layers and a leak detector

Each page declares a layer in its header block, known as frontmatter. Shared pages are what the next agent may inherit. Agent-local pages hold one bot's tone notes, connector IDs and scratch work. Raw pages are source documents, not pages to hand over directly. A file inside an agent's own folder counts as local even without a label, while a loose file at the top of the vault with no layer is reported as a problem.

On shared pages, the checker hunts for first-person session talk, such as a bot saying it will remember something or referring to an earlier session. It also looks for muse:// connector addresses, conversation IDs and paths pointing into an agent's private folder. Agent-local pages are not scanned, since that is what the folder is for. The author deliberately leaves out ordinary operational mentions, such as saying production uses Claude Code.

Two more rules apply. A shared page that cites a raw source in its body must also list that source in its frontmatter, or the check blocks. And the script keeps a log of which agent wrote which shared page. If two different agents have unreviewed writes on the same page, it blocks until a human reads the result and records a review.

The messy vault test

The demo uses an invented type foundry, Cadence Type Foundry, so the pages are not real licenses or prices. The clean version has five shared pages, five raw files and four agent-local pages, and the check passes. The messy version imitates a bad week: a front-desk bot wrote its last Claude session into the licensing FAQ, a weekend note with a conversation ID sat at the top of the vault with no layer, and a price list lost its source declaration. Both agents also edited the same specimen-release page without review.

The check then reports eleven blocking findings. Most are leakage hits on the FAQ and the weekend note. The rest are the unreviewed two-agent edit, the missing layer, and the undeclared price-sheet citation.

Marking the specimen page as reviewed clears the conflict but leaves ten findings. Review confirms that a human looked, and it does not clean the FAQ. The author says the undeclared citation is the quiet danger. The page still gives the right price, but nothing records which source backs it, so a later pack could keep the page and lose the link.

Packing context for the incoming agent

The pack command builds a file named CONTEXT.md for a named agent within a character budget. It includes shared pages in priority order until the budget runs out. Raw sources appear as a path and title, not full text. Other agents' local pages show up in an opening list by title only, so the newcomer knows they exist but does not receive their content.

For a new research agent with a 6,000-character budget, the clean vault produced a 2,954-character file holding all five shared pages. With a tighter 1600-character budget, the file came to 1320 characters, with only the high-priority licensing FAQ included and the low-priority brand-voice page first on the omitted list. The opening list of what is not inherited stays even when no page fits.

On the messy vault, pack still writes a file but warns that the FAQ has leakage. It is a compiler for shared context, not a cleaner. The weekend note stays out because it has no layer, but the contaminated FAQ goes in.

From script to habit

The author admits a script is a good way to learn the rule but a weak way to enforce it once several people add agents to one vault. The rule should live in the workspace itself, so that shared pages, private scratch and conflicting writes are handled by the tooling, not by someone remembering to run a check.

The underlying idea is simple enough to use without the code. Decide what is shared, what belongs to one bot, and what is original source material. Keep session talk and connector details out of the first group. We have not tested the script ourselves, and the article describes the author's own demo, not independent results.

What to watch

  • Whether agent platforms build shared-versus-local memory layers into their workspaces instead of leaving them to custom scripts.
  • Whether teams find that leakage checks like these catch real problems in live repos, not just a fictional demo vault.

Try it

Search your shared notes for phrases like 'last session' or 'as I mentioned', plus connector links and private folder paths. Move any hits to a private notes folder.

Up nextEvolving Profile keeps your coding agent's memory on your own machine

More stories

Say why

Liked it? Say why

Add a line for other readers.

No account needed. We never show your email. Comments with links, ads or abuse are held and not shown. Your comment shows after a quick check.

Sources

The reporting and documents this story is built from. Each link opens the original.

Written with AI by the SI Agent News Desk from the reporting above. Every number is checked against it.Spot a mistake? Corrections.

More AI news