# 26.8 How today's tools realize it (/building-ai-workers/context-engineering/how-todays-tools-realize-it)

---
type: Document
title: "26.8 How today's tools realize it"
description: "What comes back after a summary in Claude, OpenAI and open-source runtimes, which differences change a decision, and what holds on any harness."
status: stable
order: 326.08
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T08:16:23Z
chapter: '26'
part: III
expert_status: manager
concepts: [ "26.8" ]
last_verified: '2026-11-30'

sources:
  - id: anthropic-compaction-threshold
    title: Compaction at a token threshold (verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/compaction-threshold
  - id: anthropic-compaction-on-demand
    title: Compaction on demand (verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand
  - id: anthropic-context-editing
    title: Context editing (verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/context-editing
  - id: anthropic-cookbook-context
    title: 'Context engineering: memory, compaction, and tool clearing (Anthropic cookbook, verified 2026-11-29)'
    resource: https://platform.claude.com/cookbook/tool-use-context-engineering-context-engineering-tools
  - id: anthropic-sdk-agent-loop
    title: How the agent loop works, Agent SDK (Anthropic, verified 2026-11-29)
    resource: https://code.claude.com/docs/en/agent-sdk/agent-loop
  - id: anthropic-cc-context-window
    title: Explore the context window (Anthropic, verified 2026-11-29)
    resource: https://code.claude.com/docs/en/context-window
  - id: anthropic-memory-tool
    title: Memory tool (Anthropic, verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool
  - id: claude-code-memory
    title: How Claude remembers your project (Claude Code docs, verified 2026-11-29)
    resource: https://code.claude.com/docs/en/memory
  - id: anthropic-managed-agents-reference
    title: Managed Agents reference, event types (Anthropic, verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/managed-agents/reference
  - id: openai-compaction
    title: Compaction, the Responses API (OpenAI, verified 2026-11-30)
    resource: https://developers.openai.com/api/docs/guides/compaction
  - id: openai-conversation-state
    title: Conversation state, the Responses API (OpenAI, verified 2026-11-30)
    resource: https://developers.openai.com/api/docs/guides/conversation-state
  - id: openai-agents-sdk-sessions
    title: Sessions, OpenAI Agents SDK (OpenAI, verified 2026-11-30)
    resource: https://openai.github.io/openai-agents-python/sessions/
  - id: openai-agents-sdk-agents
    title: Agents, OpenAI Agents SDK (OpenAI, verified 2026-11-30)
    resource: https://openai.github.io/openai-agents-python/agents/
  - id: codex-slash-commands
    title: Slash commands in Codex (OpenAI, verified 2026-11-30)
    resource: https://learn.chatgpt.com/docs/developer-commands?surface=cli
  - id: codex-agents-md
    title: Custom instructions with AGENTS.md (OpenAI, verified 2026-11-30)
    resource: https://learn.chatgpt.com/docs/agent-configuration/agents-md
  - id: codex-config-reference
    title: Configuration reference for Codex (OpenAI, verified 2026-11-30)
    resource: https://learn.chatgpt.com/docs/config-file/config-reference
  - id: opencode-compaction
    title: Compaction (OpenCode docs, verified 2026-11-30)
    resource: https://opencode.ai/docs/compaction/
  - id: opencode-instructions
    title: Instructions (OpenCode docs, verified 2026-11-30)
    resource: https://opencode.ai/docs/instructions/
  - id: opencode-agents
    title: Agents (OpenCode docs, verified 2026-11-30)
    resource: https://opencode.ai/docs/agents/
  - id: opencode-keybinds
    title: Keybinds (OpenCode docs, verified 2026-11-30)
    resource: https://opencode.ai/docs/cli/keybinds/
generated:
  at: 2026-11-30T08:16:23Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

**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](../agent-loop-by-hand/the-conversation-is-an-array-you-own.md)). A summary replaces the older turns of the conversation, and the API drops everything before the summary block.[^anthropic-compaction-threshold] 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](compaction.md)). And a file written through the memory tool is safe on your disk, but outside the window until something reads it again.[^anthropic-memory-tool]

<!-- EDITOR: may 26.8 repeat the losses that 26.4 teaches? This draft says them once, in 26.4, and 26.8 points there in one sentence, so quiz item 26.8-03 now asks about the progress file after a summary. The other option: 26.8 keeps the four losses in full with their quotes, as Chapter 25 kept such a pair on purpose in 25.11, and the old 26.8-03 on the mid-run system message comes back. -->

> [!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.[^anthropic-compaction-threshold] 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.[^anthropic-context-editing] Compaction on demand has the header `compact-2026-09-04`, and a request cannot ask for it and carry context editing too.[^anthropic-compaction-on-demand] The setting `exclude_tools` names tools whose results a clearing leaves alone, such as the memory tool's, and by default it names none.[^anthropic-context-editing][^anthropic-cookbook-context] The memory tool is not in beta.[^anthropic-memory-tool] 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."[^anthropic-cc-context-window] 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.[^claude-code-memory] 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`.[^anthropic-sdk-agent-loop] What a subagent there receives is in [26.5](isolation-with-subagents.md).

**Anthropic: Claude Managed Agents.** Compaction is "Always on", and the threshold page says each one emits an event named `agent.thread_context_compacted`.[^anthropic-compaction-threshold] The platform's reference page lists that event with these words: "Conversation history was compacted to fit the context window."[^anthropic-managed-agents-reference] 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*.

<!-- OPEN: Managed Agents' clearing, trigger and what comes back. Read on November 30, 2026: the reference page (it has the event `agent.thread_context_compacted`, so the event name is settled), agent setup, events and streaming, session threads, sessions, session operations, session observability, webhooks, tools, memory and multiagent orchestration. None has a line on tool-result clearing, on a compaction trigger of the builder's choosing, or on what is put back after a summary. The agent setup page says only that the system prompt is part of the agent and "is distinct from user messages". -->

**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.[^openai-compaction] 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."[^openai-compaction] 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".[^openai-conversation-state] 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".[^openai-agents-sdk-sessions] So the stored history is the part a summary replaces. The SDK calls an agent's `instructions` its "System prompt".[^openai-agents-sdk-agents] 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.[^openai-agents-sdk-sessions]

<!-- OPEN: a marker of compaction in the Agents SDK. Read on November 30, 2026: the SDK's sessions page, its agents page and the reference page for `OpenAIResponsesCompactionSession`. They state the usage totals and the rewritten history, and name no event, message or log line that tells the builder a compaction ran. -->

**OpenAI: Codex.** `/status` shows the session's settings and its token usage. `/compact` replaces "earlier turns with a concise summary".[^codex-slash-commands] Codex also compacts on its own at a token limit, which a setting can change.[^codex-config-reference] Codex reads `AGENTS.md` "before doing any work". It builds its chain of instruction files once, when a session starts.[^codex-agents-md] 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: AGENTS.md after a compaction in Codex. Read on November 30, 2026: Codex's AGENTS.md guide, its slash commands page, and its configuration reference and advanced configuration pages (by the word "compact"). The guide says the instruction chain is built "once per run" and joined into "the combined prompt". No page says whether that chain is sent again, or read again from disk, after `/compact` or an automatic compaction. Lab 26, Task 6 is the test. -->

**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".[^opencode-compaction] 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.[^opencode-keybinds]

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.[^opencode-instructions] The compaction page says what happens to it: "After compaction, the current versions of your instruction files become the session's baseline".[^opencode-compaction] 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".[^opencode-instructions] 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.[^opencode-agents]

<!-- OPEN: OpenCode's `/compact`. 12.8 (30 October 2026) says "`/compact` does it when you ask". Read on November 30, 2026: OpenCode's compaction, TUI, keybinds, commands and CLI commands pages, all for OpenCode V2. None names a `/compact` slash command. They give the "Compact the session" action (`session.compact`, leader then C), the command palette (Ctrl+P), and the request `opencode api post /api/session/<id>/compact`. This page now names the action, and 12.8 needs the same check. -->

### 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`.[^codex-config-reference] OpenCode sends `session.compaction.*` events.[^opencode-compaction] |
| 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 |

<!-- OPEN: one cell still waits, "Not stated for Codex" in the first row. The vendors' pages were read on November 30, 2026, and the other four "Not read" cells are now filled from them. The Codex pages read are listed in the OPEN comment under the Codex paragraph. The last row is this book's design on every product, not a product fact. -->

<!-- EDITOR: may a published page say "Not stated"? The OpenAI and OpenCode pages were read on November 30, 2026, so the label "Not read" is gone, and quiz item 26.8-05's stem now says "Codex's pages do not say". One gap is left, for Codex. This draft labels it "Not stated", and Lab 26, Task 6 tests it. The other option: the page waits for a recorded run of Task 6, and states the result with its date. -->

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.

<!-- OPEN: an exam note for this section, as 25.11 has one, waits for the register entry. Notes are generated from the register, never written by hand. -->

**Do this now.** Open a session in your coding agent, in any project. Then do three steps.

1. 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.

2. Compact the session with your tool's own command ([12.8](../agentic-coding/both-ai-vendors.md#practice-context-and-sessions)). Then send this message.

   > Tell me what the largest file in this project is.

3. 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.

[^anthropic-compaction-threshold]: Compaction at a token threshold, Anthropic.
[^anthropic-memory-tool]: Memory tool, Anthropic.
[^anthropic-context-editing]: Context editing, Anthropic.
[^anthropic-compaction-on-demand]: Compaction on demand, Anthropic.
[^anthropic-cookbook-context]: Context engineering: memory, compaction, and tool clearing, Anthropic cookbook.
[^anthropic-cc-context-window]: Explore the context window, Anthropic.
[^claude-code-memory]: How Claude remembers your project, Claude Code docs, Anthropic.
[^anthropic-sdk-agent-loop]: How the agent loop works, Agent SDK, Anthropic.
[^anthropic-managed-agents-reference]: Managed Agents reference, event types, Anthropic.
[^openai-compaction]: Compaction, the Responses API, OpenAI.
[^openai-conversation-state]: Conversation state, the Responses API, OpenAI.
[^openai-agents-sdk-sessions]: Sessions, OpenAI Agents SDK, OpenAI.
[^openai-agents-sdk-agents]: Agents, OpenAI Agents SDK, OpenAI.
[^codex-slash-commands]: Slash commands in Codex, OpenAI.
[^codex-agents-md]: Custom instructions with AGENTS.md, OpenAI.
[^codex-config-reference]: Configuration reference for Codex, OpenAI.
[^opencode-compaction]: Compaction, OpenCode docs.
[^opencode-instructions]: Instructions, OpenCode docs.
[^opencode-agents]: Agents, OpenCode docs.
[^opencode-keybinds]: Keybinds, OpenCode docs.
