# Agents

The agents service lets the gateway run a coding agent such as Claude or Codex on your machine, and streams what it does back.

It is off by default and has no command of its own: you reach it through the gateway's REST API,
its MCP tools and the web UI. This page says how to turn it on, which agents exist and where it
stops.

## Turn it on

Set `agents.enabled` in the config (or `AHTO_AGENTS_ENABLED=true`) and restart `ahto serve`:

```yaml
agents:
  enabled: true
  default: claude          # the agent a call uses when it names none
```

The agent's own program must be installed and signed in on this machine; ahto starts it and does
not sign it in. `claude` and `codex` are on and use your subscription sign-in by default; the
others are off until you set them.

| Agent | Default | How ahto reaches it |
|---|---|---|
| `claude` | on, `read_only` | the `claude` program, with your sign-in |
| `codex` | on, `read_only` | the `codex` program, with your sign-in |
| `grok` | off | an HTTP API (`base_url`, `model` `grok-4`), needs `api_key` |
| `mistral` | off | an HTTP API (model `devstral-medium-latest`), needs `api_key` |
| `ollama` | off | a model on this machine (`http://127.0.0.1:11434/v1`, model `qwen2.5-coder:7b`), needs no key |

Every agent takes the same keys, and a key that does nothing for an agent is refused at start:
`enabled`, `auth` (`subscription`, `api_key` or `none`), `model`, `binary`, `base_url`,
`api_key`, `sandbox` and `timeout` (10 minutes when unset). `sandbox` is `read_only` or
`workspace_write`: the second lets the agent change files. `agents.mcp.servers` lists MCP
servers, each a `command` (spoken to over stdio) or a `url`, with an `env` map.

## Use it

| Call | What it does |
|---|---|
| `GET /v1/agents` | the agents, whether each is enabled, and whether it is ready |
| `POST /v1/agents/{name}/ask` | one question, one answer |
| `POST /v1/agents/{name}/runs` | a run that streams its steps as they happen |

`ready` means the agent can run now: its program is installed and signed in, or its API answers.
An agent that talks to a chat API (`grok`, `mistral`, `ollama`) calls the MCP servers named under
`agents.mcp.servers`; `claude` and `codex` use their own tools.

## Where it stops

- Agents run on the owner's machine only. The gateway refuses a call when it is in public mode,
  and when `protocol.allow_remote` is set, because there is no sign-in for the caller yet.
- No `ahto agents` command exists.
- The proxy that keeps the agent's credentials out of its hands (RFC 0022) is in use when
  `claude` or `codex` run with `auth: api_key`. Two building blocks have code and tests but
  no command or API yet: a workspace an agent works in and hands back as a patch (RFC 0023),
  and a table of runs (RFC 0024). Do not rely on them.

The design is RFC 0016.

Not to be confused with [agents in this repository](/docs/gateway#agents-in-this-repository): that is
how an outside agent, such as Claude Code, reaches ahto. This page is the reverse: ahto running
an agent.