Control

Context Management

Context management keeps the current task, relevant evidence, and unresolved decisions available to the model. Finished investigations and abandoned approaches should not occupy the conversation indefinitely.

Choose What Needs To Survive

The useful result of debugging the pipeline editor may be a corrected function and a passing regression check. The sequence of failed guesses is usually less useful. Preserve the requirement and changed files before trimming the discussion. Keep the tested revision and remaining work too.

  • Rewind suits a recent branch of discussion that went wrong. Check whether the selected mode restores the conversation, the files, or both.
  • Compact suits a discussion that remains relevant but has grown too long. Check whether the summary kept the exact constraints and open questions.
  • Clear suits the start of a new task or a prepared handoff. Check whether you saved important state outside the conversation first.

Order The Tools By What They Discard

Context engineering offers moves that range from mild to drastic. A subagent prevents clutter before it arrives by doing heavy reading in its own context. A rewind cuts one branch of the conversation. Compaction compresses the whole conversation into a summary. A handoff keeps a hand-picked selection, and a clear removes everything.

Reach for the mildest move that solves the problem. A long but healthy session may need only a rewind of its last tangent. A session that keeps repeating a mistaken idea needs that idea removed, which often means a fresh start. Picture the conversation as a trunk with branches. Keep the trunk dense and trim each branch once it has served its purpose.

Trim A Branch After It Pays Off

Exploration costs tokens. Suppose a session sends several subagents to compare approaches and their results fill the context. Ask the agent for a clean summary of the outcome. Rewind to the point before the exploration began and paste the summary back in, wrapped in a tag such as <findings>. The session keeps the answer without the cost of the search.

The same move works after debugging. Once the fix passes its check, rewind the conversation but keep the files. The fix stays on disk while the failed guesses leave the context, along with the noise that feeds context degradation. Tell the next prompt that the fix is already in place.

Conversation State And File State

Claude Code's checkpoint controls can restore conversation and supported file changes separately. A conversation-only rewind keeps the working files. The next prompt should explain their current state. Checkpointing does not undo every shell command, database update, or external action.

Codex offers fresh-chat and compaction commands; the available history controls depend on the interface and version. Git remains the durable record of code changes in either tool. Check the diff before assuming a conversation operation restored code.

Compact On Your Schedule

Compaction loses detail by design. The summary decides what survives, and you cannot see what it dropped without checking. Automatic compaction runs when the application decides the context is full, which can land in the middle of delicate work. Some practitioners turn it off and compact by hand at a clean breakpoint.

A manual compaction can take instructions. Name the constraints and file paths it must keep word for word. Read the summary afterward and restore anything it lost before continuing.

Write A Selective Handoff

A selective handoff records only what the next session needs:

  • The objective: preserving saved pipeline step order.
  • The workspace and revision with their actual values.
  • The changed files: the storage and editor changes.
  • The evidence: the command and its result, plus the tested revision.
  • The open issue: undecided duplicate-name behavior.
  • The next action: resolving that decision before changing validation.

A fresh session should inspect the referenced files before continuing. A handoff is a starting point and may already be stale if another process changed the workspace.

Exercise 8: Trim A Session After The Fix

Fix a real bug in a working project and let the session grow as the debugging goes on. Once the fix passes its check, note the token count. Rewind the conversation to the point before debugging began while keeping the files on disk, tell the agent the fix is already in place, and note the token count again.

Next, write a handoff containing the objective, the revision, the changed files, the check that passed, and the next action. Clear the session, paste the handoff inside a tag such as <handoff> and ask the agent to state the next action and confirm the fix. Anything the agent has to ask for goes back into the handoff.

September, 2026

Search the website