DSL / MVP

agent

An agent block declares one agent, or several with count or for_each, including its model, prompt, tools, dependencies, topics, output shape, and limits.

View .md

An agent block declares one agent, several identical ones when count is set, or one per element of a set or map when for_each is set. An agent runs in turns, and one turn is one call into its SDK. It starts when its inputs and depends_on are satisfied, takes more turns when a topic it watches gets a message or a message is addressed to it, and ends when it calls finish. See Agents and turns for the runtime behaviour. This page is the language reference.

Minimal example

main.cvy
agent "poet" {
  provider = provider.anthropic
  model    = "claude-sonnet-5"
  prompt   = file("prompts/poet.md")
  output   = { done = bool }
}

provider and prompt are always required. model is required unless the provider block sets model, which is then the default for every agent on it.

Full example

main.cvy
agent "implementer" {
  count    = 4
  provider = provider.anthropic
  model    = "claude-sonnet-5"
  prompt   = file("prompts/implementer.md")
  vars = {
    me      = "implementer[${count.index}]"
    repo    = env("COMMIT0_REPO_DIR")
    library = "simpy"
  }
  tools      = ["bash", "read_file", "write_file", "edit_file"]
  inputs     = { assignments = agent.lead.output }
  depends_on = [agent.setup]
  writes     = [topic.builds, topic.human]
  watches    = [topic.tasks, topic.failures]
  output     = { files = list(string), passed = bool }
  max_turns  = 60
  can_spawn  = true
}

Attributes

AttributeTypeRequiredDefaultDescription
providerprovider referenceyesThe provider block to run under, as provider.<name>.
modelstringnothe provider’s modelModel name, passed to the provider unchanged. Required unless the provider sets model.
promptstringyesThe agent’s instructions. Almost always file("prompts/<name>.md").
varsmap of stringnononeValues substituted for {{name}} in the prompt text.
toolslist of stringno[]Built-in tools of the provider’s type this agent may use.
settingsobjectno{}Settings of the provider’s type for this agent, such as { effort = "high" }.
inputsmap of expressionnononeNamed values from other agents’ outputs. Agent starts after they finish.
depends_onlist of agent referencesno[]Agents that must finish first. Passes nothing.
writeslist of topic referencesno[]Topics this agent may publish to.
watcheslist of topic referencesno[]Topics whose new messages give this agent a turn.
outputobject typenononeShape of the finish payload.
max_turnsnumberno50The agent is stopped after this many turns.
can_spawnboolnofalseWhether the agent may call create_agent.
countwhole numbernononeCreates that many identical agents.
for_eachset of string or mapnononeCreates one agent per element.

provider and model

provider = provider.anthropic names the provider block. It is a reference, not a string: provider = "anthropic" is an error (Expected a reference like provider.<name>). model is passed to the provider unchanged, for example claude-opus-5-5 or gpt-6.1-sol.

An agent that sets no model runs on its provider’s model, the default for every agent on that provider. An agent that sets one uses its own. One of the two must be set, or the agent is TS004:

HCL
provider "llm" {
  source = "claude_agent_sdk"
  model  = "claude-sonnet-5-5"
}

agent "writer" {
  provider = provider.llm              # claude-sonnet-5-5, from the provider
  prompt   = file("prompts/writer.md")
}

agent "critic" {
  provider = provider.llm
  model    = "claude-opus-5-5"         # its own
  prompt   = file("prompts/critic.md")
}

Every instance of a count or for_each agent gets the same model, whichever way it is set. When the swarm sets max_cost_usd, the model must have a price (TS060): its provider’s price, or the price in its type’s catalog. A type with a closed catalog warns about a model it does not list (TS019); the built-in types accept any name.

prompt

The agent’s instructions. Convoy places them in the YOUR JOB section of the system prompt it builds for every agent, below the swarm goal, the agent’s name, its topics, and how to use the swarm tools. Use file(), so the prompt lives in prompts/:

HCL
prompt = file("prompts/critic.md")

A path that does not exist is TS040. The file is read when the swarm is loaded and sent to the server in the bundle. Later edits to the file do not change a run that is already started. The expression must evaluate to a string and may use count.index, each.key, and each.value, but the file text itself is not interpolated.

vars

vars substitutes values into the prompt text. {{vendor}} in the prompt file is replaced with vars.vendor.

main.cvy
agent "researcher" {
  for_each = toset(["nvidia", "groq"])
  prompt   = file("prompts/research.md")
  vars     = { vendor = each.key }
  # ...
}
prompts/research.md
You research one vendor: {{vendor}}.
Publish one sourced fact per message to the findings topic.

Rules:

  • vars is a map of strings. The samples quote numbers (max_rounds = "6").
  • Every {{name}} in the prompt whose name is a key of vars is replaced.
  • A {{name}} with no matching var is left unchanged, so placeholders meant for other layers survive.
  • A var that the prompt never uses is a warning (TS054).
  • vars may use count.index, each.key, each.value, env(), and string interpolation.
  • This is the only substitution. ${...} inside a prompt file is not interpolated.

Use env() for paths and settings, never for secrets. The values travel in the bundle and are stored with the run.

tools

The built-in tools of the provider’s type that this agent may use. Each name must be one the type offers. The built-in types offer:

TypeOffers
claude_agent_sdkweb_search, bash, read_file, write_file, edit_file
openai_agentsweb_search, bash, read_file, write_file, edit_file, code_interpreter, file_search
openai_compatiblebash, read_file, write_file, edit_file

bash, read_file, write_file and edit_file run on the agent’s machine and mean the same thing on all three types, so an agent that lists them can move between providers by changing its provider and model. web_search on openai_agents, code_interpreter and file_search are hosted: they run on OpenAI’s platform. For any other type, convoy provider show <source> lists its tools. A name the type does not offer is TS013, and the message lists the offered tools and suggests the nearest name. Swarm tools (list_topics, read_topic, publish, watch_topic, create_topic, list_agents, create_agent, stop_agent, report_progress, finish) are always available and are never written in tools. create_agent is offered only when can_spawn is true. An empty tools list is valid and gives an agent that can only use the swarm tools.

settings

Settings of the provider’s type that tune this agent’s model calls, such as reasoning effort or temperature. Each key must be a setting the type defines:

TypeSettings
claude_agent_sdkeffort (low, medium, high, xhigh, max), max_thinking_tokens (0 or more)
openai_agents, openai_compatibletemperature (0 to 2), max_tokens (1 or more)
HCL
agent "planner" {
  provider = provider.anthropic
  model    = "claude-opus-5"
  prompt   = file("prompts/planner.md")
  settings = { effort = "max" }
}

Each setting resolves key by key: the agent’s settings, then its provider’s settings, then the type’s default. A setting none of them sets is not passed, so the SDK’s own default applies. An unknown key or a value outside a setting’s range is TS018. Agents created at run time with create_agent may set settings too, and are checked the same way.

inputs, depends_on, and watches

These three attributes control when an agent runs. Only the first two order agents.

AttributeEffectGraph edge
inputsThe agent starts after every referenced agent has finished, and receives the values as JSON in its first turn.yes
depends_onThe agent starts after every referenced agent has finished. Nothing is passed.yes
watchesA message on one of these topics gives the agent another turn.no

An agent with no inputs and no depends_on starts when the swarm starts.

inputs is a map of names to expressions. Each expression must read another agent’s output:

HCL
inputs = {
  brief  = agent.triager.output
  claude = agent.proposer_claude.output
}

The agent starts once triager and proposer_claude are both Done and gets {"brief": {...}, "claude": {...}} in its first turn. The expressions may reach into a field (agent.coach.output.version), or collect every instance’s outputs, agent.worker[*].output for a count agent and values(agent.builder)[*].output for a for_each agent:

HCL
inputs = { components = values(agent.builder)[*].output }

Anything with a root other than agent is an error, inputs may only reference agent outputs. Reading a field requires the referenced agent to declare it in output (TS021, TS022). Each inputs reference is an edge, and the graph must have no cycle (TS020).

depends_on is a list of agent references. Use it to order agents when you do not need the data:

HCL
depends_on = [agent.manager]            # all instances of manager
depends_on = [agent.runner["shard_a"]]  # one instance

watches is a list of topics. After its first turn, an agent gets another turn in exactly two cases: a message is published to a topic in watches, or a message is sent with to set to the agent’s name. An agent with an empty watches list works until it calls finish: whenever it ends a turn without finishing, it gets a continue turn, until it finishes or reaches max_turns.

The writer and critic in edge_chips loop through the board (writes and watches) while the graph has no cycle, because watches and writes are not edges.

writes

The topics the agent may publish to. A publish call to any other topic is rejected and the model sees the error. Each entry is a topic.<name> reference.

output

The shape of the object the agent passes to finish. After finish, the status is Done and agent.<name>.output resolves to the payload. The server checks the payload against the shape. A mismatch is returned to the model as a tool error with the path, for example output.score: number required, and the model can try again.

output is required whenever done_when or another agent’s inputs reads a field of this agent’s output.

Two forms are accepted. They mean the same:

HCL
output = { approved = bool, score = number }
output = object({ approved = bool, score = number })

The shorthand is used in every sample. The type must be an object. Field types are limited to:

TypeExample
stringpath = string
numberscore = number
boolapproved = bool
list(T)files = list(string)
map(T)scores = map(number)
nested objectmeta = { id = string, tags = list(string) }

any is rejected, so the server can always check a payload. A primitive or collection at the top level (output = string) is an error, output must be an object type.

An agent with no output can still call finish; the payload is accepted as free-form JSON. Nothing may read named fields of it, though.

max_turns

The agent is stopped after this many turns. Default 50. A turn is one SDK call, so a long-lived agent that wakes for every message on a busy topic can use turns fast; set the limit deliberately. For long jobs, set it high: the Vending-Bench operator uses max_turns = 1500. See Budgets and limits.

can_spawn

When true, the agent is given the create_agent tool and can add agents to the running swarm. Whether a team can grow is declared in the file, not left to a prompt. A child created this way may set can_spawn = true only if its creator could spawn, and is bounded by the creator’s tools, providers, and models. The server also rejects create_agent from any other caller. See Spawning agents.

count

count is allowed on agent blocks only. The value is a whole number, and that many identical agents are created. Use it for a pool of workers that differ only in their index; use for_each when each instance gets its own input.

HCL
agent "implementer" {
  count = 4
  vars  = { me = "implementer[${count.index}]" }
  # ...
}
  • Names. Each instance is named <name>[<index>], from implementer[0] to implementer[3].
  • count.index. Inside the block, count.index is the instance’s index, a number. It is available in prompt and vars only.
  • Values. The value must be known when the files load and be a whole number from 0 to 1000 (TS032). 0 produces zero instances and a warning.
  • References. agent.implementer is a list, as in Terraform. agent.implementer[0].output is one instance, agent.implementer[*].output is the list of all outputs in index order, and length(agent.implementer) is the count. See References and functions.
  • count.index without count is TS033. An agent with both count and for_each is TS034.

for_each

for_each is allowed on agent blocks only. The value is a set of strings or a map, and one agent is created per element.

HCL
agent "researcher" {
  for_each = toset(["nvidia", "groq", "cerebras", "tenstorrent"])
  vars     = { vendor = each.key }
  # ...
}

agent "runner" {
  for_each = {
    shard_a = "0,1,3,4,5,7,9,10"
    shard_b = "11,12,14,15,17,20,21,23"
  }
  vars = { shard = each.key, task_ids = each.value }
  # ...
}
  • Names. Each instance is named <name>[<key>], for example researcher[nvidia]. Instances are processed in sorted key order.
  • each. Inside the block, each.key is the set element or map key, and each.value is the element (for a set, the same as the key) or the map value. each is available in prompt and vars. It is not available in provider, model, tools, or other static attributes.
  • A list is rejected. for_each = ["a", "b"] fails: for_each requires a set or map; wrap the value in toset() (TS030). A set must contain strings.
  • An empty set produces zero instances and a warning.
  • References. agent.researcher is an object keyed by instance key. agent.researcher["nvidia"].output is one instance, and values(agent.researcher)[*].output is the list of all outputs. See References and functions.
  • Limits. The language has no cap on the number of for_each instances. convoyd --max-processes caps concurrent runners; extra agents wait in Pending.
  • each without for_each is TS031. for_each on a block other than agent is an error.

How agents start, turn, and finish

PhaseRule
StartNo inputs and no depends_on: starts with the swarm. Otherwise starts after every referenced agent has finished.
More turnsA message on a watched topic, or a message addressed to the agent. With empty watches, a continue turn after every turn that does not finish.
Finishfinish(output) ends the agent as Done. output is checked against the declared shape.
End of swarmRunning agents are stopped when done_when is true, max_runtime passes, or the budget is spent.

Agents that watch topics usually never call finish. The server stops them when the swarm ends.

What validate checks

CodeSeverityRule
TS002errorprovider or prompt is missing
TS003errorAn attribute has the wrong type
TS004errorNo model on the agent, and none on its provider
TS010errorprovider, writes, watches, depends_on, or inputs names a block that does not exist
TS013errorA tools entry the provider’s type does not offer
TS018errorsettings does not match the type’s settings
TS019warningmodel is not in a closed catalog
TS020errorA dependency cycle through inputs and depends_on
TS021errorAn inputs value reads a field of an agent with no output
TS022errorAn inputs value reads a field not in the agent’s output
TS030errorfor_each is a list or a non-string set
TS031erroreach used without for_each
TS032errorcount is not a whole number from 0 to 1000
TS033errorcount.index used without count
TS034errorboth count and for_each are set
TS040errorA file() path does not exist
TS052warningNon-empty watches and no explicit max_turns
TS053warningNo watches, no inputs, and no writes
TS054warningA var in vars the prompt never uses
TS055warningNo watches, no output, and no explicit max_turns
TS060errormax_cost_usd is set and the model has no price
TS070warningThe model, or a setting, is deprecated by its type
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