Chat and resume
View as MarkdownThe chat
At a terminal, the chat runs in the terminal UI that dexcli draws. With --plain, or when the terminal UI is not available, the chat is plain text lines. Both chat with the same session.
Exiting never ends the session. The session stays in Dex, and the command prints the --resume line that continues it.
The terminal UI
Since 0.6.0. The terminal UI fills the terminal window. Messages, replies,
and tool calls scroll above an input box. The bottom line shows the keys that
work at the moment. The line above it shows the command, the model, the
reasoning effort when the session sets one, and the workspace. Since 0.6.20
with dexcli 1.48.3, when the session offers approval modes, the bottom
line also shows the current mode, such as Accept edits; any mode but
Ask every time stands out, and Auto-approve all most. The reply streams as it arrives, and Markdown, such as a
table, is drawn as formatted text. Since 0.6.19, it opens encrypted sessions
with dexcli 1.48.2 or later; see
Payload encryption.
| Key | Action |
|---|---|
| Enter | Send the message. While a turn runs, queue it for the next turn. |
| Shift-Enter, Alt-Enter, Ctrl-J | Start a new line. |
| Ctrl-C | Cancel the running turn, or clear the input. Press it again to exit. |
| Esc | Cancel the running turn when the input is empty. |
| Ctrl-D | Exit when the input is empty. |
| Backspace | With an empty input, remove the last attached image. |
| Tab | Complete a slash command or an /image path. With an empty input, go to the waiting approvals and queued messages. |
| Shift-Tab | Since 0.6.20 with dexcli 1.48.3. Switch to the next approval mode: Ask every time, then each mode the session offers, then Ask every time again. Only when the session offers modes. If the session refuses, a line says so and the mode stays. |
| Up, Down | With an empty input, scroll the messages one line. In a typed message, move between its lines. After Ctrl-P, keep recalling. |
| Ctrl-P, Ctrl-N | Recall earlier messages, or go back toward the newest. |
| Ctrl-O | Open the last tool call's full output. |
| Ctrl-T | Show the plan's steps. |
| PgUp, PgDn | Scroll the messages by a page. End follows new ones again. |
| F1 | Show the keys and the commands. |
A mouse drag selects text for the terminal's copy key. Terminals that turn the mouse wheel into Up and Down keys scroll the messages with it. A Dex Web address is a link; terminals with hyperlink support open it on a click.
A tool call that waits for approval opens a panel with the tool, its arguments, and for a file write, the change. Press y to approve, n to reject, or r to reject with a reason. Since 0.6.20 with dexcli 1.48.3, when the session offers approval modes, a approves and stops asking for this exact command, or for this tool when it has no command, for the rest of the session. If the session refuses the rule, a line says so and the panel stays open for y or n. Esc closes the panel; the call keeps waiting. A call that a mode or a rule approved shows auto-approved (Accept edits) or auto-approved (rule: git status) on its line. A question from the agent opens a panel too: choose an answer, or type one.
A message sent during a turn waits in the queue. /steer sends the last queued message into the running turn instead, and /drop deletes it.
| Command | Action |
|---|---|
| /help | List the keys and the commands. |
| /exit | Exit. |
| /approve | Open the waiting approvals and questions. |
| /approvals [MODE] | Since 0.6.20 with dexcli 1.48.3, only when the session offers approval modes. Alone, list the modes with the current one marked, and the session's rules. /approvals MODE switches the mode, such as /approvals ask. /approvals remove ID removes a rule, such as rule-1. |
| /steer, /drop | Steer the last queued message into the turn, or delete it. |
| /image PATH | Attach an image to the next message. See Images. |
| /model [ID] | Pick the model from a list, or change it to ID, from the next turn. Since 0.6.2 with dexcli 1.47.0, the list has the command's suggested models; before, only its configured model. |
| /effort [LEVEL] | Since 0.6.2 with dexcli 1.47.0. Pick the reasoning effort from a list, or change it to LEVEL, from the next turn. default returns to the model's default. See Model and reasoning effort. |
| /new | Start a new session and switch to it. |
| /sessions | Switch to another session of this command. |
| /history | Read earlier messages of this session. |
| /tools | List the latest turn's tool calls and open one's output. |
| /copy | Copy the last reply to the clipboard. |
| /connectors | List the connector tools. |
| /web | Open this session in Dex Web. |
| /plan, /run | Plan mode, only in a harness that has it. See Workspace and local tools. |
The command uses the plain chat instead, without a message, when any of these holds:
- --plain is given;
- standard input or standard output is not a terminal;
- TERM is not set, or is dumb;
- the platform is Windows;
- the command is dex-agents-pi.
It also uses the plain chat, and prints one line that starts with Plain chat: and says why, when dexcli cannot be found or downloaded, when it has no terminal UI, such as dexcli before 1.46.0, or when the terminal UI fails to start. A failure after the session opened continues the same session in the plain chat.
NO_COLOR removes the colors and keeps the bold and dim styles. The terminal UI never gets the provider keys: the command passes it only the terminal and locale variables, and the one Dex credential variable that dex.auth needs. Since 0.6.2, it connects with the same dex.auth and dex.tls as the Worker; see Run against a remote Dex server.
The plain chat
Each line you type is a user message. The model's text streams as it arrives, and each tool call prints a line when it starts and when it ends.
- A call that waits for approval shows the tool and its arguments. Answer y, or n with an optional reason. Since 0.6.20, when the command offers approval modes, a approves and adds a rule for the rest of the session: for this exact command of a shell tool, otherwise for the tool.
- /approvals lists the modes, marks the current one, and lists the rules. /approvals MODE switches the mode, and /approvals remove RULE removes a rule. Since 0.6.20.
- A question from the agent asks for an answer. Answer with text or a choice number. In the Python commands, an empty line declines.
- /image PATH attaches an image to the next message. See Images.
- /fork and /fork N fork the session. See Fork a session.
- The first Ctrl-C during a turn cancels the turn, and a second Ctrl-C exits.
- /exit and Ctrl-D exit.
The plain chat has no plan commands. It sends /plan and /run as ordinary messages.
Resume a session
sessions lists the command's sessions, and --resume continues one. The command prints the --resume line when you exit. In the terminal UI, /sessions switches to another session and /new starts one; the line printed at exit names the session you were in last.
dex-agents-claude-sdk sessions
dex-agents-claude-sdk --resume SESSION_ID
sessions loads up to 250 sessions and sorts them by last activity. When more sessions exist, it says so. Each line has the session ID, the status, and the start time. Since 0.6.0 it also has the time of the latest turn, the turn count, and the title, the first 80 Unicode code points of the first message, when sessions.summary keeps the session summary: by default with dex.server: auto only. See List sessions. A session without the summary, such as one that an earlier release started, lists without these parts. An earlier session gains the time and the turn count at its next turn, and a title only if that turn is its first. Since 0.6.8 each line also says where the session was last open, as HOST:WORKSPACE. The Python commands leave out a missing part, and the TypeScript commands print tab-separated columns with a dash for it:
builtin-20261111-203123-3efeb4 running started 2026-11-11 20:31 updated 2026-11-11 20:40 4 turns on host-a:/home/a/work Find open issues about flaky tests
Sessions in other environments
Since 0.6.8. A session can continue in any environment that runs the same command. An environment is the host, the user, the configuration file, and the workspace. Each new session gets its own task queue, named after the session ID, and the harness's Flow type, such as DexAgentsClaudeSdkCliSession. Only the command that has the session open pulls the session's task queue, so the session's model calls and tool calls run there.
-
sessions lists every session of the harness's Flow type, from every environment, with the host and workspace where each was last open.
-
--resume SESSION_ID from another environment takes the session over. Its next tool calls run in this environment's workspace, with this environment's configuration file and permissions. The command prints one line that names both environments, each as user, host, workspace, and configuration file:
Session builtin-20261113-203123-3efeb4 was last open on alice@host-a:/home/alice/work (defaults); its model and tool calls now run here, on alice@host-b:/srv/work (defaults). -
Another environment is another host name, user, configuration file, or workspace. A takeover by the same user on the same host, with the same configuration file and workspace, prints no line.
-
When a turn was still running in the other environment, the command refuses that turn's model and tool calls, so a call approved there never runs in this workspace. It also cancels the turn before the chat starts. Once the turn has ended, it says so. When it cannot confirm that the turn ended, it says that instead and keeps refusing the turn's calls.
-
--resume of another command's session, such as a dex-agents-pi session in dex-agents-builtin, exits with code 2.
-
--resume of a session of the harness's Flow type that another client started without its own task queue, such as an application's Client that sets no task queue, exits with code 2 at once. No command pulls the task queue it runs on. Start sessions with the command instead.
-
A session that no command has open does not run. A message, an approval, or another session Action sent to it from Dex Web or another client waits for a command to open the session, for at most the server's RPC dispatch wait, 10 seconds by default. After that the call fails, and nothing is queued.
-
The command stores where it opened a session in the session, in the SessionLastTerminalEnvironment Attribute: the host name, the user, the configuration file, and the workspace. Each new session also records them in its start input, so its run in Dex Web shows where it started.
The task queues need server-zd 0.1.30 or later, which dexcli 1.47.5 or later runs. With an older server the command stops with one line that says so. Stop a dexcli dev that an earlier command started, then run the command again.
Sessions that releases before 0.6.8 started keep their old Flow type: the harness's Flow type with a six-character suffix, a hash of the host name, the user, the configuration file's real path, and the workspace's real path. They run on the default task queue.
- The command still serves the sessions of its own environment, so they resume as before, and sessions lists them with this environment.
- --resume of another environment's earlier session exits with code 2 and says to use the user, configuration file, and workspace that started it.
- Two commands in the same environment share these sessions' Steps. A tool Step may run in another process than the one that built the call. So the Worker that runs a tool Step checks the call again with its own configuration file, narrowed by the session settings of the call's turn. A call whose tool group, connection, or operation is off there, or that now needs an approval it did not get, records failed and does not run.
One terminal per session
Since 0.6.3. A session is open in at most one command at a time. A command that opens a session, with --resume, /sessions, or /new, takes the session's terminal lease first. A second command that opens the same session waits, and takes the session over as soon as the first one exits. There is no way to take a session from a command that still has it open.
Since 0.6.8, a waiting command reads the lease without pulling the session's task queue. When the lease is free or expired, it starts to pull the queue and takes the lease. When another command took the lease first, it stops pulling and waits again. When the chat ends, or the terminal UI switches sessions, the command releases the lease and stops pulling.
While it waits, the command shows one status line on standard error that updates in place: a spinner, who has the session open, how long it has waited, and how to quit.
⠹ Session builtin-20261113-203123-3efeb4 is open in another terminal (host-a, pid 4242, since 20:31) · waiting 0:12 · Ctrl-C to quit
- When it gets the session, the command clears the line and prints Took over session SESSION_ID., then starts the chat.
- A command that gets the session at once prints neither line.
- When standard error is not a terminal, or TERM is dumb, the command prints the waiting line once, without the spinner and the time, and the Took over line once.
- The line is cut to the terminal width.
- Ctrl-C while waiting exits with code 130. SIGTERM and SIGHUP exit with 128 plus the signal number.
By default the lease lasts 600 seconds, and the command renews it every third of that, every 200 seconds. A command that exits releases the lease at once, and a waiting command takes the session within about a second, however long the lease lasts. A command that was killed, or paused for longer than the lease, such as with Ctrl-Z or a laptop that sleeps, holds the session until its lease expires: up to 10 minutes by default. When a paused command continues and finds that another command took its session, its chat stops with one line and exit code 1:
Session builtin-20261113-203123-3efeb4 is now open in another terminal (host-b, pid 77, since 21:02); this chat stopped.
Changed in 0.6.9: the lease lasts 600 seconds instead of 15. sessions.lease_ttl_seconds in the configuration file sets the lease, from 10 to 3600 seconds. The environment variable DEX_AGENTS_SESSION_LEASE_TTL_SECONDS, from 1 to 3600 seconds, overrides the file; the command ignores any other value of it. A shorter lease lets another machine take a session sooner after a crash. It also renews more often, and a command that loses its connection to Dex stops sooner.
Since 0.6.8, a command pulls a session's task queue only while Dex has recently confirmed its lease. Each confirmed acquire or renewal allows it to pull until the lease minus a fifth, 480 seconds by default, after that request was sent; the time also starts when it begins to pull. When the time runs out, such as when the command loses its connection to Dex, it stops pulling first. Before the chat starts, it then waits and tries again, and a late answer from Dex grants nothing. During the chat, it prints one line and exits with code 1. Another command can then take the session without both running it:
Session builtin-20261113-203123-3efeb4 could not renew its lease in time; this chat stopped so that another terminal can take the session.
The lease is stored in the session, in the SessionTerminalLease Attribute. Sessions that an earlier release started take it the first time a 0.6.3 command opens them.
- Commands of earlier releases take no lease. They do not wait for a 0.6.3 command, and a 0.6.3 command does not wait for them.
- In the terminal UI, /sessions and /new wait for the lease with dexcli 1.47.2 or later. The terminal UI hands the switch to the command, which waits with the same status line and opens the terminal UI again on the new session. Since 0.6.8 the reopened terminal UI starts with the new session's history only, and the command uses the plain chat with an earlier dexcli, which would switch in place onto a task queue that no Worker pulls.
- Two commands that open a free session at almost the same moment may both pull its task queue for a moment, until one of them gets the lease. A Step of the session in that moment runs in either command.
- For sessions from before 0.6.8, the lease marks which terminal shows a session. It does not keep a Worker from running the session's Steps: two commands in the same environment still share them.
Fork a session
Since 0.6.13. A fork is a new session that starts from another session's conversation between two turns. It copies the messages, the session settings, the usage, and the plan at that point. The new session then runs on its own, and the source session keeps running unchanged.
dex-agents-claude-sdk fork SESSION_ID
dex-agents-claude-sdk fork SESSION_ID --at 6
- fork SESSION_ID copies the session as it waits for its next message. --at N copies it right after message N, which must be the last message of a turn. Message numbers count every stored message from 1: user messages, model replies, and tool calls and results.
- In the plain chat, /fork forks the open session, and /fork N forks it after message N.
- The command prints the new session's ID and asks whether to open it now. Enter opens it, as --resume would, and in the plain chat it leaves the source session. Without a terminal, or after n, the command prints the --resume line of the new session.
- The new session gets an ID in the command's format and its own task queue, so it runs only in the command that opens it. This holds also for a source that another client started on a shared task queue: the fork opens with --resume like any session of the command. It holds no terminal lease, and it has no last environment, so the first command that opens it takes no session over. A session from before 0.6.8 keeps its Flow type and task queue in the fork, and resumes in its own environment.
- When the fork exists but the command cannot open it, the error names the new session, so you can resume it later.
- A fork needs server-zd 0.1.33 or later, which dexcli 1.47.8 or later runs. With an older server the command stops with one line that says so.
The command refuses a point that is not between turns, with one line that says why:
- the source is running a turn, and the fork asks for its current state or its last message;
- message N is inside a turn, or steering ended its turn;
- the session's events no longer reach back to message N, or the point is outside the session's history window;
- the source failed.
The fork keeps only the state at its point. It has no Flow history and no live events of the source, so Dex Web shows its earlier tool calls with their message text only, and the terminal UI shows a cancelled earlier turn as an ended one. Changes that reached the source after the point are left out, such as a settings change or a message queued while it waited. A message queued before the point that no turn took yet is copied, and runs when the fork opens.