Skip to content

Course · Codex · Sessions & context

Sessions & context

A session is a saved conversation you can reopen with codex resume. While it runs, Codex carries one context window: everything in the transcript, file bodies it has read, tool output, standing instructions, and tool definitions. The window has a fixed capacity (often discussed as on the order of 200k tokens in current models). Nothing in it empties by itself on ordinary turns - read a file and the window only grows. (Near the capacity limit Codex may compact automatically; the compact lesson covers that escape valve and why you should usually compact on purpose instead.) Talk for an hour and the spare room shrinks. Resume yesterday and yesterday’s transcript rides into today.

That is the local problem this chapter addresses. Context (what the agent can see when it decides) is paid per session, not per repo. A small codebase can still fill a window if the conversation is long, forked, or full of repeated reads. Each command here trades window space against continuity on purpose: reopen understanding, split threads, shed weight in place, read the gauge, or start clean.

You need to… Lesson
Pick up a saved conversation across days Resume (codex resume, /resume, --last, scoped picker)
Compare two designs without blending them in one thread Fork (/fork, codex fork)
Answer a disposable question without polluting the main transcript Side (/side)
Keep the same task but reclaim window room Compact (/compact)
See how full the window is before you spend more Status (/status)
Move to unrelated work without dragging old context Reset (fresh codex, /new, /clear)

One distinction runs through several lessons: resuming restores the conversation, not the working tree. Files on disk are whatever git status and your tests say now; the transcript is a record of what was said when. Put durable facts in commits, notes, or AGENTS.md so they load in every session regardless of which thread you open.

Where a concrete tree helps, lessons use budgetcli: a small self-hosted personal-finance API, 166 lines of Python and about 230 lines including tests, config, rules, and README, with a pytest suite and an AGENTS.md at the repo root. Each page restates the files and facts it needs; you do not need prior chapters to follow a single lesson.

Start anywhere that matches your question, or walk forward from resume if you want the usual reading order.