> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opencomputer.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Sessions and turns

> Understand durable conversations and multi-turn agent work

A session is a durable conversation with a deployed agent. Each turn appends
input and streamed runtime events to the session, allowing clients to resume a
conversation without rebuilding its history locally.

## React

When you select the React SPA, the starter imports `useAgent()` from
`@opencomputer/react`. The hook exposes:

* `messages` — accumulated user and assistant messages
* `send(text)` — create a session if necessary and stream the next turn
* `isRunning` — whether a turn is active
* `error` — the latest request error

The hook accepts an agent selector such as `hello-world@development`. Build
additional UI and application hooks around its session state as needed.

## Agent playground

Open a project in the dashboard and choose **Agent playground**. Select the
agent and environment independently, then create a new session or resume a
previous playground session.

Playground sessions stay in the playground list. Sessions started through an
API appear under **Sessions**, where their durable turn history can be
inspected.

See [Playground and debugging](/agents/playground) for target selection and the
debug inspector.

## CLI

Start a session against the development agent:

```bash theme={null}
npm run session
```

The session command always uses the current project's bound Development
deployment. It does not select between local and remote runtimes.

Projects with multiple agents may select another member of the bound project.
The environment remains Development:

```bash theme={null}
npm run session -- --agent reviewer "Review this change"
```

Add `--verbose` to stream non-message lifecycle, runtime, tool, egress, usage,
and turn events. Assistant message text continues to stream normally:

```bash theme={null}
npm run session -- --verbose --agent reviewer "Review this change"
```

Or manage the durable session lifecycle explicitly:

```bash theme={null}
npm run session -- create "Draft a response"
npm run session -- list
npm run session -- inspect <session-id>
npm run session -- attach <session-id>
npm run session -- send <session-id> "Continue"
npm run session -- end <session-id>
```

Project scripts resolve the `opencomputer` binary from the installed
`@opencomputer/cli` package. For a one-off invocation outside those scripts,
select the scoped package explicitly:

```bash theme={null}
npx --package @opencomputer/cli opencomputer session "Draft a response"
```

Use `--keep` on supported commands when the session should remain active after
the command exits.

## Input sources

Inside an agent, `useInput().source` identifies how the current work arrived.
This lets the same agent distinguish direct work from delegated subagent work
without defining another session type.
