session_create
Start a terminal session for interactive programs or long-running tasks; logs all output and allows human observation and takeover. Use instead of one-shot shell calls when a prompt is needed.
Instructions
Start a terminal session: a tmux pane a human can watch or type into,
whose output is logged in full and kept as numbered regions. Use one
instead of a one-shot shell call for anything that runs a program with
a prompt (gdb, python, ssh, any REPL), takes more than a few seconds (a
build, a testsuite), prints more than a reply holds, may ask a question
(y/n), or that the user may want to watch or take over; a one-shot call
stays right for reading and editing files and for quick commands whose
whole output you want. Open one at the start of a task and do the
task's shell work in it with the run tool:
sessions are cheap, keep running between calls and across your own
restarts (session_list finds them), and keep their cwd, environment
and running programs -- cd once, start gdb once.
With no command (or "bash"), the session is bash with shell
integration: exact command boundaries and exit statuses, and programs
are started from it with the run tool (make, gdb, python, ssh, ...). command
runs another program as the session itself instead, e.g. "gdb -q -ex
'break main' -ex run ./prog" or "ssh host"; when it exits the session is
over. One session per job is the usual shape: a shell for the build
and the tests, a second one for gdb while the first is busy.
Tell the user the session's name and attach command (in the reply) on
a line of its own, so they can watch or step in. First time here:
load the terminal-sessions skill if one is listed, else guide.
By default the pane follows the window of a human who attaches, so
cols/rows apply only until then; fixed_size keeps them (the human
then sees the pane clipped or padded). session_resize changes either
later.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | working directory (default: the server process's own) | |
| env | No | environment variables set in the session, on top of the server's environment | |
| cols | No | terminal width in columns | |
| name | No | a name for the session (default: t1, t2, ...); the name of a closed session archives its old logs | |
| rows | No | terminal height in rows | |
| command | No | the program to run instead of bash with shell integration, e.g. "gdb -q ./prog" or "ssh host"; "bash" or "zsh" (with -i/-l) is that shell with the integration, "bash --norc" or "zsh -f" a plain one | |
| fixed_size | No | keep cols x rows even when a human attaches (the default lets the pane follow their window) | |
| prompt_pattern | No | the session's default prompt regex for `run`/`expect` into a program; not for bash, and rarely needed (see `run`) | |
| delete_logs_on_close | No | delete the session's logs when it closes, for one that may show something sensitive (see session_logs) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |