# List control

URL: https://docs.hanzo.ai/docs/openapi/agent/get-agent-sessions-by-id-control

> Returns the steering commands (pause/resume/stop/message) recorded against the caller's own session that are newer than the cursor, oldest first, with the cursor to poll from next.

`GET /v1/agent/sessions/{id}/control`

> [Agent →](https://docs.hanzo.ai/docs/openapi/agent) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                       |
| ------------- | ----------------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/agent/sessions/{id}/control` |
| **Method**    | `GET`                                                 |
| **Operation** | `get_agent_sessions_by_id_control`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`                |

Returns the steering commands (pause/resume/stop/message)
recorded against the caller's own session that are newer than the cursor,
oldest first, with the cursor to poll from next. It is how a locally started
`hanzo code` session — which is not task-backed, so nothing forwards its
commands to an execution engine — consumes what the dashboard posted. Read-only
and bounded at 200 per poll, so a steady poll is cheap and an applied command is
never redelivered.

## Request

2 fields.

| Field   | In    | Type    | Required | Description                                                                       |
| ------- | ----- | ------- | -------- | --------------------------------------------------------------------------------- |
| `id`    | path  | string  | yes      | ID is the session whose commands are being drained, from the path.                |
| `after` | query | integer | —        | After is the last seq this poller applied; only commands newer than it come back. |

## Response

| Status    | Body               | Meaning |
| --------- | ------------------ | ------- |
| `200`     | agent.controlDrain | ok      |
| `default` | problem-details    | refused |

`200` body — 6 fields.

| Field                | In   | Type                        | Always | Description                                                                                                                                                              |
| -------------------- | ---- | --------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `commands`           | body | agent.controlCommandView\[] | —      | Commands is the session's control commands newer than the cursor, oldest first.                                                                                          |
| `commands[].command` | body | string                      | —      | Command is what was asked, from a closed four: pause, resume, stop, message.                                                                                             |
| `commands[].message` | body | string                      | —      | Message is the text that came with the command: what to say into the run for `message`, and the cancellation reason for `stop`.                                          |
| `commands[].payload` | body | any                         | —      | Payload is the structured half a caller sent instead of (or beside) Message, embedded as JSON.                                                                           |
| `commands[].seq`     | body | integer (int64)             | —      | Seq is this command's position in the session's log — the same monotonic number every other turn is ordered by, so a command sits in the transcript where it was issued. |
| `cursor`             | body | integer (int64)             | —      | Cursor is the seq to send as `after` on the next poll — the highest seq in this page, or the cursor sent in when the page is empty.                                      |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo agent sessions control <id>
```

**SDK**

**.ts**

```ts
import { Configuration, AgentApi } from 'hanzoai';

const api = new AgentApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getAgentSessionsByIdControl({ id: 'id' });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AgentApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AgentApi(client).get_agent_sessions_by_id_control(id='id')
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.AgentAPI.GetAgentSessionsByIdControl(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, agent_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = agent_api::get_agent_sessions_by_id_control(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AgentApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new AgentApi(client).getAgentSessionsByIdControl();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/agent/sessions/<id>/control \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **agent** through the `agent` tool, which names its 38 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_agents"
         }
       }
     }'
```

---

[Agent API](https://docs.hanzo.ai/docs/openapi/agent) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
