---
title: "Agents · Tempo AI Platform docs"
description: "Durable Codex and Claude agents over HTTP: ids and personas, shared agents, turns, steering, subagents, payers and the session API for nanocode clients."
url: "https://gateway.tempo-dev.workers.dev/docs/agents"
---

> Every page of the Tempo AI Platform is Markdown at its URL with .md, or with Accept: text/markdown. The index of every page is https://gateway.tempo-dev.workers.dev/llms.txt, the API https://gateway.tempo-dev.workers.dev/openapi.json and the MCP server https://gateway.tempo-dev.workers.dev/mcp.

# Cloud agents that keep running

Start a Codex or Claude agent with one call. It plans with any model, searches the web, runs sandboxes and your machines, keeps its memory, and pays for each from your budget. It keeps going when you close the laptop.

[Get your Tempo Key](https://gateway.tempo-dev.workers.dev/key.md) · [Quickstart](https://gateway.tempo-dev.workers.dev/docs/quickstart.md)

## How they work

An agent is a nanocode session in a Durable Object, with Code Mode, a workspace under `/workspace` and subagents. `harness` picks Codex (the default) or Claude, and `model` any gateway model that calls tools: DeepSeek V4.1 Flash unless you choose another, and `GET /v1/capabilities` lists them under `agents`.

- **Turns**\
  `POST /v1/agents/:id/turns` with a `prompt` answers `202` with the turn's `request_id` and `status`, to poll at `turns/:turn`; with `Accept: text/event-stream` it streams the turn's events until its result, and the model's text and tool input as `event: live` frames while it writes them (`?live=0` leaves those out).
- **Steering**\
  A prompt sent while a turn runs steers that turn and answers `{"status":"steered"}`. Send `steer: false` to queue it as the next turn instead, or `steer: true` to steer only, which answers 409 when no turn runs.
- **Subagents**\
  An agent runs subagents inside its session, on either harness, with nanocode's own tools: `spawn_agent`, `send_agent_message`, `list_agents`, `wait_agent`, `interrupt_agent` and `close_agent`. From outside, `/v1/agents/:id/subagents` lists them as `{ agents }`, sends one a `message` with a `priority`, interrupts or closes one, or asks it a `side_question`.
- **Budgets**\
  `spawn_agent` takes `budget_usd`, the most a subagent and the subagents under it may spend together, at most the spawning agent's own. Once a subtree has spent its budget the gateway refuses its paid requests with 402 `over_limit`. The agent's owner raises, lowers or clears a budget with `POST /v1/agents/:id/subagents/:agent_id/budget` and `{ budget_usd }`; listings show `budget_usd` and, for every subagent, `spent_usd`.
- **Hands**\
  Your laptop, a browser tab or a sandbox can be the agent's hands, attached to one agent or to your account, so the agent's cells and tools run there. [Machines](https://gateway.tempo-dev.workers.dev/docs/machines.md) covers hands, paid hands and their routes.
- **Tools**\
  In a cell, `tools.mcp__gateway__*` are the gateway's kv, bucket, git, compute, browser, sharing and AI tools on the key's wallet in the agent's app, and `fetch` pays other MPP services from the same key. Both harnesses search the web through the gateway, and every agent has its own mailbox. [Comms](https://gateway.tempo-dev.workers.dev/docs/comms.md) covers mail and texts that wake it.
- **Scope**\
  An agent belongs to its wallet and its `Gateway-App` (default `default`): every key of the wallet reaches it, whether it was made with curl, over SSH or on the web, and it pays from the key that created it. Another wallet gets a 404 unless you share it (an `agents` grant to a wallet, a team or `*` for anyone with a Tempo Key: read to watch its threads, write to prompt it), and then sends `Gateway-Owner`. A turn someone else starts is paid from their own key and its tools act on their own data; it never steers your turn, and it is refused while your hands are attached. It expires with the key that created it.

## Ids and personas

Every agent has an id, `agt_` and 16 hex digits, which `POST /v1/agents` answers. It may also have a persona, 1 to 64 lowercase letters, digits, `_`, `.` or `-`, not starting with `agt_`, and unique among the key's live agents in the app (another answers `409`). Routes take either; every agent route's answer carries the id in `Gateway-Agent`. `PATCH /v1/agents/:id` with `{"persona":null}` clears a persona, and deleting an agent frees it.

## Personas

A persona is a saved agent configuration: a name, a description, a harness, a model, a thinking level and optional instructions of at most 32 KiB. It is private to your wallet, or team-wide when you save it with a `team` you are a member of; any member creates a team persona, and its creator or a team admin edits or deletes it.

- **Creating from one**\
  An agent created with `{"persona":"reviewer"}` takes the persona's harness, model and thinking unless the request sets them, and keeps `reviewer` as its handle.
- **The factory**\
  `POST /v1/agents/reviewer/turns`, when the key has no agent with that persona but a persona of that name is yours or your team's, creates the agent from it on the spot and runs the turn.
- **Instructions**\
  They are appended to the lead agent's system prompt on every model call as AGENTS.md instructions for the persona, the way Codex and Claude Code add a repository's AGENTS.md. The harness's own prompt stays untouched, subagents don't get them, and an edit reaches a running agent within 30 s, or one model call later when it was idle.

## Shared agents

You share an agent with an `agents` grant (`POST /v1/grants/set`) to a team, a wallet or anyone with a Tempo Key. [Multiplayer](https://gateway.tempo-dev.workers.dev/docs/guides/multiplayer.md) covers teams, budgets and who pays.

- **Reaching it**\
  A grantee reaches the agent by its `agt_` id, or by its persona with `Gateway-Owner` and the agent's `Gateway-App`. Read lets it read the agent, its events, turns, files and subagents; write lets it start turns, paid by its own key or team budget.
- **Co-steering**\
  Members of a team granted write steer the running turn, whoever of the owner and the team started it, cancel it and message the agent's subagents. A wallet or anyone else with write starts turns of its own, which wait for the running one and are cancelled only by it or the owner.
- **Senders**\
  A prompt from another wallet reaches the agent as `[from name (0x1234…abcd)] prompt`, with the name from their profile, and the gateway records who sent every turn.
- **The owner's**\
  Only the owner deletes it, patches it or attaches hands, and while the owner's hands are attached everyone else's turns answer 409.

## Traces and analytics

Every call your keys and agents make through the gateway is recorded once, as a row of Workers Analytics Engine tagged with your wallet, app, key, agent, turn and subagent: each paid operation, MCP tool call and agent cell fetch, with its status, error, duration, model and provider, and the steps inside it. What it cost is read from the ledger that charged it, so the two never disagree.

- **Find a failure**\
  List the calls of a turn with `{"turn":"…"}`, or every failed call with `{"outcome":"failed"}`; each carries the problem's `code` and `detail`, as the caller got them.
- **Its steps**\
  Each call lists the steps inside it with their start, duration and status: the operation it paid for, every model request with the provider that served it and its retries, vendor purchases and fetches, by host and never by URL.
- **Analytics**\
  `/v1/traces/stats` answers calls, failures, p50 and p95 latency by operation, model and agent, cost and tokens from the ledger and the vendors paid, over up to 90 days.
- **Where**\
  The console's [Traces](https://gateway.tempo-dev.workers.dev/console.md#traces) shows the same, and agents have the MCP tools `traces_list` and `traces_stats` to read their own. Calls show up within a minute and are kept 90 days.
- **Limits**\
  Analytics Engine samples a busy wallet's bursts: a call marked `weight` 2 stands for two, and the totals count them. A call keeps its first 10 KB of steps and says how many more it had.

| Route                 | What it does                                                                                                                                                                                                                                                | Price   |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| POST /v1/traces/list  | The wallet's calls, newest first: status, error code and detail, duration, model, agent, turn and subagent, cost and tokens from the ledger, and the steps inside each; filter by agent, turn, key, app, kind, name or outcome failed, and page with before | $0.0005 |
| POST /v1/traces/stats | Calls, failures, p50 and p95 latency by operation, tool or host, by model and by agent, cost and tokens from the ledger, vendors paid, and a series by hour or day, over 1 to 90 days                                                                       | $0.0005 |

## Use it

Run agents like any platform, with one API key for every route, or have your own app pay for them over MPP. Both pay the same prices.

### From your cloud agent

Give [your agent](https://gateway.tempo-dev.workers.dev/docs/quickstart.md) a turn. It already has these tools:

> Spawn three subagents, each on its own sandbox. Benchmark zlib, bz2 and lzma on 20 MB of synthetic logs, commit the script to a git repo named codecs, and answer with a table.

**Cloud agent**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/agents/$AGENT/turns \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -H accept:text/event-stream \
  -d '{"prompt":"Spawn three subagents, each on its own sandbox. Benchmark zlib, bz2 and lzma on 20 MB of synthetic logs, commit the script to a git repo named codecs, and answer with a table."}'
```

### With your Tempo Key

Create an agent with your Tempo Key and give it turns, as the quickstart does. Its model calls and tools are paid from the key at the prices of the routes they call, and the agent belongs to that key: revoke the key and the agent stops.

**Stream its events**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/agents/$AGENT/events \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H accept:text/event-stream
```

**Subagents**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/agents/$AGENT/subagents \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default

curl https://gateway.tempo-dev.workers.dev/v1/agents/$AGENT/subagents/1/messages \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"message":"Stop after lzma","priority":"urgent"}'
```

**Claude harness**

```sh
curl https://gateway.tempo-dev.workers.dev/v1/agents \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H gateway-app:default \
  -H content-type:application/json \
  -d '{"harness":"claude","model":"vercel/anthropic/claude-sonnet-5.5","thinking":"low"}'
```

### Paid by your app over MPP

An agent runs on a Tempo Key, because the gateway holds the key it pays from. Your app can pay for it instead: set a payer, and the gateway asks it for an MPP session voucher in MACH or OUSD for every model and tool call, as Swarms does for crowdfunded agents. The agent's data stays the key's.

**Set a payer**

```sh
curl -X PATCH https://gateway.tempo-dev.workers.dev/v1/agents/$AGENT \
  -H "authorization: Bearer $TEMPO_KEY" \
  -H content-type:application/json \
  -d '{"payer":{"url":"https://your.app/pay","secret":"'$PAYER_SECRET'"}}'
```

**Payer (mppx)**

```sh
import { Mppx, tempo } from "mppx/client";
import { createSqliteChannelStore } from "mppx/client/node";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const channelStore = createSqliteChannelStore({ namespace: "https://gateway.tempo-dev.workers.dev" });
const mppx = Mppx.create({ methods: [tempo({ account, channelStore, maxDeposit: "1" })], polyfill: false });

export default {
  async fetch(request: Request) {
    const asked = await request.json();
    const challenge = new Response(null, { headers: asked.challenge.map(value => ["www-authenticate", value]), status: 402 });
    return Response.json({ authorization: await mppx.createCredential(challenge) });
  },
};
```

### Tools inside the agent

Agents have no MCP tools of their own. Inside an agent these are its tools, beside the gateway's MCP tools as mcp__gateway\_\_\*.

`spawn_agent`, `send_agent_message`, `wait_agent`, `list_agents`, `interrupt_agent`, `close_agent`, `exec_command`, `web__run`, `hands`

**Claude Code**

```sh
claude mcp add --transport http tempo https://gateway.tempo-dev.workers.dev/mcp \
  --header "authorization: Bearer $TEMPO_KEY"
```

**Codex**

```sh
curl -fsSL https://gateway.tempo-dev.workers.dev/codex | sh
```

## Routes

Every route takes the key as `Authorization: Bearer` and an optional `Gateway-App`. They are free; the agent's model calls and paid tools are charged as they run, at the prices of the routes they call.

| Route                                                 | What it does                                                                                                                                                                                                                                                                                                            |
| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| POST /v1/agents                                       | Create an agent: harness (codex, the default, or claude), model (a gateway model that calls tools), thinking, name (a label), persona and payer; answers the agent with its id (agt\_…)                                                                                                                                 |
| GET /v1/agents                                        | The key's agents in this app, each with its id and persona                                                                                                                                                                                                                                                              |
| GET /v1/agents/:id                                    | One agent; every :id route takes the agent's id or its persona, and an agent shared with you is reached by its id, or by its persona with Gateway-Owner                                                                                                                                                                 |
| PATCH /v1/agents/:id                                  | Set, change or clear (null) the persona, its thinking or the payer; owner only                                                                                                                                                                                                                                          |
| DELETE /v1/agents/:id                                 | Delete an agent, its transcript and its workspace; answers its id and persona, and frees the persona; owner only                                                                                                                                                                                                        |
| GET /v1/agents/:id/triggers                           | The agent's [schedules and GitHub subscriptions](https://gateway.tempo-dev.workers.dev/docs/guides/triggers.md), each with when it fired last; owner only                                                                                                                                                               |
| POST /v1/agents/:id/triggers                          | Add a trigger (prompt and schedule or github), or replace one by id; owner only                                                                                                                                                                                                                                         |
| DELETE /v1/agents/:id/triggers/:trigger               | Delete a trigger; owner only                                                                                                                                                                                                                                                                                            |
| POST /v1/agents/:id/turns                             | Send a prompt (id, thinking, hand, steer, up to 8 images); answers the agent's id and persona beside request_id and status, steers a running turn unless steer is false, and with Accept: text/event-stream streams the turn's events, with the model's text and tool input as it writes them (live=0 leaves those out) |
| GET /v1/agents/:id/turns/:turn                        | A turn's status and result                                                                                                                                                                                                                                                                                              |
| POST /v1/agents/:id/turns/:turn/cancel                | Cancel a turn                                                                                                                                                                                                                                                                                                           |
| GET /v1/agents/:id/events                             | The agent's events after a cursor, as JSON pages or a stream with live text and tool input (live=0 leaves those out)                                                                                                                                                                                                    |
| POST /v1/agents/:id/warm                              | Open the agent's runtime ahead of its next turn                                                                                                                                                                                                                                                                         |
| GET /v1/agents/:id/subagents                          | The agent's subagents, as { agents } like nanocode's list_agents; GET /subagents/:agent_id for one                                                                                                                                                                                                                      |
| POST /v1/agents/:id/subagents/:agent_id/messages      | Send a subagent a message with a priority (urgent steers its running turn, deferred queues behind it), as nanocode's send_agent_message                                                                                                                                                                                 |
| POST /v1/agents/:id/subagents/:agent_id/interrupt     | Interrupt a subagent and its descendants; close closes them                                                                                                                                                                                                                                                             |
| POST /v1/agents/:id/subagents/:agent_id/side_question | Ask a subagent a side question from its last completed turn                                                                                                                                                                                                                                                             |
| POST /v1/agents/:id/subagents/:agent_id/budget        | Set or clear the most a subagent and its own subagents may spend together                                                                                                                                                                                                                                               |
| GET /v1/agents/:id/subagents/:agent_id/events         | A subagent's events, or its whole subtree's with subtree=1, as pages or a stream                                                                                                                                                                                                                                        |
| GET /v1/agents/:id/files/:path                        | Read a file from the agent's workspace                                                                                                                                                                                                                                                                                  |
| POST /v1/agents/:id/files?name=                       | Upload a file into the workspace's uploads                                                                                                                                                                                                                                                                              |
| /v1/agents/sessions/:name/...                         | nanocode's Cloudflare session API, the path for nanocode clients and their hands: :name is an agent's id or persona, and a new name creates an agent with a fresh id and the name as its persona                                                                                                                        |

### Personas, teams and profiles

These are paid per call, from the key or over MPP, and are also MCP tools.

| Route                    | What it does                                                                                                                                                             | Price   |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
| POST /v1/personas/set    | Save a persona: name, team (a team address for a team-wide one), description, harness, model, thinking and instructions; replaces the persona of that name in that scope | $0.0005 |
| POST /v1/personas/list   | Your personas first, then your teams' (team narrows to one team)                                                                                                         | $0.0005 |
| POST /v1/personas/get    | One persona by name and team                                                                                                                                             | $0.0001 |
| POST /v1/personas/delete | Delete a persona; the creator or a team admin deletes a team one                                                                                                         | $0.0001 |
| POST /v1/teams/agents    | The agents shared with a team through agents grants, with their owner, the owner's profile name and the team's abilities                                                 | $0.0005 |
| POST /v1/profile/get     | Your profile name and wallet                                                                                                                                             | $0.0001 |
| POST /v1/profile/set     | Set the name (at most 64 characters) others see on turns you send their agents, or team: the team whose budget pays for you (auto, none or an address)                   | $0.0001 |

### Hands

The routes that attach hands to one agent or to your account are on [Machines](https://gateway.tempo-dev.workers.dev/docs/machines.md#hands).

## Session API for nanocode clients

nanocode clients built for its Cloudflare sessions, such as nanocode-ts's `cloudflare/transport` and nanocode-swift's Cloudflare remote with its hands, work with base `https://gateway.tempo-dev.workers.dev/v1/agents/` and a Tempo Key as their bearer token. They name their sessions themselves: `:name` resolves as an agent's id or persona, and a turn to a name that is neither creates an agent with a fresh `agt_` id and the name as its persona, on the turn's `provider` as harness and its `model` when that is a gateway model that calls tools (DeepSeek V4.1 Flash for none, or for an OpenAI or Anthropic name). Later turns run on the agent's harness and model.

| Route                                     | What it does                                                                                 |
| ----------------------------------------- | -------------------------------------------------------------------------------------------- |
| GET /v1/agents/health                     | The health check nanocode clients make                                                       |
| POST /v1/agents/sessions/:name/turns      | A turn, creating the agent when :name is new (provider picks the harness, Claude by default) |
| GET /v1/agents/sessions/:name/turns/:turn | A turn's status; POST …/cancel cancels it                                                    |
| GET /v1/agents/sessions/:name/events      | The session's events, with after, limit and live as the client sends them                    |
| POST /v1/agents/sessions/:name/warm       | Warm the session; an unknown name answers 204 without creating one                           |
| POST /v1/agents/sessions/:name/hands      | A hand token, dialed at sessions/:name/hands/machine                                         |
| /v1/agents/sessions/:name/files           | Read and upload files, as /v1/agents/:id/files                                               |

[<- It speaks SSH](https://gateway.tempo-dev.workers.dev/docs/guides/ssh.md) · [Models ->](https://gateway.tempo-dev.workers.dev/docs/models.md)
