Deep dive

Why your coding agent forgets everything, and how memory should work

Every new chat starts as a stranger, even though you explained the same three rules last week. Context windows are not memory. Here is what memory actually requires.

November 27, 2026 · 8 min read

Ask a coding agent why the migration runner has to be invoked by hand and it will tell you, in detail, because you explained it yesterday. Ask it again tomorrow and it has no idea. The context window is not memory: it is a buffer that gets compacted, truncated or thrown away when the chat ends.

That gap is where most of the frustration with agents lives. Not model quality. Missing continuity.

Three kinds of memory, only one of which people mean

  • Session memory. The conversation itself. It is lossy by design: summarization drops details, and a long enough run will always push the earliest turns out.
  • Instruction files. AGENTS.md, CLAUDE.md, rule folders. Durable and cheap, but static. Nobody updates them mid task, so they drift from reality.
  • A durable store. Facts, decisions and lessons written down as records, retrieved by relevance, and injected into the next turn. This is what people mean when they say an agent "remembers".

Most tools stop at the second kind. That is why the same correction gets made every week.

What a durable store needs

Bolting a vector database onto a chat loop is the easy part. The hard part is making the retrieved text worth the tokens.

Typed entries, not a text blob

A fact, a standing rule, a decision and a past mistake are different things. They should be stored differently, scored differently, and expire differently. A rule you stated once should outrank a random observation from three weeks ago.

Retrieval with a reason

When an entry is injected into a prompt, the agent should know why it is there: matched the file you are editing, matched the project, or is a standing rule that always applies. A memory the model cannot attribute is a memory it will misapply.

A token budget

Memory competes with the code you are actually working on. A good implementation caps injection at a small slice of the context, keeps a separate always on budget for standing rules, and never lets retrieval crowd out the task.

Editable by a human

If you cannot read the memory, you cannot trust it. Every entry should be visible, searchable and deletable, ideally mirrored into the project so it can be reviewed like any other file.

How Tuffcode does it

Memory in Tuffcode is a typed graph, not a transcript. Entries carry a kind, an importance, links to related entries, and the project or thread they came from. Retrieval scores by relevance to the current turn and injects the top entries under a fixed token budget, with the reason attached.

Two things make it practical:

  • Standing rules are captured as you type. Phrases like "from now on", "always use" or "never use" become high importance rules instead of disappearing into scrollback.
  • A notetaker subagent writes during a run. It has read access and memory tools only, so it extracts durable facts without being able to edit code.

Because it is a graph, you can ask what a decision is connected to, not just whether the words match.

What to store, and what not to

Store itSkip it
Rules that apply to every change in this repoAnything the code already says out loud
Decisions with a reason ("Claude goes through Claude Code, never the raw API")One off debugging details from a single failed run
Mistakes that cost an hour and will cost another hourRestatements of the current task
Commands and paths that are not discoverableSecrets, tokens, customer data

The failure mode of memory is not forgetting. It is remembering too much, badly, and injecting noise into every prompt.

How to test whether an agent really remembers

  1. Tell it a rule in plain language. "From now on, never use any in this repo."
  2. Close the app completely. Reopen it. Start a new chat in the same project.
  3. Ask it to write a typed function without mentioning the rule.
  4. Ask it why it avoided any.

If step four produces a citation to the rule you gave, the memory is real. If it produces a plausible story, it is improvising.

Related: how Council uses memory during a run, and parallel subagents without merge hell.