How to work with agent sessions
The workspace's coding agent (OpenCode unless agent selects another, see Choose a coding agent) runs in a session inside the workspace VM, reached over SSH. Sessions outlive your terminal: you can detach, re-attach, run several at once and stop them from outside.
Start or attach to a session
From a directory inside a workspace path, run jailoc. It picks the workspace that contains the current directory, starts the VM if needed and opens the agent in that directory. If a session is already running there, jailoc attaches to it and redraws the screen.
If the directory belongs to several workspaces equally, jailoc asks you to pick one with -w. To name the workspace or directory explicitly:
jailoc -w my-project
jailoc ~/projects/my-project/src
Running jailoc from a second terminal takes the session over and detaches the first terminal.
Detach
Press Ctrl-b, then d, or close the terminal window. The agent keeps working. Run jailoc again to come back.
To send Ctrl-b to the agent itself, for example to background a task in Claude Code, press Ctrl-b twice.
Change the detach keys
If Ctrl-b clashes with your tmux prefix or is awkward on your keyboard layout, set other keys in ~/.config/jailoc/config.toml:
detach_keys = "ctrl-a,d"
Or for one session:
jailoc --detach-keys 'ctrl-\'
See detach_keys for the key syntax.
Get notified when the agent needs you
With OpenCode (opencode, opencode1, opencode2), an attached session notifies you when the agent finishes or asks for input while you are in another window.
To choose how, or to turn it off, set notifications in ~/.config/jailoc/config.toml and re-attach with jailoc to apply it; the VM keeps running:
[defaults]
notifications = "osc" # auto, native, osc or off
[workspaces.my-project]
notifications = "off"
auto, the default, shows a desktop notification on the host when it can (osascript on macOS, notify-send on a Linux desktop). Otherwise, as over SSH, it asks the terminal to show one with OSC 777 (osc), which only some terminals support. See notifications for every value.
Notifications need a terminal that reports focus changes, because jailoc notifies only while the terminal is unfocused. In tmux, turn on focus events and, for osc, passthrough:
tmux set -g focus-events on
tmux set -g allow-passthrough on
If OpenCode itself is configured to show notifications, jailoc sends none; see Get notifications from OpenCode.
Start another session
jailoc --new
This opens a second session next to the running one, for example to run a dev server while the agent works. A new session gets the environment of the last jailoc reload; running sessions keep the environment they started with. jailoc restart and jailoc down end every session of the workspace.
Continue an earlier agent conversation
jailoc -c # continue the last conversation
jailoc -s <session-id> # continue a specific conversation
Both flags start a new session. They are passed to the agent (for example --continue and --resume <id> for Claude Code) and refer to its conversations, not to running jailoc sessions.
| ID | Identifies | Used with |
|---|---|---|
| Agent conversation ID | A conversation stored by the agent | jailoc -s <session-id> |
jailoc session ID, listed by jailoc sessions |
A running session in the VM | jailoc --attach <ID>, jailoc sessions stop <ID> |
List and attach to running sessions
jailoc sessions -w my-project
Then attach to one by its ID:
jailoc --attach <ID> -w my-project
Sessions end when the VM stops, for example on jailoc restart; their IDs stop working. To pick up where the agent was, continue its conversation with jailoc -c from the same directory.
Stop a session
Quitting the agent ends the session. To end it from outside:
jailoc sessions stop <ID> -w my-project
jailoc down ends every session of the workspace.
Read workspace logs
jailoc logs my-project # print the last up, builder supervisor, workspace supervisor and guest console logs
jailoc logs my-project -f # follow them
For log locations and common failures, see Troubleshooting. For every flag, see CLI reference.