Sessions, history and context.
Resume or fork a conversation, inspect context pressure, compact long sessions, export useful records, and distinguish a fresh session from file recovery.
Code saves conversations as local session event logs. A session records what was said and which tool events occurred; it is not a snapshot of the whole computer. This guide covers CLI 0.9.0.
Find and resume a session
Inside Code:
/sessions
/resume
The session picker normally focuses on the current folder. /sessions all
lists across folders. You can also use /resume <number-or-id> with a current
listing number or an unambiguous session reference. From your terminal:
kaitoi code --resume <session-id>
kaitoi code --continue-session
The second form selects the most recently saved top-level session across folders. Read the recap and
check /status and /workspace before continuing. Resuming history does not
restore its old session approvals or put workspace files back to their former
contents. In-session /resume does not switch your model or workspace; a
different saved workspace produces a notice. Existing ordinary background processes in the current invocation
are not stopped by switching conversations.
Fork when you want a separate direction
/fork copies the current saved history into a new session and continues there.
The original log remains available. It is a conversation branch, not a Git
branch, a duplicate directory, or an isolated worktree. Both conversations can
still refer to the same files.
Session A contains messages 1, 2, and 3. Forking creates session B with a copy of that history, then new messages can diverge. Compacting creates a continuation containing a summary rather than replaying all earlier conversation; the earlier log remains. Both paths can use the same workspace, so neither isolates files.
Usage copied into a fork remains visible in its history. /cost identifies
inherited usage; copied records are not a second charge for the original work.
Inspect and compact context
/context
/compact Keep the accepted API contract and remaining failing checks.
/context describes how much of the current model context is occupied.
/compact [focus] asks a model to summarize the conversation and starts a
continuation session. Automatic compaction can do the same before a turn when
context reaches its configured threshold. Configuration belongs under
compaction in user agent.json. Its defaults are:
{
"compaction": {
"auto": true,
"thresholdPercent": 80,
"model": null
}
}
The threshold accepts 50–95. A null model uses the current session model;
an explicit provider/model selects another summary model. Merge settings
into the existing file and restart Code after editing.
The old log stays intact. A summary is lossy: check that decisions, constraints,
and remaining work survived, and keep durable project instructions in files.
Compaction can use paid model inference. Even if writing the continuation later
fails, the summary call may already have run. On failure, read the message;
automatic retries are suppressed for that session in the current process,
while a manual /compact can be tried after resolving the problem.
Start fresh without deleting the earlier log
/clear immediately starts a new session ID and clears session approvals and
pending hook context. It also runs the configured SessionStart hooks for that
transition. Earlier saved logs remain available.
It does not undo files, stop ordinary background processes, or reset every
workspace/model preference. Use /processes for processes and
rewind for checkpoint-based recovery.
Export a useful record
/export md
/export json
/copy
/export [md|json] [path] saves a readable transcript or raw event trace;
/copy json copies the trace instead of the text transcript. Export creates a
new file and refuses to overwrite an existing one. Review the output
before sharing it: prompts, file excerpts, tool arguments, and results can
contain project information. Exporting a conversation does not package the
workspace or its dependencies.
Last reviewed against Kaitoi on 24 October 2026. View this page as Markdown