中文

Runtime Context, Compaction, Replay

Understand how Codex keeps a long conversation coherent.

A source-pinned technical book about context as runtime state: turn envelopes, history normalization, typed injections, optional-context budgets, compaction, rollout reconstruction, rollback, fork, realtime surfaces, and token telemetry.

Codex context management as a pipeline from ledger, turn envelope, and fragments to projection, clients, compaction, and replay
Codex keeps context coherent by separating the durable ledger, turn envelope, typed fragments, model projection, client views, compaction, and replay.
01

Boundary

Start with context as runtime state and the turn envelope that freezes one unit of work.

02

Projection

Then read history normalization, typed fragments, and optional-context budgets as prompt-shaping owners.

03

Survival

Study compaction, replacement history, rollout reconstruction, rollback, and fork as recovery mechanics.

04

Exposure

Finish with TUI, realtime, app-server, token usage, and trace as downstream views.

Runtime-first

Context is treated as governed runtime state, not as a growing prompt string.

Checkpointed

Compaction installs replacement history with enough evidence to resume and audit later.

Source-pinned

All source links point to 569ff6a1c400bd514ff79f5f1050a684dc3afde3, so the book can be audited against a fixed tree.

Table of contents

Part 4

Expose Context Without Losing Control

Clients may render context, but the runtime must remain the source of truth.

Reference