A session is a conversation with [Claude Code or Codex](/docs/models) in its own cloud environment. The agent keeps working when you close the page or disconnect.

## Start a session

In the dashboard, describe the task on **Home** and click **New session**. From a terminal:

```bash
ellipsis --model claude-opus-5-5 -e cloud_agent_environment "Add an empty-body test in api-repo. Run it; do not commit."
```

From code:

```python
import os
from ellipsis import ClaudeCodeConfig, Ellipsis, RunBudget

client = Ellipsis(api_key=os.environ["ELLIPSIS_API_TOKEN"])
handle = client.sessions.run(
    environment="cloud_agent_environment",
    budget=RunBudget(session=5),
    claude_code=ClaudeCodeConfig(
        model="claude-opus-5-5",
        prompt="Add an empty-body test in api-repo. Run it; do not commit.",
    ),
)
print(handle.id)
```

```typescript
import { Ellipsis } from '@ellipsis-dev/sdk';

const client = new Ellipsis({
  apiKey: process.env.ELLIPSIS_API_TOKEN!,
});
const handle = await client.sessions.run({
  environment: 'cloud_agent_environment',
  budget: { session: 5 },
  claude_code: {
    model: 'claude-opus-5-5',
    prompt:
      'Add an empty-body test in api-repo. Run it; do not commit.',
  },
});
console.log(handle.id);
```

Replace `cloud_agent_environment` and `api-repo` with your [environment](/docs/environments) and repository; without an environment, the session uses the default environment. `budget` caps the session at $5. Keep the session ID to check on it later. To set up the client, see the [Python](/docs/api/python-sdk) or [TypeScript](/docs/api/typescript-sdk) SDK and [API authentication](/docs/api/authentication).

## Follow the work

The dashboard and the CLI show messages and tool calls as they happen. To reattach the CLI to a running session, run `ellipsis session get <session-id> --watch`. From code, wait for your prompt to be answered.

```python
ended = handle.wait(timeout=900)
print(ended.status, ended.error)

for record in client.sessions.records(handle.id):
    print(record.kind, record.payload)
```

```typescript
const ended = await handle.wait({ timeoutMs: 900_000 });
console.log(ended?.status, ended?.error);

for await (const record of await client.sessions.records(handle.id)) {
  console.log(record.kind, record.payload);
}
```

`wait()` returns when the session is `idle` or `closed`, with how the message ended, one of `completed`, `failed`, `stopped`, or `cancelled`. Check `status` before treating the task as done. `error` explains a `failed`, `stopped`, or `cancelled` message, with the same `reason` and `detail` the session carries. A timeout stops your client from waiting, not the agent. To stream messages as they happen, see the [Python](/docs/api/python-sdk#stream-a-session) or [TypeScript](/docs/api/typescript-sdk#stream-a-session) SDK. For what each status means, see [Lifecycle](/docs/sessions/lifecycle#status).

### Retrieve a session

```python
handle = client.sessions.handle("your-session-id")
print(handle.session.status, handle.session.error)
```

```typescript
const handle = await client.sessions.handle('your-session-id');
console.log(handle.session.status, handle.session.error);
```

Get a handle by ID at any time, for example after your application restarts.

## Send a follow-up

<span id="conversations" />

In the dashboard, type in **Reply to the agent...** and click **Send**. In the CLI, type in the session view. From code:

```python
message = handle.send("Add a test for an invalid content type too.")
ended = handle.wait(timeout=900)
print(message.id, ended.status)
```

```typescript
const { message } = await handle.send(
  'Add a test for an invalid content type too.'
);
const ended = await handle.wait({ timeoutMs: 900_000 });
console.log(message.id, ended?.status);
```

A follow-up continues the same conversation and workspace. `wait()` then waits for that message to be answered. A message sent while the agent is working is answered after the one it is on. Only the person who started a session can message it. Sessions started by a mention take replies in their GitHub, Slack, or Linear thread. A closed session can't take follow-ups. `conversation.prompting` says whether a message would be accepted. See [Lifecycle](/docs/sessions/lifecycle#conversation).

## Run a one-off task

<span id="one-shot-tasks" />
<span id="from-scripts" />

```python
from ellipsis import SessionConversationConfig

task = client.sessions.run(
    environment="cloud_agent_environment",
    claude_code=ClaudeCodeConfig(
        model="claude-opus-5-5",
        prompt="Run request-validation tests in api-repo and report failures.",
    ),
    conversation=SessionConversationConfig(interactive=False),
)
ended = task.wait(timeout=900)
print(task.id, ended.status, task.session.status)
```

```typescript
const task = await client.sessions.run({
  environment: 'cloud_agent_environment',
  claude_code: {
    model: 'claude-opus-5-5',
    prompt:
      'Run request-validation tests in api-repo and report failures.',
  },
  conversation: { interactive: false },
});
const ended = await task.wait({ timeoutMs: 900_000 });
console.log(task.id, ended?.status, task.session.status);
```

Set `conversation.interactive` to `false` when you won't send follow-ups. The session closes when its message is answered and its environment is deleted. Its messages and results stay available. To save a task and run it again or on a schedule, use [Agents](/docs/agents).

## Inspect the result

```python
session = handle.refresh()
for repo in session.scm.github.repos if session.scm.github else []:
    for file in repo.local_uncommitted_files:
        print(repo.full_name, file.path, file.patch)
    print(repo.full_name, repo.commits, repo.prs)
```

```typescript
const session = await handle.refresh();
for (const repo of session.scm.github?.repos ?? []) {
  for (const file of repo.local_uncommitted_files) {
    console.log(repo.full_name, file.path, file.patch);
  }
  console.log(repo.full_name, repo.commits, repo.prs);
}
```

The [session](/docs/api/sessions/get-sessions-id) carries its uncommitted changes, commits, and pull requests in `scm.github`. A file left out of the diff to keep it under 100 KB has a `null` `patch`.

### Cost and records

```python
session = handle.refresh()
print("Cost (USD):", session.cost.total / 100_000)
print("Budget (USD):", session.budget.limit / 100_000)
```

```typescript
const session = await handle.refresh();
console.log('Cost (USD):', session.cost.total / 100_000);
console.log('Budget (USD):', session.budget.limit / 100_000);
```

`cost.total` and `budget` are in thousandths of a cent, so divide by 100,000 for dollars. Follow-ups share the budget. Each message's `message_ended` record carries what answering it cost. Read them with [`GET /v1/sessions/{id}/records`](/docs/api/sessions/get-sessions-id-records). See [Pricing](/docs/pricing) for rates, or [download the session history](/docs/api/sessions/get-sessions-id-download).

### Session settings and agent

The [session](/docs/api/sessions/get-sessions-id) shows its own settings next to the agent that started it.

- The top level holds the session's own settings, which are its harness block (`claude_code`, `codex`, or `gemini`), `permissions`, `skills`, `mcp`, and `budget`.
- `mcp` lists every MCP server the session has, which are the servers its environment lists, its own, and the Slack or Linear server of a session started from Slack or Linear.
- `environment` is the whole [environment](/docs/environments) the session runs in, with the saved environment's `id` and a `source` that says how it was chosen.
- `agent` is the [agent](/docs/agents) that started the session, with its `id`, `kind`, `name`, `sha`, and `config`, and it is `null` when no agent started the session.
- `agent.config.session` holds the agent's own settings, which the session starts from before any [override for a session](/docs/agents#override-settings-for-a-session).

## Stop a session

Click **Stop** in the dashboard. In the CLI, type `/stop` in the session view or run `ellipsis session stop <session-id>`. From code:

```python
session = handle.stop()
print(session.status, session.error)
```

```typescript
const session = await handle.stop();
console.log(session.status, session.error);
```

Stopping ends the message the agent is on with `stopped` and cancels any queued ones. The session's `status` becomes `idle` and it can still take follow-ups. Stopping a session whose `status` is `idle` or `closed` fails with `409`. Disconnecting doesn't stop the agent.
