26.8 How today's tools realize it
- Approved by
- Panaversity ·
Reference. How today's products realize the chapter's ideas. Skim it now, and come back when you choose a runtime or port the month-end review.
In everyday life. On one trip you stay at three hotels. At each, you tell the night clerk that you need a wake-up call at five every morning. At the first hotel, the clerk writes it in the book that every shift reads. At the second, a notice at the desk says the same is done there. At the third, nobody can tell you what the morning shift is told. So on the second day at each hotel you ask the new clerk one question: "What do you have written down for my room?" In this concept, the hotels are three kinds of product, the change of shift is a summary, and your question is the check you run afterward.
What you will learn. You practice this in Lab 26, Task 6.
- How sure is each claim?
- What comes back after a summary, in each product?
- Which differences change a decision?
- What must stay true on any harness?
Why it matters. Every product on this page can summarize a long conversation. They differ in what is put back into the window afterward. For one of them, Codex, the vendor's pages do not say.
At work. Lab 26 ends with a port. You replay the month-end review in two more coding agents, compact it in each, and run the same check by code on the answer. You write down one fact for each product: what came back after the summary.
How sure is each claim?
Most facts on this page are documented. Where a vendor's pages do not say, this page says so.
| Label | Means |
|---|---|
| Documented | Read on the product owner's own pages on November 29 or 30, 2026. A fact with no label is documented |
| Not stated | The vendor's pages were read on November 30, 2026, and they do not say. This page states nothing about it |
| Not yet tested | Documented, but not yet tried in a lab run. That is true of every fact on this page today |
No vendor-neutral standard defines compaction. So this section compares each product with one question from the chapter: after a summary, what is the model reading?
What comes back after a summary, in each product?
On Claude's products, whatever the product sends again on every request comes back, and everything said only in the conversation depends on the summary.
Anthropic: the Messages API. This is the API your own loop calls (21.5). A summary replaces the older turns of the conversation, and the API drops everything before the summary block.1 The system prompt is not a turn. Your code sends it whole with every request, so the worker's instructions come back unchanged. Earlier thinking is known not to come back. On a summary on demand, images and documents and a mid-run system message do not come back either (26.4). And a file written through the memory tool is safe on your disk, but outside the window until something reads it again.2
Note
Watch this: three settings in beta. On November 29, 2026, compaction at a token threshold, compaction on demand and context editing were all in beta on the Messages API, each behind a beta header. Compaction by threshold is the edit compact_20260112, with the header compact-2026-01-12. It starts at 150,000 input tokens unless you set a trigger, and a trigger must be at least 50,000 tokens.1 Clearing old tool results is the edit clear_tool_uses_20250919, with the header context-management-2025-06-27. It starts at 100,000 input tokens and keeps the last 3 tool uses, unless you set other values.3 Compaction on demand has the header compact-2026-09-04, and a request cannot ask for it and carry context editing too.4 The setting exclude_tools names tools whose results a clearing leaves alone, such as the memory tool's, and by default it names none.35 The memory tool is not in beta.2 Check each status again on the day you build.
Anthropic: Claude Code and the Agent SDK. Here the instruction file matters. In Claude Code it is CLAUDE.md. After a compaction, the CLAUDE.md at the project's root is "Re-injected from disk", which means put back from the file. Two kinds of rule come back only on demand: a rule with a paths: setting, and a CLAUDE.md in a subfolder. Claude Code's page gives the fix: "If a rule must persist across compaction, drop the paths: frontmatter or move it to the project-root CLAUDE.md."6 Frontmatter is the block of settings at the top of a rule's file. An instruction given only in the conversation is summarized with the rest, and may be gone.7 The Agent SDK's page says the same in one line: "Persistent rules belong in CLAUDE.md (loaded via settingSources) rather than in the initial prompt". It marks each compaction with a message whose subtype is compact_boundary.8 What a subagent there receives is in 26.5.
Anthropic: Claude Managed Agents. Compaction is "Always on", and the threshold page says each one emits an event named agent.thread_context_compacted.1 The platform's reference page lists that event with these words: "Conversation history was compacted to fit the context window."9 So the history is the part a summary replaces. Whether a session accepts a trigger of your choosing, or the clearing of old tool results, is not stated.
OpenAI: the Responses API and the Agents SDK. The Responses API can compact on its own, when the input passes a compact_threshold that you set. Your code can also ask for a compaction.10 What comes back is a compaction item. It "carries forward key prior state and reasoning", but you cannot read it: "It is opaque and not intended to be human-interpretable."10 So on this API you cannot open the summary to see what it kept. The instructions are apart from the history. The API's page says top-level instructions "apply only to the request that supplies them".11 So your code sends them with every request, as it sends Claude's system prompt.
The Agents SDK has a session type named OpenAIResponsesCompactionSession. It compacts the stored conversation history with the Responses API's responses.compact. By default it checks after each turn, and compacts when the history passes a threshold. Or your code can call run_compaction() between turns. The SDK's page says "Compaction clears and rewrites the session history".12 So the stored history is the part a summary replaces. The SDK calls an agent's instructions its "System prompt".13 A rule written there is outside the stored history. No SDK page says in one sentence that it comes back after a compaction, so that is not yet tested. The SDK's pages name no event that marks a compaction. They say only that its cost is added to the run's usage totals.12
OpenAI: Codex. /status shows the session's settings and its token usage. /compact replaces "earlier turns with a concise summary".14 Codex also compacts on its own at a token limit, which a setting can change.15 Codex reads AGENTS.md "before doing any work". It builds its chain of instruction files once, when a session starts.16 That page does not say what happens to the chain after a compaction. So for Codex, whether a rule in AGENTS.md comes back is not stated.
Open source: OpenCode. OpenCode summarizes the whole conversation when a session comes near the model's limit. Beside the summary it keeps the most recent conversation, "about 15,000 tokens by default".17 This is on by default, and you can ask for a compaction at any time. In the terminal, the action is named "Compact the session". Its keys are the leader key, which is Ctrl+X by default, and then C.18
The system prompt stays in front of the summary. The project's AGENTS.md is part of the instructions that OpenCode assembles when a session starts.19 The compaction page says what happens to it: "After compaction, the current versions of your instruction files become the session's baseline".17 An AGENTS.md in a subfolder is different. It enters the history when the agent first reads in that folder. If a compaction removes it, "a later read can load the file again".19 So it comes back only on demand, like a CLAUDE.md in a subfolder in Claude Code. A subagent in OpenCode runs "with fresh context" in a session of its own.20
Which differences change a decision?
Where the rule comes back from, and who starts the summary.
| Claude Messages API, your own loop | Claude Code and the Agent SDK | OpenAI Agents SDK | Codex and OpenCode | |
|---|---|---|---|---|
| Where a rule must live to come back | The system prompt, which your code sends on every request | The project-root CLAUDE.md, re-injected from disk | The agent's instructions, its system prompt. Not yet tested | The project's AGENTS.md. Documented for OpenCode. Not stated for Codex, so Task 6 tests it |
| A rule said only in the conversation | Summarized. On a summary on demand, a mid-run system message stops applying | Summarized, and may be gone | In the history, which is cleared and rewritten. You cannot read the compaction item | Summarized. OpenCode also keeps about the last 15,000 tokens as they were |
| Who starts a summary | The API at your trigger, or your code on demand | The harness on its own, or you with /compact | The session after a turn, or your code | The harness on its own, or you: /compact in Codex, "Compact the session" in OpenCode |
| How you see that one happened | A summary block in the response, with its cost under usage.iterations | A compact_boundary message in the SDK | No event is named. The cost is added to the run's usage totals | Codex has the hook events PreCompact and PostCompact.15 OpenCode sends session.compaction.* events.17 |
| The state of the work (this book's design, on every product) | A file your memory handler wrote, read again after the summary | A file in the project | A file your code keeps | A file in the project |
Two rows should change a decision. The first row decides where you write a rule before a long run starts. The third decides whether a summary can arrive when you did not ask for one. In Managed Agents it always can.
What must stay true on any harness?
A rule lives where the harness sends it again on every request, the state of the work lives in a file, and a check by code after the run says whether the rule held.
The first part, in one line: rules in an instruction file survive compaction on every harness. On November 30, 2026 that line is documented for Claude Code, the Agent SDK and OpenCode, and only for the file at the project's root. For Codex it is a claim, and Task 6 is where you test it.
That is why the third part matters most. A product's page can tell you what should come back after a summary. Only the check by code tells you what did. The same check runs unchanged on any harness, because it reads the answer and the tool results, and never the product's settings.
The operating rule: on any harness, put the rule in the file the harness sends every time, and keep the state of the work in a file. Trust the check by code over the product's page.
Do this now. Open a session in your coding agent, in any project. Then do three steps.
-
Send this message.
End every answer in this session with the line "Checked against the rules file." Then tell me what this project is, in two sentences.
-
Compact the session with your tool's own command (12.8). Then send this message.
Tell me what the largest file in this project is.
-
Look at the last line of the answer. Then write the rule into your project's instruction file, and start a fresh session. Send only the second sentence of step 1's message, compact, and send step 2's message again.
Write down, for your tool and today's date, whether the rule held each time. That note is one row of the table above, tested by you.
Check yourself
Question 1 / 8
0 answered
A long Claude Code session compacts. What happens to the CLAUDE.md at the project's root?
Sources
- Compaction at a token threshold, Anthropic.↑↑2↑3
- Memory tool, Anthropic.↑↑2
- Context editing, Anthropic.↑↑2
- Compaction on demand, Anthropic.↑
- Context engineering: memory, compaction, and tool clearing, Anthropic cookbook.↑
- Explore the context window, Anthropic.↑
- How Claude remembers your project, Claude Code docs, Anthropic.↑
- How the agent loop works, Agent SDK, Anthropic.↑
- Managed Agents reference, event types, Anthropic.↑
- Compaction, the Responses API, OpenAI.↑↑2
- Conversation state, the Responses API, OpenAI.↑
- Sessions, OpenAI Agents SDK, OpenAI.↑↑2
- Agents, OpenAI Agents SDK, OpenAI.↑
- Slash commands in Codex, OpenAI.↑
- Configuration reference for Codex, OpenAI.↑↑2
- Custom instructions with AGENTS.md, OpenAI.↑
- Compaction, OpenCode docs.↑↑2↑3
- Keybinds, OpenCode docs.↑
- Instructions, OpenCode docs.↑↑2
- Agents, OpenCode docs.↑
- Owner
- Panaversity