# Agent sessions

Run Claude Code, Codex or opencode in a VM, follow each session, send it more work and delete it.

Source: https://slashinfra.com/docs/platform/agent-sessions
Last modified: 2026-11-30T16:36:19.000Z

A session is a coding agent’s work in one folder of one VM: its id, its agent, its VM, its folder, and the state it last reported. Start it from Companion or the CLI, then return to it from a terminal or from the API.

## Start an agent with a task

`si agent run` starts the agent with your text as its first prompt and streams the answer. Companion starts the same agent in a terminal tab, so the session stays in Agents after you leave the terminal.

The samples use a VM named `agent-box` and the folder `/home/user/app`. [VMs](https://slashinfra.com/docs/platform/vms) shows how to create the VM.

The CLI has no flag for a permission mode: the agent runs with full access, edits files and runs commands without asking. To make the agent ask before it acts, start it in Companion and choose Ask in the Mode menu.

### Dashboard

- Open [Companion](https://app.slashinfra.com/companion). 
- Select the plus in Agents. 
- Enter `Run the tests and fix the failing one.` in Task. 
- Choose Claude in the Agent menu. 
- Choose `agent-box` in the SVM menu. 
- Choose Other folder in the Folder menu. 
- Enter `~/app`. 
- Choose Ask in the Mode menu. 
- Select Start agent. Companion opens the session’s terminal tab.

On a phone, the same flow opens in the Companion layout. [Answer from your phone](https://slashinfra.com/docs/agents/phone) covers the phone and its notifications.

### CLI

The agent must be signed in inside the VM, and the folder must exist. The [sign-in section](https://slashinfra.com/docs/platform/agent-sessions#sign-in-an-agent) links each agent’s guide. A VM without a sign-in answers:

```bash
si agent run agent-box --agent claude --cwd /home/user/app -- 'Run the tests and fix the failing one.'
```

Output

```text
Not logged in · Please run /login
```

A signed-in run streams the answer and ends with the agent’s exit code. The session stays in `si agent sessions` after the command ends.

## Sign in an agent

Each agent keeps its own login inside the VM. Sign in once in a terminal in the VM; the login stays on the VM’s disk and survives a sleep. SlashInfra’s sign-in does not sign an agent in.

- [Claude Code](https://slashinfra.com/docs/agents/claude-code): sign in, clone a repository and ask for a fix. 
- [Codex](https://slashinfra.com/docs/agents/codex): sign in with a device code and ask for a fix. 
- [opencode](https://slashinfra.com/docs/agents/opencode): connect a model provider and ask for a fix.

Run the start command again after the sign-in, or start the agent in Companion.

## What a session is

A session has an `ags_` id and a `session` name. The id is the one the API uses and stays with the row until you delete it. The session name is the agent’s own, such as a Claude Code UUID or `term-1234/build`.

`agent` names the coding agent, such as `claude`, `codex` or `opencode`. `svm` and `svm_name` name the VM, `svm_state` is its runtime state, `cwd` is its folder, and `project` is the VM’s project. `state` is what the agent last reported, and `changed_ms` is when the state, kind or message last changed.

Companion runs an agent in a terminal tab of its VM, and `terminal` is that tab’s id. A session started by `si agent run` has `terminal: null`, because it runs as a background job rather than a terminal tab. `si agent attach` opens a terminal for either kind.

## What survives a sleep

A sleeping VM keeps its sessions. A `working` or `blocked` session of a VM that is not running reads `paused`, because the agent cannot make progress.

A sleep in memory keeps the agent process, so it resumes where it stopped. A sleep on disk keeps the files but not the process. The agent’s transcript stays on the VM’s disk, and `si agent attach` starts the agent again from the session. [`GET /agent-sessions`](https://slashinfra.com/docs/api-reference/control/svms#getAgent-sessions) does not wake the VM; `si agent sessions`, `si agent send` and `si agent attach` reach it, so they wake it.

The terminal tab also lives in the VM: a sleep in memory keeps it, and a sleep on disk ends it. A deleted VM takes its sessions with it.

## List sessions

[`GET /agent-sessions`](https://slashinfra.com/docs/api-reference/control/svms#getAgent-sessions) returns at most 200 sessions, newest change first, and covers every project the key reads unless `project` names one. `si agent sessions` reads the agent’s own session files in the VM, so it can show a session that the API has not reported.

### Dashboard

- Open [Companion](https://app.slashinfra.com/companion). The Agents list groups sessions as Needs you, Working, Finished and Paused.

### CLI

```bash
si agent sessions agent-box
```

Output

```text
agent   id                                    cwd             title                                   updated
claude  0a1b2c3d-4e5f-4a6b-8c9d-0e1f2a3b4c5d  /home/user/app  Run the tests and fix the failing one.  2026-11-29 13:38:41Z
```

### curl

```bash
curl -sS "https://api.slashinfra.com/agent-sessions" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
{"sessions":[{"id":"ags_0123456789ab","svm":"6f1c0f0e8a","svm_name":"agent-box","svm_state":"running","project":"proj_6f1c0f0e8a","agent":"claude","session":"0a1b2c3d-4e5f-4a6b-8c9d-0e1f2a3b4c5d","state":"error","kind":null,"message":"Not logged in · Please run /login","cwd":"/home/user/app","terminal":null,"at_ms":1795959531910,"changed_ms":1795959531951}]}
```

### Python

```python
import os, requests

res = requests.get(
"https://api.slashinfra.com/agent-sessions",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
for session in res.json()["sessions"]:
print(session["id"], session["agent"], session["state"])
```

Output

```text
ags_0123456789ab claude error
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/agent-sessions', {
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
const { sessions } = (await res.json()) as {
sessions: { id: string; agent: string; state: string }[]
}
for (const session of sessions) console.log(session.id, session.agent, session.state)
```

Output

```text
ags_0123456789ab claude error
```

## Send a follow-up message

`si agent send` starts the same session again with your text as the next prompt. The agent keeps its folder and its transcript. The VM must still have the session’s files; `si agent sessions` shows the id to pass.

```bash
si agent send agent-box 0a1b2c3d-4e5f-4a6b-8c9d-0e1f2a3b4c5d -- 'Add a test for the fix.'
```

The answer streams to your terminal, as a run does, and the command ends with the agent’s exit code. `--agent` names the agent when the list no longer has the session.

## Attach to the terminal

`si agent attach` resumes the session in a terminal, with its history. Use it to answer a prompt or to type your next line.

### Dashboard

- Open [Companion](https://app.slashinfra.com/companion). 
- Select a session that Companion started in Agents. Companion opens its terminal tab.

### CLI

```bash
si agent attach agent-box 0a1b2c3d-4e5f-4a6b-8c9d-0e1f2a3b4c5d
```

The terminal takes over until you quit the agent. Unlike a run, it stays open after the agent finishes a turn. `--agent` names the agent when the list no longer has the session.

## Delete a session

Delete removes the row from the list. It does not stop the agent or delete the agent’s transcript in the VM. A working session that reports again returns with a new id. Companion’s Dismiss is for a finished session; the API accepts a session in any state.

### Dashboard

- Open [Companion](https://app.slashinfra.com/companion). 
- Find the session under Finished, or an `error` session under Needs you. 
- Open its menu: right-click the row, or press and hold it on a phone. 
- Select Dismiss. Dismiss appears only for a session in `done` or `error`.

### curl

```bash
curl -sS -i -X DELETE "https://api.slashinfra.com/agent-sessions/ags_0123456789ab" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
HTTP/2 204
...
```

### Python

```python
import os, requests

res = requests.delete(
"https://api.slashinfra.com/agent-sessions/ags_0123456789ab",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
print(res.status_code)
```

Output

```text
204
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/agent-sessions/ags_0123456789ab', {
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
console.log(res.status)
```

Output

```text
204
```

## Options

| Field | Type | Default | Allowed values | What it changes |
| --- | --- | --- | --- | --- |   
| `svm` (positional) | string | The VM set with `si use`, or the only VM in the project | A VM name or id in the project | The VM that runs or reports the agent. | 
| `prompt` (after `--`) | string | Required on `run` | Text, or `-` to read standard input | The task the agent starts with. | 
| `session` (positional) | string | Required on `send` and `attach` | A session id from `si agent sessions` | The session to resume. | 
| `agent` (`--agent`) | string | Required on `run`; the session’s agent on `send` and `attach`; every agent on `sessions` | `claude`, `codex` or `opencode` | The coding agent. On `sessions`, it filters the list. | 
| `cwd` (`--cwd`) | string | The home directory, `/home/user` | An absolute path that exists in the VM | The folder the agent works in. | 
| `project` (`--project`, or `project` query) | string | CLI: `SI_PROJECT`, else `default`; API: every project the key reads | A project name, or its `proj_` id | The project of the CLI command, or the one project of the API list. | 
| `json` (`--json`) | boolean | `false` | `--json` | Print the result as JSON. `si agent sessions --json` prints the rows as a JSON array; `run`, `send` and `attach` ignore it. | 
| `seen` (query) | string | None | 1 to 2048 characters | Mark one browser push subscription as seen; Companion sends it, and without it nothing is marked. |

## States

| State | What it means for you | What you can do |
| --- | --- | --- |   
| `working` | The agent runs a turn. | Wait, or open the terminal to watch. | 
| `blocked` | The agent waits for a permission, a question or a sign-in. | Answer in Companion, or attach to the terminal. For `auth`, sign in again. | 
| `done` | The agent finished its turn. | Send a follow-up, attach, or delete the session. | 
| `error` | The agent stopped with an error; `message` may hold its one line. | Read `message`, then send a follow-up or attach. | 
| `paused` | A `working` or `blocked` session of a VM that is not running. | Wake the VM, then attach or send a message. |

`kind` is set only on `blocked`, and is `permission`, `question` or `auth`. `message` is one line of what the session waits for.

The API reports `paused` for a `working` or `blocked` session of a VM that is not running. When the VM runs again, the list reports the session’s own state.

## Errors

| Code | When | Fix |
| --- | --- | --- |   
| [`not_found`](https://slashinfra.com/docs/reference/errors#not_found) | Delete names an id that no session of your organization has, or one outside the key’s scope. | Check the id, and the key’s project scope. | 
| [`project_not_found`](https://slashinfra.com/docs/reference/errors#project_not_found) | The `project` query names no project of the organization, or one outside the key’s scope. | Check the name or id, and the key’s project scope. |

Errors that any request can return are in the [error catalog](https://slashinfra.com/docs/reference/errors).

## Permissions

| Operation | Who can | Key action |
| --- | --- | --- |   
| Start an agent | Any member | `svm:read` | 
| List sessions | Any member | `svm:read` | 
| Send a message | Any member | `svm:read` | 
| Attach to a session | Any member | `svm:read` | 
| Delete a session | Any member | `svm:write` |

The CLI resolves the VM through the control API, so every CLI command needs `svm:read`, and its key must reach the VM’s project. The API list also needs `svm:read`.

## Limits

- The API list returns at most 200 sessions, newest change first. There is no cursor; list again to read newer changes. 
- The API keeps at most 64 session rows for a VM. A new session beyond 64 replaces the oldest `done` or `error` row; with none, the report is dropped. 
- A row is removed 14 days after its last state, kind or message change. 
- An `ags_` id is `ags_` and 12 lowercase hex characters. The agent’s `session` name is at most 128 characters. 
- A session message is one line of at most 512 code points, and `cwd` is at most 512 bytes. 
- `seen` is 1 to 2048 characters. 
- A VM serves 8 terminals at once; a 9th terminal answers 429.

The full list is in [Limits](https://slashinfra.com/docs/reference/limits).

## Next

- [Fix a failing test with Claude Code](https://slashinfra.com/docs/agents/claude-code): sign in and start a first session on a repository. 
- [Answer from your phone](https://slashinfra.com/docs/agents/phone): answer a blocked session from a notification. 
- [Sleep and wake](https://slashinfra.com/docs/how/sleep-and-wake): what the VM keeps while a session waits.
