AI agentsAgent memoryContext compactionContext engineeringClaude CodeCodexAgent handoffs
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.
Website/share card for KN-09 — Load and compaction map.
Saved, loaded and used
Conceptual map, not a recall benchmark. Storage, loading and correct use are separate checks.
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:
Applicable CLAUDE.md files on the directory path, with their imports; nested files load when relevant work reaches them.
The first 200 lines or 25 KB of the MEMORY.md index, whichever comes first, when auto memory is enabled.
Available skill names and descriptions; skills disabled for model invocation are an exception.
After a compaction it reloads from disk:
The project's root CLAUDE.md and its unscoped rules.
The memory index.
The bodies of skills already invoked, capped.
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?
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.
At start, no. A fresh seat whose index carried an at-every-start section was sent only its name. It opened
nothing.
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.
The load map follows current documentation. The index observations are small tests on three Sonnet 5 seats, not a population recall rate.
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.
In the observed replacement history, the human's own messages were kept, verbatim and in order.
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.
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.
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.
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.
CLI 0.159.2 field observations. Visible absence does not establish semantic loss from opaque compacted state. Startup-memory truncation is a separate, version-specific issue.
What to do with it: preserve agent memory and handoffs
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.
Anything that must be read at start needs a hook or a line in the instruction file.
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.
Keep must-always-apply rules out of generated memory.
Practical design guidance, not a measured guarantee. Suggested handoff fields add implementation detail without changing the original four recommendations.
How we know: versions, sources and limits
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.
The Codex findings are from CLI 0.159.2, early October 2026. The value that survived two compactions was tested on
one model.
Both harnesses ship often. Every line here belongs to its release. Documentation was rechecked for this article;
the original experiments were not rerun.
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).