Your LLM Wiki Saved 400 Notes and Still Forgot. I Wrote a Memory Budget for That.
This week's feed kept treating "just let the model write more notes" as a memory strategy. Anthropic's components of agent memory study, published 6 November 2026, put a clean number on why that fails. Playing PokΓ©mon Re
This week's feed kept treating "just let the model write more notes" as a memory strategy. Anthropic's components of agent memory study, published 6 November 2026, put a clean number on why that fails. Playing PokΓ©mon Red, Claude Sonnet 3.7 wrote 413 memory files across 225 folders and earned one badge. Claude Fable 5 wrote nine files in two folders, plus a single global.md, and earned four. Sonnet treated everything as potentially important β often a file per battle, item, or NPC β and around step 10,000 it spent 17 steps creating and deleting notes without taking an action in the game. Fable 5 used memory for things the screen did not already show: a current goal, a plan for the gyms, and tested rules. The official write-up is explicit about the limit: these were different models and single runs, so the comparison does not isolate memory management as the cause of better play. The shape of the failure is still useful. A bigger archive was slower to use and constantly going stale.
The same week, the quieter second-brain posts named the everyday version of that failure. One that stuck: an agent that creates notes without reading what the vault already says leaves you a fourth version of the same note, and the second brain becomes a second inbox. Search-before-write is the rule. Most LLM wikis I look at do not enforce it.
So this post is a 605-line, stdlib-only Python script called memory_budget.py. You point it at a Markdown wiki whose pages declare a kind β core, ephemeral, or archive. It requires a global.md dashboard with a current goal and memory rules, counts the working set against a budget (default 10), clusters near-duplicate pages, and flags screen-state phrasing that has leaked onto a core page or been left at the vault root. plan writes a COMPACT.md of recommended moves. It never rewrites a wiki page. Twenty-one tests pin that down.
A budget is not a backup
The failure mode I keep seeing is "the wiki is the memory, so every useful sentence deserves its own page." That is how you get a 400-note vault that still cannot answer the question you asked yesterday. The model spends the context window rereading snapshots of a world that has already changed. A budget is narrower than a backup.
- Pages opt in with
kind:in frontmatter. A file underlog/is treated as ephemeral even if the field is missing. A file underarchive/, orkind: archive, is out of the working set. A file at the vault root with no kind is a warning β unless it already failed as unfiled ephemeral. - The working set is what a new session should actually load:
global.mdplus core pages. Ephemeral notes and the archive do not count against--budget. That is the whole point of filing them. -
global.mdhas to exist, and it has to contain a current Goal and Memory rules. Fable 5's dashboard held the current goal, a plan, and the model's own rules for using memory. A folder of pages with no dashboard is just a directory. - Near-duplicate clusters are blocking. Title Jaccard or body Jaccard (stopwords stripped) is enough to catch the fourth varnish page. Log notes are exempt: daily haul-out logs are allowed to sound alike.
- Screen-state phrasing β "as of today," "current inventory," "the shop is at 12," "right now we have" β is blocking on a core page. Durable process numbers such as "clamp time is eight hours at 18β20 C" are not matched, on purpose. The same phrasing at the vault root is
unfiled_ephemeral: move it underlog/. -
check --budget 10exits 1 if any finding is blocking.plan --out COMPACT.mdwrites the recommended moves. Neither command edits a wiki page.
EPHEMERAL_RULES = [
("as-of-today snapshot",
re.compile(r"\bas of\s+(?:this\s+)?(?:morning|afternoon|evening|today|tonight|\d{4}-\d{2}-\d{2})\b", re.I)),
("today's reading",
re.compile(r"\b(?:today|this morning|this afternoon|tonight)'s\s+"
r"(?:weather|temperature|temp|inventory|count|reading|cash|balance|stock|notes?)\b", re.I)),
("current screen-state",
re.compile(r"\bcurrent(?:ly)?\s+(?:the\s+)?(?:shop\s+)?(?:temperature|temp|"
r"inventory|count|weather|cash|balance|stock|location|position|humidity)\b", re.I)),
# plus right-now inventory, today's shop condition, and live inventory counts
]
def inspect(root, budget=10):
pages = load_pages(root)
findings = []
if "global.md" not in {p.rel for p in pages}:
findings.append(Finding("missing_global", "global.md",
"vault has no global.md dashboard (current goal + memory rules)"))
working = [p for p in pages if p.in_working_set] # not log/, not archive
if len(working) > budget:
findings.append(Finding(
"over_budget", "working-set",
f"working set is {len(working)} pages; budget is {budget}",
))
for cluster in duplicate_clusters(pages): # working-set pages only
keep = pick_keep(cluster)
names = ", ".join(p.rel for p in sorted(cluster, key=lambda p: p.rel))
findings.append(Finding(
"duplicate", keep.rel,
f"near-duplicate cluster of {len(cluster)} pages; search before write failed",
evidence=names,
))
for page in pages:
for kind, snippet in scan_ephemeral(page.body):
if page.kind == "core":
findings.append(Finding(
"ephemeral_on_core", page.rel,
f"{kind} on a core page (durable memory should be rewritten, not snapshotted)",
evidence=snippet,
))
elif not page.under_log:
findings.append(Finding(
"unfiled_ephemeral", page.rel,
f"{kind} left at the vault root instead of under log/",
evidence=snippet,
))
return findings
The comparison is deliberately boring. The script does not know that the varnish system changed. It knows that varnish-system.md now contains "as of today" and "current inventory is 2," and that three other pages share most of its tokens. That is the whole signal. "Clamp time is eight hours at 18β20 C" is a rule. "The shop is at 12 degrees this morning" is a snapshot. Only the second one matches.
The sample vault
The fixture in this post is made up: a fictional spar and mast repair shop I called Harborline Spar Shop, in Port Townsend, Washington. These pages are not a real rate card, a real yard policy, or a real haul-out log.
The clean version has a global.md, six core Markdown pages, and one already-filed log note.
-
global.mdβ current goal: finish the Pearson 36 mast repair before the 12 December 2026 haul-in window. Memory rules: rewrite core pages in place, search before write, keep one-day readings underlog/. It links the six core pages. -
glue-schedule.mdβ West System epoxy on dry, warmed stock; resorcinol for traditionally finished Sitka; clamp time eight hours at 18β20 C; scarfs are 12:1. Priority is high. -
varnish-system.mdβ eight thin coats of traditional spar varnish; Awlgrip only when the owner asks for a two-part linear polyurethane; do not recoat below 15 C. The mix lives here; inventory counts do not. -
haul-out-rules.mdβ a mast comes down only after the yard books the crane and the owner signs the ticket; no unstep above a 25-knot gust forecast. -
insurance-yard.mdβ the yard policy covers spars on their horses once the ticket is signed; tools left on the dock overnight are not covered. -
standing-rates.mdβ shop labor is $92 an hour; after-hours call-out is a two-hour minimum at $140; written estimates above $800. -
shop-voice.mdβ short sentences, no exclamation marks in estimates, say "spar" or "mast," not "pole." Priority is low. -
log/haul-out-2026-11-14.mdβ a single-day log. It does not count against the budget.
check --budget 10 on the clean vault exits 0:
wiki ./wiki Β· 7 core Β· 7 working set Β· 1 log/ephemeral Β· 0 archived Β· 0 unlabeled
budget 10 Β· 0 blocking Β· 0 warnings
ok: memory budget holds
The messy version is the same shop after the kind of week the feed has been describing. There is no global.md. The agent wrote three more varnish pages instead of editing the one it already had. A second haul-out policy sits next to the original rules. The varnish system itself now ends with "as of today the current inventory is 2 quarts." Six one-day notes β shop temperature, inventory, weather, a haul-out, cash in the tin, morning tasks β were left at the vault root. A weekend cover scratch note has no kind: at all.
Running it on the bloated vault
check --budget 10 on that vault exits 1, with thirteen blocking findings and one warning:
wiki ./wiki Β· 10 core Β· 15 working set Β· 3 log/ephemeral Β· 0 archived Β· 5 unlabeled
budget 10 Β· 13 blocking Β· 1 warnings
BLOCK duplicate haul-out-rules.md near-duplicate cluster of 2 pages; search before write failed Β· haul-out-policy.md, haul-out-rules.md
BLOCK duplicate varnish-system.md near-duplicate cluster of 4 pages; search before write failed Β· spar-varnish.md, todays-varnish-thoughts.md, varnish-notes.md, varnish-system.md
BLOCK ephemeral_on_core varnish-system.md as-of-today snapshot on a core page Β· As of today
BLOCK ephemeral_on_core varnish-system.md current screen-state on a core page Β· current inventory
BLOCK ephemeral_on_core varnish-system.md live inventory count on a core page Β· inventory is 2
BLOCK missing_global global.md vault has no global.md dashboard (current goal + memory rules)
BLOCK over_budget working-set working set is 15 pages; budget is 10 Β· shop-voice.md, todays-varnish-thoughts.md, current-cash.md, +12 more
BLOCK unfiled_ephemeral current-cash.md current screen-state left at the vault root Β· Current cash
BLOCK unfiled_ephemeral haul-out-2026-11-28.md as-of-today snapshot left at the vault root Β· As of today
BLOCK unfiled_ephemeral inventory-now.md ephemeral page is not under log/ Β· Current inventory
BLOCK unfiled_ephemeral morning-notes-nov-30.md today's reading left at the vault root Β· Today's notes
BLOCK unfiled_ephemeral shop-temp-today.md ephemeral page is not under log/ Β· Today's temperature
BLOCK unfiled_ephemeral weather-2026-11-29.md as-of-today snapshot left at the vault root Β· As of this morning
WARN unlabeled weekend-cover.md no kind: in frontmatter and path does not imply one
Four things I care about in that report.
The varnish cluster is the search-before-write failure in one line. Four pages share the same coats, the same Awlgrip exception, and the same 15 C cutoff. The agent did not fail to "know" the system. It failed to look. todays-varnish-thoughts.md is not a new decision; it is a fourth inbox copy of a page that already existed.
The three ephemeral_on_core findings on varnish-system.md are the PokΓ©mon problem in miniature. "Eight thin coats" is a rule that stays useful next week. "Current inventory is 2 quarts" is a screen-state fact that is wrong the moment someone opens a can. Leaving it on the core page means every future session has to decide whether the number is still true. Fable 5's habit β rewrite the durable file, do not snapshot what you can re-read β is the fix. The script will not do that rewrite for you.
The working set is 15 pages against a budget of 10 because the unfiled logs are still sitting at the vault root, where they count, and because the duplicate varnish and haul-out pages have not been merged. The header's "5 unlabeled" is the same pile: four of those root files already failed as unfiled ephemeral, and the fifth is the weekend cover warning. Move the logs under log/ and they drop out of the working set immediately. The already-filed 14 November haul-out note, still under log/, does not appear in the report at all.
The missing global.md is the quiet one. Without a dashboard, the next session has no current goal and no rule that says "search before write." The pages are still there. The working memory has no index.
Plan the compact, then check it again
plan --out COMPACT.md exits 1 on the messy vault, because the findings are still blocking, and writes a plan. It does not move a file.
The plan says: write global.md; move the six one-day notes under log/; keep haul-out-rules.md and varnish-system.md, then merge the extras; strip the inventory snapshot off the varnish page; label or file weekend-cover.md. After a human actually does that work β and only after β the compact fixture is a dashboard, the six original core pages, a standing weekend-cover rule, and seven log notes.
check --budget 10 on that vault exits 0:
wiki ./wiki Β· 8 core Β· 8 working set Β· 7 log/ephemeral Β· 0 archived Β· 0 unlabeled
budget 10 Β· 0 blocking Β· 0 warnings
ok: memory budget holds
Eight is still under the budget of ten, with room for a new standing rule. The logs are not gone; they are just not what a new session has to load in order to know how Harborline varnishes a mast. That is the difference between a memory folder and a filing cabinet.
Put the budget where the team already writes
A script like this is only useful if the pages it watches are the pages people will actually correct. The source of truth for a team LLM wiki should be the workspace the team already edits, not a parallel dump an agent maintains in a private repo. If you are building an LLM wiki for more than one person, start with access and review, then connect a model. The same instinct shows up when you self-host the AI stack: keep the knowledge layer where you can see it, and treat the model as a reader with a budget, not as a second archive.
I work on AFFiNE, which is knowledge base software and an AI knowledge base software option teams can run in the cloud or self-host. It is also an open source Notion alternative in the sense that the docs, whiteboards, and databases live in one workspace you can export. For a longer take on structure, review, and a small evaluation set before you roll out answers, we published a guide to how to build a team knowledge base. None of that replaces a budget. It is the place you would keep one.
If you already have a Markdown vault, start with check. If it fails, read plan, then edit the pages yourself. The next session should inherit a small folder of rules, not four copies of the varnish system and this morning's temperature.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.

