DSL / MVP

swarm

The swarm block names the swarm, states its goal, and sets the rules that end it, including done_when, max_runtime, max_cost_usd, and the overseer.

View .md

The swarm block declares the goal and the stopping rules for a run. Every configuration has exactly one, in any file. Its label is the swarm’s name, which convoy run, convoy status, and the API use.

Minimal example

main.cvy
swarm "hello" {
  goal        = "Write a haiku about convoys"
  done_when   = agent.poet.output.done == true
  max_runtime = "10m"
}

This validates with one warning: max_cost_usd is not set (TS061). It also needs a poet agent that declares output = { done = bool }.

Full example

main.cvy
swarm "vending_year" {
  goal         = <<-EOT
    Run the Vending-Bench 2 machine for a full simulated year and end with the
    highest bank balance possible without going bankrupt.
  EOT
  done_when    = agent.operator.output.day >= 365 || agent.operator.output.bankrupt == true
  max_runtime  = "168h"
  max_cost_usd = 300
  overseer = {
    provider  = provider.anthropic
    model     = "claude-sonnet-5"
    can_spawn = false
  }
}

Attributes

AttributeTypeRequiredDefaultDescription
goalstringyesThe goal in plain language. Shown to every agent and to the overseer.
done_whenbool expressionyesWhen true, the run is Done. Evaluated each time a referenced agent finishes.
max_runtimeduration stringyesWall-clock limit for the whole run.
max_cost_usdnumber greater than 0nounsetDollar budget for the whole run, counting every agent and the overseer.
overseerobject with provider, model, can_spawnnoconvoyd’s flagsThe overseer’s provider and model, and whether it may create agents.

goal

A string that states what the swarm is for. It is placed in every agent’s system prompt and in the overseer’s, so write it for a model that has no other context. Use a heredoc for anything longer than a sentence. goal is static: it cannot reference other blocks.

done_when

A boolean expression that decides when the swarm is finished. It may only read agent outputs: agent.<name>.output.<field>, combined with comparison and logic operators (==, !=, >=, &&, ||, !).

HCL
done_when = agent.critic.output.approved == true
done_when = agent.reporter.output.held_out_gain >= 0.10
done_when = agent.operator.output.day >= 365 || agent.operator.output.bankrupt == true

To read one instance of a for_each agent, index it by key: agent.runner["shard_a"].output.passed. See References and functions.

How it is evaluated:

  • The server evaluates it every time an agent that it references finishes. It is not polled.
  • Agents that have not finished are unknown values. An expression that depends on an unknown value is unknown, and the server treats unknown as “not yet”.
  • A known true ends the run with status Done, and every running agent is stopped.
  • A known false means not done.
  • An evaluation error, such as comparing a number with a string, is reported once as a swarm-level event and treated as false.
  • If every agent finishes and done_when is still false, the run ends as Failed.

Every agent whose output done_when reads must declare an output shape that includes the field you read. Otherwise validation fails (TS021, TS022). Referencing anything other than an agent output, such as a topic or a provider, is TS023.

done_when references are not dependency-graph edges. The swarm does not wait for the referenced agents to start; it just checks the condition when they finish.

max_runtime

A duration string such as "4h". When the limit passes, every agent is stopped and the run’s status is Stopped with reason max_runtime. It is required so that every run has an upper bound even when no budget is set.

max_cost_usd

A number greater than zero (US dollars) bounding spend across every agent and the overseer. Spend is computed by the server from the token usage each runner reports after each turn, priced with Convoy’s built-in table or the provider’s own price.

When spend reaches the limit, every agent is stopped, the run is Stopped with reason budget, and outputs already produced are kept. Turns already in flight finish first, so actual spend can exceed the cap by up to one turn per running agent. convoy status reports actual spend.

If max_cost_usd is set, every model used by an agent, and the overseer’s model if declared, must have a price, or validation fails with TS060. If it is not set, validation warns (TS061) because only max_runtime bounds the run. A value of zero or less, or a non-number, is TS062. See Budgets and limits.

overseer

The overseer is the built-in agent that judges whether the swarm is making progress and can add, redirect, or stop agents. This attribute chooses its model.

HCL
overseer = { provider = provider.anthropic, model = "claude-sonnet-5" }
KeyTypeRequiredDefaultDescription
providerprovider referenceyesA provider.<name> reference.
modelstringnothe provider’s modelModel name, passed to the SDK unchanged. Required unless the provider sets model.
can_spawnboolnotrueWhether the overseer may call create_agent.

model may be left out when the provider block sets its own model; the overseer then runs on that one, as an agent with no model does:

HCL
overseer = { provider = provider.llm }

With neither, the overseer has no model, which is TS004.

Any other key is an error with a suggestion. When overseer is omitted, convoyd uses its --overseer-provider and --overseer-model flags. If neither is set, the server rejects the run with HTTP 422, code overseer_missing. This is not a validate error, because validation cannot know the server’s flags. If the overseer comes from the flags and max_cost_usd is set, the server checks the overseer model’s price and rejects the run with unpriced_model if it has none. See The overseer.

Limits that are not in the language

There is no limit on the number of agents in the language. How many run at once is a property of the machine, set by convoyd --max-processes. Agents beyond it wait in Pending.

What validate checks

CodeSeverityRule
TS001errorExactly one swarm block
TS002errorgoal, done_when, or max_runtime is missing
TS003errorAn attribute has the wrong type, including a malformed duration
TS004erroroverseer sets no model, and neither does its provider
TS010erroroverseer.provider or a name in done_when does not exist
TS021errordone_when reads a field of an agent with no output
TS022errordone_when reads a field not in the agent’s output
TS023errordone_when references something other than agent.*.output
TS060errormax_cost_usd is set and a model has no price
TS061warningmax_cost_usd is not set
TS062errormax_cost_usd is not a number greater than zero

Unknown attributes, and unknown keys inside overseer, are also errors.

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