Skip to content

Course · Codex · Sessions & context

Start unrelated Codex work with a fresh session or /new

Yesterday’s work is committed and the next task is unrelated. If you keep typing into the same session, the window still carries file reads, test output, and reasoning from the finished tasks. The model may steer the new work through old context. Reset means a fresh conversation context, not undoing git history.

A session is the saved Codex conversation (codex resume can bring an old one back). Resetting starts or clears the chat side while your repo stays as-is. Resuming restores transcript, not disk; resetting clears transcript weight, not your commits. That distinction is spelled out in resume.

The CLI reference documents in-session resets: /new starts a new chat inside the same CLI session; /clear does the same while also clearing the terminal view. The conversation you left behind is not destroyed - it remains a saved session, reopenable with codex resume like any other, which is the difference between resetting your current context (what /new changes) and the saved history (codex resume’s territory). Slash-command availability varies by surface; treat the current reference as authority for your build.

From the shell:

codex # launch a new interactive session in the current project
codex fork # branch a saved session (picker; --last skips it where supported)

Use a fresh codex session or /new when the next task should inherit no prior thread. Use /fork or codex fork when you want shared history for a second approach (paid twice); that is comparison, not a clean slate. Use /compact when the task continues but the window is crowded.

An illustrative fresh start on budgetcli (the course’s small FastAPI teaching app; the local authoring fixture is not published with the site, so use a course-host copy or adapt the command to your own pytest project with an AGENTS.md at its root):

$ codex
> add a GET /transactions?category= filter to app/main.py that returns
only transactions in that category, using ledger.by_category
[reads app/main.py, app/services/ledger.py ...] (illustrative)

The agent can go straight to routes and ledger code without dragging parse-path exploration. Reset wiped what the agent remembered in chat. Files you committed yesterday are unchanged.

Situation Move
Continue tomorrow’s thread codex resume / /resume
Compare two designs from the same base /fork
Disposable side question (an ephemeral side chat; its lesson covers it) /side
Same task, window too full /compact
Unsure how full /status first
Done; unrelated next task Fresh codex or /new

When in doubt, /status then decide.

A reset is not an undo. Decisions, TODOs, and findings that lived only in the thread need a durable home before you reset: commit, note, or AGENTS.md. Reset when you want the chat context gone, after what mattered is on disk.

None of the session commands decide what was worth keeping; that judgment stays yours.

Session moves manage what the agent remembers (context). They do not set what it may do without asking or how far it can reach (control). When work touches money paths, network calls, or destructive commands, approval policy and sandbox matter separately. That pairing is the subject of Approvals and sandbox.