AI More detail B · Official guidance Platform: AI

Context Compaction

Context compaction replaces older conversation state with a smaller item so a long task can continue. The item may not be a readable summary, and details may be lost.

See how it works
You might call it context compressionconversation compactionhistory compaction

See how it works

Original worked exampleContext Compaction
LONG TASK · SMALLER WORKING CONTEXTContext Compactionhistory → compact item → continuity check
DATAlong coding session · 178ktrigger before the model limitA coding agent nears its context limit. The system compacts earlier turns but keeps goals, decisions, changed files, and open errors available.
CONTROL
1Preserve state→goal · files · errors
2Compact old turns→opaque item C7
3Continue✓C7 + new input
BOUNDARYUse it when needed context is near the model limit. Check that the next turn can still finish the task.FAILUREDo not treat the compact item as the full record. Keep permissions, exact values, unfinished work, and source evidence elsewhere.
history → preserved state + compact item → continuity checkOPS
Context CompactionAI operations

Another example

A coding agent nears its context limit. The system compacts earlier turns but keeps goals, decisions, changed files, and open errors available.

Main parts

  1. 01Compaction trigger
  2. 02Source history
  3. 03State to preserve
  4. 04Compact item
  5. 05Continuation input
  6. 06Continuity check

Use it when

Use it when needed context is near the model limit. Check that the next turn can still finish the task.

Do not use it when

Do not treat the compact item as the full record. Keep permissions, exact values, unfinished work, and source evidence elsewhere.

Name used in code

history → preserved state + compact item → continuity check

Before you ship

Check the model and prompt versions, source data, versioned evaluation set, and measures. Verify links to evidence, tool permissions, privacy, common failures, decline-to-answer and fallback behavior, human review, monitoring, cost, speed, and rollback.

Request you can copy

Outcome: Use or evaluate Context Compaction to make AI behavior measurable and tied to evidence. User context: A coding agent nears its context limit. The system compacts earlier turns but keeps goals, decisions, changed files, and open errors available. AI method or concept: Context Compaction. Why it fits: Use it when needed context is near the model limit. Check that the next turn can still finish the task. Do not use it when: Do not treat the compact item as the full record. Keep permissions, exact values, unfinished work, and source evidence elsewhere. AI requirements: Define the input and source evidence. Set model and tool permissions. Use versioned evaluation data and measures. Define failure, decline-to-answer, privacy, speed, and cost limits. Operational safeguards: Keep a clear trace and hide sensitive log data. Show users a safe fallback. Mark steps that need human review. Define how to roll back the model or prompt. Acceptance criteria: Record baseline and target measures on a versioned evaluation set. Test edge cases and hostile inputs. Verify fallback, monitoring, permissions, and rollback. Evidence and limits (evidence boundary): It is official for that source. Other platforms or teams may use the term in another way. Unknowns to confirm: Target task, model and version, evaluation owner, source data, risk limit, tool permissions, and production fallback.

Check this request

Review the current use of Context Compaction. Definition: Context compaction replaces older conversation state with a smaller item so a long task can continue. The item may not be a readable summary, and details may be lost. Release checks: Check the model and prompt versions, source data, versioned evaluation set, and measures. Verify links to evidence, tool permissions, privacy, common failures, decline-to-answer and fallback behavior, human review, monitoring, cost, speed, and rollback. Before changing code, report the evidence you found, gaps, severity, and the smallest safe fix.

B
How official is this term?

Official guidance

The named platform, framework, project, or expert group has an official guide for this term.

It is official for that source. Other platforms or teams may use the term in another way.

Scope
Provider-specific long-context compaction documented by OpenAI and Anthropic
Document status
stable
Checked on
2026-07-30

Evidence sources & scope

Authority source + Term reference · OpenAI · stable Compaction Scope: OpenAI Responses API server-side and standalone context compaction Role here: Direct term reference Source covers: canonical name, definition, platform API, implementation, usage guidance Authority source + Term reference · Anthropic · experimental Compaction Scope: Beta Claude API server-side context compaction Role here: Direct term reference Source covers: canonical name, definition, platform API, implementation, usage guidance

Copy it yourself

The browser could not copy this. Select the request below and copy it yourself.