← All insights

KN-09 · Load and compaction map

What your agent still knows after a compaction

Two moments decide what an agent knows: the start of a session, and the moment its context is compacted. Most confusion about "it forgot my instructions" comes from not knowing what each harness reloads at those two moments. We read the docs, then tested where the docs stop.

6 min readGuildBuild Team
AI agentsAgent memoryContext compactionContext engineeringClaude CodeCodexAgent handoffs
In this article

Saved, loaded and used

Figure 01Illustrative mechanism

A saved fact has to reach the next decision

  1. Saved

    A fact exists in a file or session record.

    A durable handoff keeps a path, the next action and what must still be checked.

  2. Loaded

    The harness reloads a file or the agent retrieves it.

    Root instructions can reload in Claude Code. A note behind an index may still need a read at task time.

  3. Used

    The agent applies the fact to the task.

    Check the resulting action against the source. An agent can read a note and attribute its author’s experience to itself.

Conceptual sequence. Reload and retrieval depend on the harness, release and configuration.

Claude Code: what loads at startup and after compaction

Compaction reduces the conversation carried forward; it does not make every saved file part of the new context. This load map follows Claude Code's memory documentation and compaction breakdown, checked on 14 October 2026.

At start it loads:

  1. Applicable CLAUDE.md files on the directory path, with their imports; nested files load when relevant work reaches them.
  2. The first 200 lines or 25 KB of the MEMORY.md index, whichever comes first, when auto memory is enabled.
  3. Available skill names and descriptions; skills disabled for model invocation are an exception.

After a compaction it reloads from disk:

  1. The project's root CLAUDE.md and its unscoped rules.
  2. The memory index.
  3. The bodies of skills already invoked, capped.
  4. Up to five recently read or edited files; a large file can return as a path reference rather than its contents.

The distinction matters: project-root CLAUDE.md reloads from disk. Nested CLAUDE.md files and path-scoped rules reload on demand, not necessarily immediately after compaction.

In our setup, other notes and reference files were routed through index lines and the model's judgment. That is where we tested.

Does a memory index trigger a file read?

  1. Asked a question, yes. A running seat was sent six questions. It opened the routed file each time, including one whose index line was written after it started. It reads the index from disk.
  2. At start, no. A fresh seat whose index carried an at-every-start section was sent only its name. It opened nothing.
  3. At the first real question, yes again. Given a remark with no keyword from any file, the fresh seat opened three notes whose triggers matched, about 9.5 KB, and placed the remark correctly. A seat started without the index answered the same remark from general knowledge.

In these tests, the index worked at question time, not on a start-only prompt. If something must be read before the first task, do not rely on an index line alone. Use an explicit startup instruction or a tested start hook, and verify the read.

One side effect is worth knowing. After reading a routed note, the seat said "I" about a cost that the note's author had paid, not the seat. A routed read can produce a false first person.

Codex: what nine compactions showed about handoffs

We read nine compactions in three chats, on CLI 0.159.2. These are observations from that setup, not a guarantee about every Codex release.

  1. In the observed replacement history, the human's own messages were kept, verbatim and in order.
  2. The visible replacement history held no tool output or assistant message. Beside it the record kept the last few messages in clear text; whether the model was shown those cannot be told from a log. An encrypted compaction item also carried state.
  3. A long hash, a word and a number came through two compactions exact, with nothing visible holding them. Some information survived without appearing in the readable history.
  4. A message from another agent, sent through the app's tool, landed as tool output. After the first compaction, a stub naming the sender was visible in the replacement history, but the message body was not.
  5. A message put in through the tested queue landed as a user message, and its text stayed in the observed history.

So a peer handoff can lose its visible message body. That alone does not prove its meaning was lost: OpenAI's compaction documentation describes the carried state as opaque. Test the facts the next agent needs, not just what the log displays.

Generated memory showed a separate startup issue. The summary injected at start arrived cut: about 2,500 tokens of a real store's 6,100, with the middle removed. In our case the part lost held the routing entries for the current work. This behavior is also reported in openai/codex issue 48679. That issue is a version-specific bug report, not a permanent product limit or a compaction retention rate.

We have not exhaustively checked message-retention budgets. Ours is narrower: what a handoff between agents needs to survive.

Figure 02Evidence comparison

Two message routes left different visible records

Peer handoff

How it entered contextArrived as tool output.

What the study could seeA sender stub remained. The peer message body was absent from the visible replacement history.

Queued message

How it entered contextArrived as a user message.

What the study could seeThe text stayed in the visible replacement history.

Generated memory

How it entered contextInjected at startup in a separate case.

What the study could seeAbout 2,500 of 6,100 tokens loaded. The missing middle held routing entries.

Nine compactions across three chats on Codex CLI 0.159.2. Opaque state can carry information beyond the readable history. The startup truncation case concerns a separate mechanism.

What to do with it: preserve agent memory and handoffs

  1. Anything that must survive a compaction belongs where the harness reloads it: the root instruction file, or a file on disk the agent is told to read.
  2. Anything that must be read at start needs a hook or a line in the instruction file.
  3. Do not hand work to a Codex peer in a message and expect it to outlive a compaction. Put it in a file and send the path.
  4. Keep must-always-apply rules out of generated memory.

How we know: versions, sources and limits

  1. The Claude Code load list is from the docs, read in late September 2026. The index tests are three seats on Sonnet 5. Recall depends on model and effort, so a larger model may differ.
  2. The Codex findings are from CLI 0.159.2, early October 2026. The value that survived two compactions was tested on one model.
  3. Both harnesses ship often. Every line here belongs to its release. Documentation was rechecked for this article; the original experiments were not rerun.
  4. A saved file is not proof of a completed read, and a completed read is not proof of compliance. For enforcement, see Real guards versus prose (KN-01).

Related field note: Where the tokens go in a real agent team (KN-02).