The question
In Context rot, the harness shrank the context by summarizing the test log and saving the full log to disk. That was the first half of context management: deciding what goes into the context. Now the second half: where does everything outside the context live, and how is the context rebuilt from it on every turn?The answer
Split the agent’s state into separate stores, one for each kind of information. Before every call, a context builder in the harness picks what the next call needs from those stores and assembles a fresh context.The seven-store split is this guide’s design. The last two columns show where Claude Code and Codex keep each kind of state, as real examples.
Why separate stores?
Not all state is alike. Two questions sort it:- How long does it need to live? For this call only, for this session, across future sessions, or permanently.
- Who needs it? The model on every call, the model only sometimes, the harness only, or the user.
npm run test:unit” is useful in every future session. The model choice is needed only by the harness. Each answer pair points to a different store.
The seven stores
Using the same session-expiry bug as before. The examples are illustrative. Claude Code keeps most stores under~/.claude/ and Codex under ~/.codex/; the full paths are in Sources.
Where real agents keep it
The two products agree on most stores but make different choices on three:
- Task state. Claude Code keeps the task list in its own store. Codex records its plan as part of the conversation, so the plan lives in the transcript alongside everything else.
- File recovery. Claude Code snapshots files before editing them, so an edit can be undone without git. Codex can rewind a conversation, but its rewind does not restore files; undoing a code change relies on git.
- Large tool output. Claude Code moves large outputs, like the 6,000-line log, into separate files next to the transcript. Codex writes tool output into the transcript itself.
How the context is rebuilt
Before call 51, the context builder takes a small piece from some stores and leaves the rest on disk. Each box below is labelled with the store it came from:Working context for call 51
System promptHarness
Tool definitionsHarness
Memory: run tests with
npm run test:unit.MemoryUser: Fix the session-expiry bug. Don’t change the
isExpired signature.HistoryTasks: ✓ reproduce the bug · ✓ fix the comparison · ☐ run session testsTask state
Summary: 1 test fails: sessions expire 1 ms late at the boundary.History
Current diff: session.ts,
> changed to >=CodeStays outside the context
Full 6,000-line test logHistory
Older messages and tool resultsHistory
Explorer subagent’s full search trailSubagent history
session.ts as it was before the editFile recovery
Model choice and allowed commandsConfiguration
The rest of the repositoryCode
Sources
All paths are as of October 2026 and can change between versions.Claude Code
From the.claude directory reference:
- Conversation history:
~/.claude/projects/<project>/<session>.jsonl. Large tool outputs are moved to<session>/tool-results/. - Subagent history:
~/.claude/projects/<project>/<session>/subagents/ - Task state:
~/.claude/tasks/ - Persistent memory:
~/.claude/projects/<project>/memory/ - File recovery:
~/.claude/file-history/<session>/ - Configuration:
settings.json, described in Settings
Codex
From OpenAI’s docs, the openai/codex source at commitc7234c1, and a local Codex install:
- Conversation history:
~/.codex/sessions/YYYY/MM/DD/rollout-<timestamp>-<id>.jsonl, with tool output stored inside the transcript (recorder.rs, local install) - Subagent history: each spawned agent’s transcript is stored in
sessions/with its parent thread’s ID (local install) - Task state: recorded in the conversation by the
update_plantool (plan.rs) - Persistent memory:
~/.codex/memories/, off by default (Memories) - File recovery: rewinding a thread writes a new transcript file and does not restore files (
revert_thread.rs) - Configuration:
~/.codex/config.toml(Config basics)
Continue the walkthrough
Why not one blob
Continue to topic 5 of 14: why each store uses its own format.