# Runtime runner

The omazy-runner process, its configuration, the protocol it speaks to Omazy, and the Claude CLI versions it supports.

Source: https://docs.omazy.ai/reference/platform/runtime-runner/

`omazy-runner` runs runbooks on the Claude runtime on a machine you control. For
setting one up, see [Run runbooks on your own Claude](/how-to/automate/claude-runtime/).
This page is the specification.

## Configuration

Everything is an environment variable, so the same image runs under Docker,
systemd and Kubernetes.

| Variable | Default | Meaning |
|---|---|---|
| `OMAZY_API` | `https://mw.omazy.ai/api/v1` | The API the runner dials. Must be `https` |
| `OMAZY_ENROLL_TOKEN` | | One-time enrolment token. Read only on first start |
| `OMAZY_STATE_DIR` | the image's state volume | Runner identity (mode `0600`) and per-run scratch folders. Keep it on a persistent volume |
| `OMAZY_RUNNER_NAME` | hostname | Shown in the console |
| `OMAZY_CAPACITY` | `1` | Concurrent runs, `1` to `64` |
| `OMAZY_SESSION_STORE` | `none` | Where paused sessions are mirrored: `none`, `file:///path`, or `s3://bucket/prefix` |
| `OMAZY_SANDBOX_WRAPPER` | | A command prefix for each run, for an extra sandbox layer |

Model credentials are passed through to Claude untouched: `ANTHROPIC_API_KEY`, or
`CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX` or `CLAUDE_CODE_USE_FOUNDRY`
with that provider's variables. Proxy settings (`HTTPS_PROXY`, `NO_PROXY`) pass
through too. Nothing else from the runner's environment reaches Claude.

With an `s3://` session store, set `S3_ENDPOINT`, `S3_ACCESS_KEY`,
`S3_SECRET_KEY` and `S3_REGION`. Any S3-compatible store works, including MinIO.

## How a run executes

Each run gets a fresh home folder and working folder. The runner starts the Claude
CLI with:

- `--bare`: no hooks, plugins, project instruction files, auto-memory or saved logins;
- the run's MCP server (`omazy`) and no other (`--strict-mcp-config`);
- `--permission-mode dontAsk` with only the run's tools allowed, and `--tools`
  limited to the built-ins the runbook opted into;
- `--max-budget-usd` from the runbook's budget.

The runner caps model turns itself, enforces the run's deadline, and stops the
whole process group on pause, cancel or a lost lease.

## Protocol

Version `1`. Every request except register carries `Authorization: Bearer
<runner token>`. Responses use the standard envelope. The schema of every body is
published as `contracts/runtime-runner.schema.json`.

| Method | Path | Purpose |
|---|---|---|
| `POST` | `/api/v1/runtime/v1/register` | Exchange the enrolment token for a runner token |
| `POST` | `/api/v1/runtime/v1/claim` | Long-poll about 25 seconds for a run. `200` with a run spec, or `204` |
| `POST` | `/api/v1/runtime/v1/runs/{runId}/heartbeat` | Extend the lease, report spend and the session id, get `continue`, `pause` or `cancel` |
| `POST` | `/api/v1/runtime/v1/runs/{runId}/events` | Append translated events. Safe to retry |
| `POST` | `/api/v1/runtime/v1/runs/{runId}/complete` | Final result. Revokes the run's MCP key |
| `POST` | `/api/v1/runtime/v1/mcp` | The run's tools, over MCP, with the run key from the spec |

A lease lasts 90 seconds; the runner heartbeats every 30. A run whose lease lapses
is handed to another runner once, resuming the same Claude session when the
transcript was mirrored, and stopped with `runtime_lease_expired` the second time.

Event numbers are local to the runner: they start at 1 for each claim and only
have to increase. Omazy assigns the run's real sequence and skips anything it has
already applied, so a retried batch never appears twice.

### Event mapping

| Claude CLI output | Run event |
|---|---|
| `system` / `init` | `thinking` ("Claude runtime started") |
| `system` / `compact_boundary` | `compacted` |
| `assistant` text | `agent_message` |
| `assistant` `tool_use` | `tool_call` (an `mcp__omazy__` prefix is removed) |
| `user` `tool_result` | `tool_result` |
| anything carrying `parent_tool_use_id` | `subagent_event` |
| `result` | `usage`, then the run's final state |

An `omazy` MCP server that fails to connect is reported as an `error` event.

## Supported CLI versions

| Claude CLI | Status |
|---|---|
| 2.x | Tested. The runner image pins `2.1.314` |
| other majors | Runs, with a warning in the runner log; events may be incomplete |

The CLI's output format is an external contract, so the pinned version only moves
together with a recorded-transcript test for the new version.
