Engram Blog · Published November 20, 2026

The Memory Layer: How Engram Plugs Into Your AI's Harness

Every AI app wraps the model in a harness, and the harness decides what the model remembers. Here is how that memory works in Claude Code, ChatGPT, Codex and the rest, where it breaks, and how Engram plugs in as one memory layer your tools share.

“If you're not the model, you're the harness.” That's how LangChain's Vivek Trivedy put it in March 2026, and it's a useful way to look at any AI app you use.

When you work in Claude Code, ChatGPT or Codex, you aren't talking to a bare model. You're talking to a model wrapped in software that decides what it sees, which tools it can use and what it remembers. That software is the harness. This post is about one part of it, memory: how each harness handles it today, where that breaks down, and where Engram fits.

What a harness does

A language model on its own is text in, text out. It doesn't remember your last conversation, or even your last message, unless something sends it again. Every time you press enter, the harness rebuilds the model's input from scratch: its instructions, your files, the results of any tools it ran, and the conversation so far. The model knows only what the harness puts in front of it.

So when it comes to memory, the harness has four jobs:

  • Assembling: choosing what goes into the context window, the model's working space, on each turn.
  • Reducing: making room when the conversation gets too long, usually by summarizing it. Claude Code calls this compaction.
  • Recording: writing down what happened somewhere outside the context window.
  • Carrying: bringing what was recorded into the next session.

These choices matter about as much as the model does. In the same post, LangChain reported that its coding agent climbed from the top 30 to the top 5 on Terminal Bench 2.0, a benchmark of coding tasks done in a terminal, by changing only the harness. The model stayed the same.

Every app keeps memory its own way

Here's what the main AI tools carry from one session to the next, going by their own documentation as of November 2026:

AppWhat carries overWhere it lives
Claude CodeCLAUDE.md files you write, plus auto memory: notes Claude keeps for itself. It loads the first 200 lines or 25KB of the memory index each session.Your computer. Auto memory stays on the machine it was written on.
Codex CLIAGENTS.md files you writeYour computer
Gemini CLIGEMINI.md files, sent with every prompt. It can be set to read AGENTS.md too.Your computer
GitHub CopilotFacts about each repository, shared with everyone who has access to it, and your own preferences. Memories expire after 90 days unless Copilot confirms them again; owners can set repository facts to last anywhere from 7 to 180 days.GitHub
Claude (web, desktop, phone)Short topic files Claude writes about youAnthropic, in your account
ChatGPTA list of facts it decided to keep about youOpenAI, in your account

Claude and ChatGPT can also look back through your earlier chats, but only the ones you had in that same app. Claude Code keeps a full transcript of each session on your disk so you can resume it, and deletes those transcripts after 30 days by default.

Two things stand out. First, every one of these memories stays inside its own app: what ChatGPT has learned about you never reaches Claude Code, and the reverse. Second, most of them are notes the app wrote, not what was actually said. We went into what that costs in Your AI Doesn't Remember Your Conversations. The only memory that moves between tools is a file you write yourself, like AGENTS.md, which Codex reads and Claude Code and Gemini CLI can load too.

Why a bigger context window doesn't fix it

The obvious answer is to keep everything in the window. Context windows now hold hundreds of thousands of tokens, some a million. But study after study finds that models get worse as the window fills, long before it's full:

  • Chroma tested 18 models in July 2025 and found they answered better from a focused prompt of about 300 tokens than from the full conversation of about 113,000 tokens that held the same answer. Chroma calls this context rot.
  • NoLiMa (ICML 2025) asked 13 models to find a fact when the question didn't use the same words as the fact. At 32,000 tokens, 11 of them scored less than half of what they managed on short inputs. Even GPT-4o, one of the two that stayed above half, fell from 99.3% to 69.7%.
  • LongMemEval (ICLR 2025), a benchmark for long-term memory in chat assistants, found that commercial assistants and long-context models lost about 30% accuracy when they had to remember information across long, ongoing conversations.

And when the window does fill up, the harness has to make room. Claude Code does it by compacting: it swaps the conversation for a summary. In an illustrative example in Claude Code's documentation, compacting takes the context from 22,225 tokens to 17,095, and everything said up to that point comes back as a 1,725-token summary.

What survives compaction intact is what Claude Code reloads from disk: the CLAUDE.md at your project's root, rules that apply to the whole project, auto memory, your plan if you made one, up to five recently read files (a file over 5,000 tokens comes back as just its path), and the instructions of any skills in use, up to 5,000 tokens each. Everything else, including what you decided, what you ruled out and why, exists afterward only as far as the summary kept it. Even context that a hook added earlier is summarized along with the rest. We wrote about what that looks like day to day in After the Compaction.

Where Engram plugs in

Engram doesn't replace the harness. It takes on the two memory jobs a harness does worst on its own, recording and carrying, and gives assembling better material to work with.

Harness jobWhat Engram does
RecordingThe Engram CLI watches the session files Claude Code and Codex CLI write on your computer and saves each conversation word for word as it happens. In other apps, your AI saves what you ask it to, and you can import your ChatGPT and Claude history.
CarryingEverything lands in one memory. ChatGPT, Claude, Cursor and the other apps you connect all search the same place, so a decision made in one is there in the next.
AssemblingWhen your AI searches Engram, it gets back the original passages, ranked by meaning and by exact words, with a small boost for recent ones. The harness decides what to do with them.
ReducingNot Engram's job. Compaction still happens; Engram means the words it drops can still be found.

There are four common ways to connect a harness to a memory like this:

  1. Tools. The memory offers search and save tools, and the model decides when to call them. Engram works this way in every app, through the Model Context Protocol (MCP), the open standard AI apps use to connect to outside tools.
  2. Instruction files. A few lines in CLAUDE.md or AGENTS.md, or a skill, telling the model when to search and when to save. Engram's Claude Code plugin ships a skill that does this.
  3. Hooks. The harness runs a command at a fixed moment, like the start of a session, and adds what it prints to the model's context. There's an example below.
  4. Automatic injection. The memory searches on every turn and slips the results into the prompt before the model sees it.

Engram uses the first three, plus the CLI's background capture. It doesn't inject on every turn, on purpose. Injection costs tokens on every turn whether or not the memory is relevant, and if something bad ever got into memory, injection would put it in front of the model on every turn too. With tools, the model asks when it needs something, and each search shows up in the conversation where you can see it.

Why Engram keeps the words, not a summary

Most built-in memory saves a digest: a list of facts, a short note, a profile. That's cheap to store and cheap to load into every chat, but anything the digest left out is gone for good.

LongMemEval tested this directly. Its authors found that:

  • Storing each exchange (one message and its reply) as its own entry worked better than storing whole sessions.
  • Replacing the original text with summaries or extracted facts lost information. The one exception was questions that reason across several sessions.
  • Extracted facts helped most as an index, not a replacement. Used as extra search keys that point back to the original text, they raised recall by 9.4% and accuracy by 5.4% on average.

That's close to how Engram works. Every conversation is kept word for word and indexed in small passages, so a search can land on the exchange that matters. Each search result carries a short summary to help your AI choose between matches, alongside the original text it came from.

One caution about memory benchmarks: the numbers are shakier than they look. In April 2026, Penfield Labs audited LoCoMo, a widely used memory benchmark, and found that 99 of its 1,540 answers were wrong, so even a perfect system tops out around 93.6%. In their tests, the AI judge used to grade it marked 62.81% of wrong answers as correct. And in one public thread in May 2025, Mem0's CTO re-ran Zep's reported 84% LoCoMo score and got 58.44%, and Zep then posted a corrected 75.14%. When anyone quotes a memory score, ourselves included if we ever do, ask how it was graded.

Making recall reliable after compaction

In Claude Code, the moment memory matters most is right after a compaction, when the details have just left the window. There are two ways to make sure Claude checks Engram then.

An instruction in CLAUDE.md. Our compaction post has a ready-made block to paste in. CLAUDE.md reloads after every compaction, so the instruction survives it. But as Claude Code's memory documentation points out, these files are context Claude reads, not settings it is forced to obey. Usually it follows them, but nothing guarantees it notices that a compaction just happened.

A hook. Claude Code can run a command each time a session starts, and one kind of start is compact: it fires right after a compaction. Whatever the command prints is added to Claude's context at that moment (see the hooks reference). So instead of hoping Claude remembers to search, the harness asks at exactly the right time:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "compact",
        "hooks": [
          {
            "type": "command",
            "command": "echo 'The conversation was just compacted. Before you continue, search Engram for the decisions, constraints and open questions behind the current task.'"
          }
        ]
      }
    ]
  }
}

Put it in ~/.claude/settings.json to cover every project, or in .claude/settings.json inside a repo to share it with everyone who works there. If the file already has a "hooks" section, add the SessionStart entry to it rather than pasting in a second one.

The hook doesn't search anything itself. It puts a one-line request in front of Claude at the moment it's needed, and Claude runs the search with Engram's tools, whether you connected them through the plugin or with claude mcp add. If you change the hook to print more, keep it short: Claude Code caps hook output at 10,000 characters, and anything longer is moved to a file instead.

Memory is also an attack surface

Anything an AI reads can try to give it orders, and memory is something it reads again and again, across sessions. A September 2026 study of memory poisoning tested this on Claude Code and OpenClaw. On Claude Code, averaged across the models and scenarios they tried, planted instructions made it into persistent memory 66.9% of the time, and poisoned memory went on to trigger the attack in a later session 81.7% of the time. A defense written into the prompt cut down the planting in many settings, but did little once the memory was already poisoned.

Here's what Engram does about that today:

  • Secrets stay out of memory. Engram's vault (engram vault set) encrypts a secret on your computer with AES-256-GCM before it's uploaded, and the connector your AI uses can't read it.
  • Known secrets are scrubbed. When the CLI captures a session, it replaces any exact vault value it finds with a placeholder like [VAULT:name] before sending it.
  • You decide what's captured. engram exclude add <path>, or a .engramignore file at a repo's root, keeps a project out. Saying “don't save this to engram” in a Claude Code or Codex session stops the capture and erases what was already saved (more on that).
  • You can delete anything. Any saved conversation can be deleted, including by asking your AI to delete it.

And what it doesn't do yet:

  • Engram doesn't ask you to approve each save. Many apps ask before running any tool, but that's the app's setting, not Engram's.
  • Search results show a conversation's title, not which app saved it, so your AI can't tell at a glance where a memory came from.

So treat what comes back from memory the way you'd treat a web page: information to weigh, not orders to follow. If your AI ever acts on a “memory” you don't recognize, look it up and delete it.

What Engram doesn't do

  • It doesn't replace CLAUDE.md, AGENTS.md or auto memory. Those are the right place for standing rules. Engram is the record of what was said.
  • It doesn't stop compaction. It makes what compaction drops findable again.
  • It can't find what it never saved. Automatic capture covers Claude Code and Codex CLI, with the Engram CLI running on your computer. Everywhere else, Engram has only what your AI saved or you imported.
  • In most apps, recall depends on the model deciding to search. Instructions and hooks make that much more reliable, but not certain.

Get started

In Claude Code, install the plugin, then restart Claude Code and sign in when your browser opens:

/plugin marketplace add get-engram/engram
/plugin install engram@engram

For automatic capture of your Claude Code and Codex CLI sessions, add the Engram CLI. The Claude Code guide walks through it with Homebrew or npm.

In Claude or ChatGPT, connect Engram from their directories in a couple of clicks (here's how). Guides for all twelve supported tools, including Cursor, VS Code and Gemini CLI, are in the docs.

Create a free account, or see what each plan includes on the pricing page.

Questions, or something not working? hello@getengram.app.