# Capabilities

> Declare what an agent may do, bind it to code, and choose who approves it.

A capability is a typed function the model may propose. The bundle declares it; your code
implements it.

```yaml
capabilities:
  - method: send_warning
    risk: dangerous
    approval: human
    params_schema:
      type: object
      properties:
        message: { type: string }
      required: [message]
      additionalProperties: false
    handler: "budget_actions:send_warning"
    workspace: true
```

| Field | What it does |
|---|---|
| `method` | The name the model proposes. |
| `params_schema` | JSON Schema the params must match before anything runs. |
| `risk` | `read_only`, `mutating` or `dangerous`. `dangerous` allows only `human` or `deny`. |
| `approval` | `auto`, `parent`, `human` or `deny`. |
| `condition` | Optional CEL over measures, the proposal and the caller. |
| `handler` | `module:function` that implements it. Without one, every proposal is refused. |
| `workspace` | Give the handler a folder Loom made, instead of letting anyone choose a path. |
| `returns` | Optional JSON Schema for the result. |

## Writing a handler

Loom calls the handler with the validated params as keyword arguments, plus `workspace` when the
capability asks for one. Return something JSON-serializable: it is recorded as the outcome.

```python title="budget_actions.py"
from pathlib import Path


def send_warning(*, message: str, workspace: Path) -> dict:
    target = workspace / "warning.txt"
    target.write_text(message)
    return {"path": str(target)}
```

The model never chooses where a handler writes. A handler is still your code, though: it can open any
path its process can, so keep it narrow.

## Conditions

Conditions read measures as `m.*`, the proposal as `action.*`, and the caller as `actor.*`:

```yaml
condition: "m.disk_pct_avg > 95 && action.params.confirm == true && actor.roles.exists(r, r == 'sre')"
```

See [Safety pipeline](/loom-site/concepts/safety-pipeline/) for the order these checks run in.