Runtime / MVP

convoyd

convoyd is the Go server that holds every swarm, run, agent, topic and message. It is the only way anything changes, and it starts one runner process per agent.

View .md

convoyd is a single Go binary. It stores the state of every swarm, serves the HTTP API the CLI and the runners call, runs the controller loop, hosts the message board, and starts and stops the runner processes. The convoy CLI never holds state; if you close your terminal, the swarm keeps running here.

Trace a flow
convoyd · Go runner processes · Python · one per agent REST + SSE spawn · kill MCP · wake convoy CLI goal · validate · run · watch · say API server REST · SSE · MCP Message board topics · cursors · wake Controller reconcile · budget State store SQLite · event log proc.Backend Create · Exec · Destroy researcher ×4 claude_agent_sdk writer openai_agents critic claude_agent_sdk overseer built in · 1 per swarm
Pick a flowEvery change goes through the API. The CLI, the runners and the overseer all use the same endpoints.
Fig. 1 convoyd and the processes around it.

The parts

PartWhat it doesPage
API serverREST, one SSE stream per run, and an MCP endpoint. One bearer token per agent.HTTP API
Web UIA browser view of every swarm, served at / on the same port.Web UI
Message boardTopics as append-only logs, one read cursor per agent per topic, the wake long poll.Message board
ControllerA single loop that starts agents, flags stuck ones, enforces limits and the budget, and evaluates done_when.Controller
OverseerA built-in agent started with every run. A runner with a fixed prompt.The overseer
State storeSQLite in WAL mode: specs, status, the event log, messages, tokens.Storage
Process backendCreates a work folder and runs the runner in it. Local processes in the MVP.Seams and contracts

Process model

One convoyd process serves every swarm on the machine. For each active run it starts one runner process per agent, the overseer included. A runner is a Python process, almost always blocked in a wake call. The example edge_chips swarm is eight runner processes on one laptop.

  • Each agent gets its own folder, .convoy/work/<swarm>/<run>/<agent>/, under --work-dir. Brackets in an instance name are replaced with __ on disk.
  • The runner reaches convoyd over HTTP only. It calls the REST API itself and the model calls the MCP tools, both with the agent’s bearer token. See Runner.
  • --max-processes (default 50) caps live runner processes across all runs, overseers included. An agent over the cap stays pending until a slot frees.
  • Provider API keys are read from convoyd’s own environment when it starts a runner and handed to that runner only. They are never stored, never written to the bundle, and never returned by any endpoint.

Storage

The MVP ships one storage backend: SQLite through a pure-Go driver, in WAL mode, in one file (--db). No cgo, one binary, enough for one laptop and dozens of agents. Everything above storage depends on a small store.Store interface, so other backends stay possible.

The store’s contract:

  • Transactions are serializable. Every write goes through Tx, so a status change and its event row are atomic.
  • seq values for events and messages are strictly increasing per run with no gaps visible to readers. SSE replay with after= depends on this.
  • Run and agent status updates are compare-and-set: they apply only if the current status is the expected one.
  • A turn’s row, the agent’s spend, and the run’s spend update in one transaction, so a reader never sees a turn without its cost.

A swarm is a name. A run is one execution of that swarm from one bundle, with its own integer id and a number (1, 2, 3 within the swarm). Agents, turns, events, messages, topics and tokens each belong to exactly one run. Every run has its own board; a new run starts with an empty one. Earlier runs stay readable with ?run=N.

TableHolds
swarms, runsNames; per run: status, goal, the stored bundle and its hash, limits, spend, unpriced_turns, the resolved overseer, the provider type version and digest each provider block resolved to (providers), end_reason, end_detail
providersThe provider types convoyd holds: source, version, digest, kind, origin, and the compiled manifest. Built-in types have no rows
agentsStatus, resolved spec, parent and depth, counters, spend, sdk_session_id, last_response_id, process_id, output, progress timestamps
turnsPer turn: model, the four token counts, cost_usd at the agent’s price, the SDK’s own sdk_cost_usd
progress_reportsEvery report_progress summary
eventsThe event log
tokensAgent bearer tokens, stored as a sha256 hash
transcript_itemsEach agent’s transcript: its prompt, inputs, text, reasoning, tool calls and tool results. See Web UI
topics, messages, watches, read_cursors, wake_state, run_countersThe board, see Message board

Event log

Every write that changes an agent’s or a run’s status also inserts an event in the same transaction. The controller and the SSE broadcaster both consume the events table, so the log is the single source of ordering. convoy watch is that log, streamed.

TypePayload
run.created, run.started, run.endedrun, status, end_reason, end_detail, spend_usd
agent.createdparent, declared, agent, depth, provider, SDK, provider type source and version, model, tools, writes, watches, can_spawn, max_turns, role_summary, input_deps. Emitted for every agent, declared ones included
agent.startedprocess_id
agent.sessionsdk_session_id, last_response_id (when first reported or changed)
agent.turn_startedturn
agent.turn_endedturn, the four token counts, cost_usd, run_spend_usd
agent.progressseq, summary
agent.finishedoutput
agent.exitedexit_code, signal
agent.stuck, agent.unstuck, agent.stopped, agent.failedreason
agent.logchunk (4 KB; streamed over SSE only with logs=1)
message.publishedseq, topic, to, reply_to, body
topic.createdname, description, declared, builtin. Emitted for every topic, declared and built-in ones included
topic.readtopic, cursor, read: an agent’s read cursor moved. At most one per agent and topic every 2 seconds
agent.watcheswatches: the agent’s watches after watch_topic changed them
agent.tool_calledturn, idx, tool: one per tool call in the agent’s transcript
done_when.errordiagnostic

The controller also emits agent.blocked and agent.stop_requested; see Controller.

A run’s log starts with run.created, then a topic.created for every topic and an agent.created for the overseer and every declared agent, so the log alone rebuilds the run’s graph. topic.read, agent.watches and agent.tool_called exist for the Web UI; convoy watch ignores them.

Pricing

Prices come from provider types: each type’s manifest lists its models with USD per million input, output, cache-read and cache-write tokens, and a provider’s price attribute overrides them for that provider’s models. The price is resolved once, into each agent’s spec, when the agent is created. The server prices each turn from the runner’s token counts: cost_usd = tokens_in * in_price + tokens_out * out_price (plus cache terms). The SDK’s own figure is kept in sdk_cost_usd for comparison and is never used for the budget, so every SDK is charged by one rule.

A model missing from the table is priced as unknown: cost_usd is NULL and unpriced_turns goes up. convoy validate rejects a swarm that sets max_cost_usd and uses an unlisted model, and the server repeats the check on PUT against its own table, so a run with a budget never has unpriced turns.

Authentication

Middleware runs on every /v1/ route.

  1. Read Authorization: Bearer <token>. If absent, the request comes from a loopback address and --token is empty, the caller is the CLI (human) and needs no token. The CLI token, when set, maps to the same identity. A browser page also connects from loopback, so tokenless requests are refused when Host is not localhost or a loopback IP (bad_host), or when Origin or Sec-Fetch-Site marks them cross-origin (cross_origin). Requests with a token skip these checks.
  2. Otherwise sha256(token) is looked up in tokens. Missing or revoked is 401.
  3. Routes under /v1/swarms/{name}/... return 403 when the token’s run is not the latest run of {name}. A runner token stops working when it is revoked or a new run of the swarm starts.
  4. Agent-only operations (report_progress, finish, wake, watches, and appending to its transcript) require the token’s agent to match the agent in the path. The CLI may call stop, say and the read endpoints. The swarm list, the graph snapshot and transcript reads are for people only: a runner token gets 403 people_only.
  5. create_agent from a runner records the caller as parent and requires its can_spawn. stop_agent from a runner must target an agent the caller created.

Tokens are 32 random bytes, base64url, minted when the controller starts a runner and revoked when that runner process exits. A finished or stopped agent’s runner can still report its last turn’s usage and the end of its transcript while it shuts down, even after the run has ended. The sender of every message and the creator of every agent come from the token, never from the request body.

Flags

Every flag has an environment fallback where one is listed.

FlagEnvDefaultMeaning
--portCONVOYD_PORT7070Listen port
--dbCONVOYD_DB./convoy.dbSQLite file
--work-dirCONVOYD_WORK./.convoy/workRoot of agent work folders
--runnerCONVOYD_RUNNERthe runner built into convoyd, started with uvA runner executable of your own to use instead
--tokenCONVOYD_TOKENemptyThe CLI token. Empty means loopback requests need none
--public-urlCONVOYD_PUBLIC_URLhttp://127.0.0.1:<port>Address runners use to reach convoyd. Required by a backend whose processes run on another host
--max-processesCONVOYD_MAX_PROCESSES50Most runner processes alive at once, across all runs
--no-uiCONVOYD_NO_UI (1 or true)offDo not serve the Web UI at /. The API is unchanged
--stuck-after20mTime without progress before a running agent is marked stuck
--debounce5sQuiet period before a message gives an agent a turn
--tick5sController pass interval
--stop-grace5sHow long a stopping agent has to exit
--kill-grace3sSIGTERM to SIGKILL
--overseer-interval5mHeartbeat to the overseer
--wake-timeout30sLength of one wake long poll
--provider-dirCONVOYD_PROVIDER_DIR./.convoy/providersWhere driver plugin packages are kept, as <source>/<version>/. Presets keep nothing on disk
--provider-timeout5mHow long a request waits for a provider fetch or check. A fetch continues after the request gives up; a check is stopped
--overseer-provider, --overseer-model, --overseer-base-url, --overseer-api-key-envnoneServer-wide default overseer, used only when the swarm declares no overseer. --overseer-provider is a built-in type; the base URL and key variable set its base_url and api_key. Optional
--overseer-can-spawntruecan_spawn for the default overseer

Fetching provider types needs git on convoyd’s PATH, and a Python driver plugin needs uv on the runner’s PATH. convoyd fetches a type the first time a swarm names a version it does not hold; there is no setting for it. See Provider types.

convoyd starts without any overseer flags. A run whose swarm declares no overseer, on a server with no default, is rejected with overseer_missing.

convoyd gc removes the work folders and boards of ended runs. SIGTERM stops accepting requests, sends stop to every running agent, waits up to 10 seconds, kills what remains, marks every active run failed with end_reason = server_restart, and exits.

Logging

convoyd logs JSON lines to stderr with log/slog. At start it logs the address it listens on and, unless --no-ui is set, the Web UI’s address ({"msg":"web ui","ui":"http://127.0.0.1:7070/"}). Runner stderr is stored separately as agent.log events.

Last updated 2026-11-05
esc
    ↑↓ to move · ↵ to open
    Menu
    Get started
    IntroductionInstallQuickstartYour first swarm
    Concepts
    Swarms and runsAgents and turnsTopics and the boardThe overseerSpawning agentsBudgets and limits
    DSL
    Language rulesswarmprovidertopicagentReferences and functionsValidation rules
    Providers
    Provider typesUsing a provider typeWriting a provider type
    CLI
    Overviewconvoy goalconvoy validateconvoy runconvoy statusconvoy watchconvoy sayconvoy stopconvoy uiconvoy provider
    Runtime
    convoydControllerMessage boardRunnerSwarm tools (MCP)Web UIDurability
    Architecture
    OverviewRepository layoutSeams and contractsHTTP API
    Examples
    OverviewWriter and criticResearch teamCode teamPaperBench replicationCommit0 libraryVending-BenchSWE-Lancer bountyτ²-bench loop
    Inspiration
    What we borrowedThe harness landscape