# agent_cancel

Stops a running agent_prompt by its task. What the agent did until then stays done.

**In short:** Risk class [`agent`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `agent_cancel`; over HTTP send `"tool": "agent_cancel"` 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 |
| --- | --- | --- | --- |
| `task` | `integer` | yes | The `task` of an `agent_prompt` answer. |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `stopping` | `boolean` | yes | The run was asked to stop; `task_output` shows when it has. |
| `task` | `integer` | yes |  |

## Examples

**MCP**

```json
{
  "name": "agent_cancel",
  "arguments": {
    "machine": "<machine>",
    "task": 0
  }
}
```

**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_cancel","args":{"task":0}}'
```

## Limits

The call times out after 15 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).
