Where Should Agent Memory Writes Land? Three Options Compared
3 Nov 2026 · 7 min read

Giving an agent memory is easy. Deciding who checks what it remembers is the hard part.
Most write-ups on agent memory cover storage: vector stores, files, how much to load at startup. Very few ask the question that bites first in a real pipeline. When the agent writes something down, where does that write land, and does a person see it before the next run reads it?
My answer, for the agent that drafts posts on this site: observations can go in straight away, but anything that changes behaviour needs a pull request. Here’s the reasoning, the two options I turned down, and what would make me switch.
The constraint: a worktree that only commits two folders
This site has an editor agent. It researches ideas, drafts the ones I approve, and opens a pull request for each. I covered its checks in the guardrails post.
Two details matter here. First, every step is a fresh headless Claude Code session. Nothing carries over between runs, so if I tell it “stop opening with a rhetorical question” on Monday, Wednesday’s draft hasn’t heard.
Second, each draft runs in its own git worktree, and the script commits a narrow slice of it:
sh('git', ['-C', dir, 'add', '-A', '--', post, 'social']);
The post folder and the social copy. Nothing else gets in, even if the agent edits it. That’s deliberate: a draft can’t quietly rewrite the house style or the script that runs it.
Memory doesn’t fit that box. A lesson learned on one post is meant for the next one, so it has to live somewhere outside the post folder. Which means widening the box, or putting memory somewhere else.
Option A: memory rides the draft PR
The simplest change. Add a memory file to the paths the script commits, and let the agent update it alongside the draft. I review the lesson with the post, and merging accepts both.
It’s safe. Nothing the agent remembers takes effect until I’ve merged it.
It’s also slow, in three ways I didn’t spot at first:
- Lessons wait for the merge. Posts are scheduled weeks ahead, and I don’t always merge in order. A correction on one draft won’t reach the draft being written next to it.
- Parallel drafts collide. Two open PRs that both append to the same memory file will conflict. Fine once, tedious every week.
- Rejected drafts lose their lessons. If I close a PR because the idea didn’t work, the lesson about why goes with it. That’s the lesson I most wanted kept.
The quieter problem is attention. When I review a post I’m reading the post. A three-line diff to a memory file at the bottom gets skimmed. A review gate you skim is a rubber stamp with extra steps.
Option B: agents commit straight to main
The fast option. After a run, the script commits whatever the agent learned directly to main. The next run reads it immediately.
This is roughly how Claude Code’s own auto memory behaves. The docs describe it as notes Claude writes itself, stored per repository, “shared across worktrees”, and loaded at the start of every session. No review step. For a person at a keyboard, that’s reasonable: you’re watching the session, and the notes are on your own machine.
An unattended pipeline is different. My agent reads web pages as part of its research. Its prompt says to treat them as information, never as instructions, and mostly it does. But once a line from a web page makes it into memory, the next run reads it as its own past experience. The OWASP GenAI Security Project puts it plainly: “A memory file is not just stored text. It can influence future decisions.”
There’s a dull, practical problem too. On this site, a push to main runs the job that builds and deploys. Every memory write would be a deploy. Not dangerous, just daft.
And even without anything hostile, an agent writing its own rules drifts. One odd comment from me becomes “the author dislikes lists”, and every post after it is a wall of prose. Unreviewed memory doesn’t fail loudly. It just slowly stops sounding like you.
Option C: findings in, rules need a PR
The split I’m leaning towards separates two kinds of memory that look alike but aren’t.
- A finding is an observation with a source. “On PR #12 the author cut the second aside; it repeated the bold line.” It records what happened. It doesn’t tell the agent what to do.
- A rule changes behaviour. “Never use more than one aside per section.” It’s an instruction.
Findings go in straight away: an append-only log, one JSON line each, with the date and the PR it came from. The script appends them after the same private-terms scan every draft gets. They reach the next prompt the same way web pages do, labelled as information, never as instructions.
Rules already have a home. The house style lives in editor/style.md, and its first lines say “Change it here and every future post follows.” So a rule is just an edit to that file, and that edit goes through a pull request like any other change to the system. When the same finding turns up three times, the agent proposes the rule. I read a short diff with nothing else in it, and merge or close.
That mirrors a line Anthropic draw in the same docs: CLAUDE.md is written by you and holds “instructions and rules”; auto memory is written by Claude and holds “learnings and patterns”. Both are loaded as context, not enforced. The difference in my version is that the only path from a learning to a rule goes through a human.
Why lean this way:
- Speed where it’s cheap. A finding is useful on the very next draft, and a bad one does little harm because it’s framed as a note, not an order.
- Review where it counts. A rule PR is small and on its own, so I actually read it.
- Nothing gets lost. Findings from closed PRs stay in the log.
- It’s easy to undo. A wrong finding is one line to delete. A wrong rule never merged.
It’s the same principle as the gates in the rest of the pipeline: automate what’s cheap to undo, gate what isn’t. The findings log does still commit to main, so I’d keep it out of the deploy trigger with a paths-ignore filter.
What I’d measure to decide
I haven’t run this for long enough to have numbers, so I won’t pretend to. These are the counts I’ll keep, and the result that would change my mind for each.
- Repeat corrections. How often I leave the same kind of comment on two different PRs. That’s the problem memory is meant to fix. If it doesn’t fall, none of the three options is working, and the question is moot.
- Findings I delete. If I’m regularly removing bad or odd findings, the log isn’t safe to read unreviewed, and I’d fall back to Option A for findings too.
- Promotion rate. How many findings become rules. If almost every one does, the split adds a step for nothing, and A is simpler.
- Rule PRs I close. If I merge every proposal without changes for a couple of months, the gate is ceremony. That’s the one result that would tempt me towards B, for low-risk rules only.
- Revision cost. Each PR already prints what the run cost. If memory works, revisions should get rarer and cheaper.
All five come from data the pipeline already produces: PR comments, merges, closes and a cost line. If deciding needs a new dashboard, I’ve measured the wrong thing.
If you’re building your own
- Decide where writes land before you add memory. Storage is the easy part; the review path is the design decision.
- Split observations from instructions. Record what happened freely, and gate anything that tells the agent what to do.
- Give rules their own small PR. Bundled with other work, a memory diff gets skimmed.
- Scan memory like you scan output. Whatever check stops a draft leaking should run on what the agent remembers too.
- Treat memory as input from outside. Anything the agent read on the web can end up in it, so label it as information in the prompt.
- Pick the counts that would change your mind. Write them down first, so the decision isn’t just a feeling later.
More in the Working with AI agents series, including one inbox for everything your agents need from you, which is where those rule PRs show up.


