# agent_sessions

Recent sessions of the AI agent programs on the machine, newest first, with the id agent_prompt takes to continue one.

**In short:** Risk class [`read`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `agent_sessions`; over HTTP send `"tool": "agent_sessions"` to [`POST /api/v1/call`](https://docs.cmdop.ai/reference/http/post-call.md).

## Arguments

Over MCP every tool also takes `machine`: the machine's name or id, optional when only one machine is online.

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `agent` | `string` | no | Catalog id. Absent: every agent `agent_list` shows. |
| `limit` | `integer` | no | At most this many, newest first (default 20, at most 200). |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `sessions` | `object[]` | yes |  |

## Examples

**MCP**

```json
{
  "name": "agent_sessions",
  "arguments": {
    "machine": "<machine>"
  }
}
```

**HTTP**

```bash
curl -sS -X POST "https://<contour>.cmdop.dev/api/v1/call" \
  -H "Authorization: Bearer $CMDOP_TOKEN" \
  -H "x-cmdop: 1" \
  -H "Content-Type: application/json" \
  -d '{"machine":"<machine>","tool":"agent_sessions","args":{}}'
```

## Limits

The call times out after 30 s (`timed_out`). Available since version 0.1.13. A refused or failed call returns one of the [error codes](https://docs.cmdop.ai/reference/errors.md).
