LatentCodeUsing LatentCode
Sessions and context
Every conversation is a session, saved on your machine. Resume, branch, undo, and keep long sessions within the model's context window.
Start, resume and switch
| To | In the TUI | From the shell |
|---|---|---|
| Start a new session | /new (or /clear), ctrl+x n | latentcode |
| Continue the last one | latentcode -c | |
| Open a specific one | /sessions (or /resume), ctrl+x l | latentcode -s <id> |
| List them | /sessions | latentcode session list |
In the session list:
- ctrl+r renames the selected session (or use
/renamein a session). - ctrl+d deletes it; press it again to confirm.
- ctrl+f pins it to the top. Pinned sessions get quick slots: ctrl+x 1 to ctrl+x 9 jump straight to them.
New sessions are titled automatically from your first message.
Fork a session
/fork asks which message to branch from, then copies the conversation up to that point into a new session titled … (fork #1). The original is left as it was. Use it to try a different approach without losing the first one. From the shell, --fork with -c or -s continues in a copy.
latentcode -s ses_abc123 --forkA fork also copies the session's goal and loop, if it has them.
Undo and redo
/undo (ctrl+x u) removes your last message and everything after it, restores the files the agent changed since then, and puts your message back in the prompt so you can reword it. Run it again to go further back. /redo (ctrl+x r) reverses it. If the agent is working, undo stops it first.
Undo works in git repositories and never commits to your repository. Untracked files over 2 MB aren't restored. Turn it off with "snapshot": false.
Context and compaction
Each model has a context window: the most text it can consider at once. The line under the prompt shows how much of it the session uses, and the sidebar shows how much is left before compaction.
Automatic
Old tool output and older turns are condensed automatically, so long sessions keep going.
Nothing is deleted: the full history stays in the session, and you can still scroll through it.
Manual
Run /compact (or /summarize, ctrl+x c) to compact now, for example before switching to a new part of a task.
Settings
{
"compaction": {
"auto": true, // summarize automatically
"prune": true, // drop old tool output
"tail_turns": 2 // recent turns kept word for word
}
}LATENTCODE_DISABLE_AUTOCOMPACT turns automatic compaction off for one process. Automatic compaction needs the model's context window, which your gateway reports. If the sidebar shows no context limit for a model, ask your administrator to set its context window.
Work in more than one directory
A session works in the directory you started it in. Anything outside it asks for permission. To let the session use another directory freely, add it:
/add-dir ../shared-libThis applies to the current session only and isn't written to config. /add-dir status lists the extra directories. To start in another directory, pass it as an argument: latentcode ../other-repo.
Bring in another session
Type @sync: in the prompt and pick a session. A summary of that session's history is added to your message, so you can continue work started elsewhere without copying it.
/push-to-registry summarizes the current session and shares it with your organization. Teammates can then pick it from their own @sync: list.
Save and share a transcript
| Command | Result |
|---|---|
| /export | Asks which details to include (thinking, tool details, model info), then writes a Markdown file named session-<id>.md in the current directory and opens it in $EDITOR. Also ctrl+x x. |
| /copy | Copies the transcript to the clipboard. |
| latentcode export <id> | Prints the session and every message as JSON. Add --sanitize to redact the content. |
Usage and cost
/stats shows what the current session has cost, including its subagents: cost, number of calls, input, output and cached tokens, and the models used. The figures come from your gateway. For all sessions, run:
latentcode stats --days 7 --modelsSee also My Usage in the console.
Where sessions are stored
Sessions live in a local database (latentcode db path prints where). Deleting a session with ctrl+d or latentcode session delete removes it for good.