Docs / MVP

Language reference

Every block, attribute, function, tool, price, and validation code of the Convoy language. Generated from the dsl package.

View .md

Convoy language reference

Language rules

A swarm is a folder of .cvy files written in HCL, the syntax Terraform uses. Prompt files usually live in prompts/.

  • Files. Every *.cvy file in the folder is read and merged; files in subfolders are not. Block order and file boundaries do not matter. Exactly one swarm block must exist across all files.
  • Blocks. A block is a type, one label, and a body: agent "writer" { ... }. There are four block types: swarm, provider, topic, and agent. The label is the block’s name. Names contain letters, digits, and underscores, start with a letter or underscore, and are unique within their type. The agent name overseer is reserved.
  • Attributes. name = expression. Value types are string, number, bool, list, map, and object. Durations are strings with a unit: "30s", "10m", "4h".
  • References. provider.<name>, topic.<name>, and agent.<name> refer to blocks. agent.<name>.output is the JSON an agent passed to finish, and agent.<name>.output.<field> reads one field of it. References appear only in provider, writes, watches, depends_on, inputs, done_when, and the swarm’s overseer. Every other attribute is constant: literals and functions only.
  • for_each. Allowed on agent blocks only. The value is a set of strings (use toset([...]), never a bare list) or a map. One agent is created per element, named <name>[<key>], for example researcher[nvidia]. Inside prompt and vars, each.key and each.value refer to the current element. agent.<name> is then an object keyed by instance key: agent.<name>["nvidia"].output is one instance’s output, and values(agent.<name>)[*].output is the list of all of them.
  • Dependency graph. Every reference inside inputs or depends_on is an edge from the referenced agent to this one. The graph must have no cycles. References inside writes, watches, and done_when are not edges; feedback loops go through topics.
  • Starting and finishing. An agent with no inputs and no depends_on starts when the swarm starts; otherwise it starts when every agent it references has finished, and receives its inputs as JSON in its first turn. After its first turn, an agent takes another turn when a topic it watches gets a message, or a message is addressed to it. An agent that watches nothing takes continue turns until it calls finish or reaches max_turns. finish(output) ends the agent; when the agent declares output, the payload is checked against it.
  • Ending the swarm. done_when is evaluated each time an agent finishes. When it is true, the run is Done. When max_runtime elapses first, the run is Stopped with reason max_runtime; when spend reaches max_cost_usd, it is Stopped with reason budget. When every agent has finished and done_when is still false, the run Failed.
  • Prompts. prompt is almost always file("prompts/<name>.md"). Prompt files are not HCL templates: ${...} in them is plain text. Use {{name}} placeholders, replaced from vars; a placeholder with no matching var is left as it is.
  • Functions. file(path) reads a file relative to the folder. env(name) reads a variable on the machine running convoy run; the value is sent to the server, so never use it for secrets. The arguments of file() and env() must be literal strings.
  • Models. A provider’s model is the default for every agent on that provider, and for the overseer when it names that provider. An agent’s own model wins. An agent needs one or the other.
  • Secrets. A provider’s api_key is the name of a variable in convoyd’s environment, never the key itself.
  • Comments. # and // to end of line, /* */ for blocks.

Block: swarm

Exactly one. Declares the goal and the stopping rules.

AttributeTypeRequiredDefaultMeaning
goalstringyesThe goal in plain language. Shown to every agent and to the overseer.
done_whenbool expressionyesWhen true, the swarm is Done. May reference agent.<name>.output.<field> for agents that declare an output shape. Evaluated each time an agent finishes.
max_runtimedurationyesWall-clock limit for the whole run, such as "4h". When reached, every agent is stopped and the run is Stopped with reason max_runtime.
max_cost_usdnumbernoDollar budget for the whole run, counting every agent and the overseer. When spend reaches it, every agent is stopped and the run is Stopped with reason budget. Turns in flight finish, so spend can exceed it by up to one turn per running agent.
overseerobject { provider, model, can_spawn }noThe overseer’s provider (a provider reference) and model. model may be left out when the provider sets one. can_spawn (default true) controls whether the overseer may create agents. When omitted, convoyd’s --overseer-provider and --overseer-model are used.

Block: provider

One or more. Declares one configured use of a provider type: how to reach a model provider and which driver runs its agents. Besides the core attributes below, a provider block takes the attributes its type defines; the built-in types’ attributes are listed under Provider types.

AttributeTypeRequiredDefaultMeaning
sourcestringyesThe provider type: a built-in type (claude_agent_sdk, openai_agents, openai_compatible), or an address <namespace>/<name> or <host>/<namespace>/<name> of a type that convoyd fetches from the git repository convoy-provider-<name>.
versionstringnothe newest version the server hasA version constraint, such as "~> 1.4" or ">= 1.2, < 2.0". Not allowed with a built-in type. A prerelease is selected only by an exact version.
modelstringnoThe default model for every agent on this provider, and for the overseer when it names this provider. An agent’s own model wins.
priceobject { input, output, cache_read, cache_write }nothe type’s model catalogUSD per million tokens for every model on this provider, overriding the type’s prices. input and output are required; the cache prices default to input.
settingsobjectno{}Defaults for the settings of every agent on this provider. Its keys are the type’s settings.
sdkstringnoDeprecated name of source, accepted for the three built-in types. Set exactly one of source and sdk.

Block: topic

Zero or more. Declares one channel on the message board.

AttributeTypeRequiredDefaultMeaning
descriptionstringyesOne line saying what belongs here. Shown to every agent in its topic list.

Block: agent

One or more. Declares one agent, or several when count or for_each is set.

AttributeTypeRequiredDefaultMeaning
countwhole numbernoCreates that many identical agents, named <name>[0], <name>[1], and so on. count.index is available in prompt and vars. agent.<name> is then a list. Not allowed with for_each.
for_eachset of strings or mapnoCreates one agent per element, named <name>[<key>]. each.key and each.value are available in prompt and vars. agent.<name> is then an object keyed by instance key.
providerprovider referenceyesThe provider block to run under, as provider.<name>.
modelstringnothe provider’s modelThe model name, passed to the driver unchanged. Required unless the agent’s provider sets model. A type with a closed catalog warns about a name it does not list.
promptstringyesThe agent’s instructions, almost always file("prompts/<name>.md"). {{name}} placeholders are replaced from vars.
varsmap of stringnoValues substituted into the prompt: {{vendor}} becomes vars.vendor.
toolslist of stringno[]Built-in tools of the provider’s type that this agent may use. Swarm tools are always available and are not listed here.
settingsobjectno{}Settings of the provider’s type for this agent, such as { effort = "high" }. Each key resolves from the agent’s settings, then its provider’s settings, then the type’s default; a setting none of them sets is not passed.
inputsmap of expressionnoNamed values the agent needs before it starts. Each must reference another agent’s output. The agent starts when every referenced agent has finished and receives the values as JSON in its first turn.
depends_onlist of agent referencesnoAgents that must finish before this one starts. Like inputs, but nothing is passed.
writeslist of topic referencesno[]Topics this agent may publish to.
watcheslist of topic referencesno[]Topics whose new messages give this agent a turn. With none, the agent takes continue turns until it calls finish.
outputobject typenoThe shape of the finish payload, such as { approved = bool, score = number }. Field types are string, number, bool, list(...), map(...), and nested objects.
max_turnsnumberno50The agent is stopped after this many turns.
can_spawnboolnofalseWhether this agent may call create_agent.

Provider types

A provider block’s source names its type. The three built-in types ship with Convoy; any other type is a plugin that convoyd fetches from its git repository, and convoy provider show <source> prints its reference. Each type defines the provider block’s other attributes, the settings its agents take, the built-in tools they may list, and its models with their prices.

claude_agent_sdk

Claude models through the Claude Agent SDK.

AttributeTypeRequiredDefaultMeaning
source, version, model, price, settingsThe core attributes of every provider block.
api_keyenvironment variable nameno"ANTHROPIC_API_KEY"The name of an environment variable in convoyd’s environment that holds the key. Never the key itself, and never an expression. The runner receives the value as ANTHROPIC_API_KEY.
SettingTypeDefaultMeaning
effortstring, one of "low", "medium", "high", "xhigh", "max"How much effort the model spends on each response. Passed as the Agent SDK’s effort.
max_thinking_tokensnumber, 0 or moreThe most tokens the model may spend thinking in one response. Passed as the Agent SDK’s max_thinking_tokens.

Tools: web_search, bash, read_file, write_file, edit_file.

ModelInputOutputCache readCache writeNotes
claude-fable-5-110500.2512.5
claude-opus-5-54200.25
claude-sonnet-5-52100.22.5
claude-haiku-5-50.10.50.010.125
claude-opus-55250.56.25
claude-sonnet-52100.22.5

Other model names are accepted and passed through unchanged.

openai_agents

OpenAI models through the OpenAI Agents SDK.

AttributeTypeRequiredDefaultMeaning
source, version, model, price, settingsThe core attributes of every provider block.
api_keyenvironment variable nameno"OPENAI_API_KEY"The name of an environment variable in convoyd’s environment that holds the key. Never the key itself, and never an expression. The runner receives the value as OPENAI_API_KEY.
SettingTypeDefaultMeaning
temperaturenumber, 0 to 2Sampling temperature. Passed as ModelSettings.temperature.
max_tokensnumber, 1 or moreThe most tokens one response may produce. Passed as ModelSettings.max_tokens.

Tools: web_search, bash, read_file, write_file, edit_file, code_interpreter, file_search.

ModelInputOutputCache readCache writeNotes
gpt-6-astra1050112.5
gpt-6.1-sol2100.12.5
gpt-6.1-terra150.051.25
gpt-6-luna0.10.50.010.125

Other model names are accepted and passed through unchanged.

openai_compatible

Any Chat Completions endpoint, through the OpenAI Agents SDK.

AttributeTypeRequiredDefaultMeaning
source, version, model, price, settingsThe core attributes of every provider block.
api_keyenvironment variable nameno"OPENAI_API_KEY"The name of an environment variable in convoyd’s environment that holds the key. Never the key itself, and never an expression. The runner receives the value as OPENAI_API_KEY.
base_urlstringyesThe endpoint, for example http://localhost:11434/v1.
headersmap(string)noHeaders sent with every request, as the client’s default headers.
SettingTypeDefaultMeaning
temperaturenumber, 0 to 2Sampling temperature. Passed as ModelSettings.temperature.
max_tokensnumber, 1 or moreThe most tokens one response may produce. Passed as ModelSettings.max_tokens.

Tools: bash, read_file, write_file, edit_file.

Models: any name, passed to the endpoint unchanged.

Every agent also has the swarm tools, which are never listed in tools: list_topics, read_topic, publish, watch_topic, create_topic, list_agents, create_agent, stop_agent, report_progress, finish. create_agent is given only to agents with can_spawn = true.

Functions

concat, contains, distinct, env, file, fileexists, flatten, format, join, jsondecode, jsonencode, keys, length, lookup, lower, merge, replace, split, templatefile, tobool, tolist, tomap, tonumber, toset, tostring, trimspace, upper, values

file, fileexists, and templatefile take paths relative to the swarm folder. env fails when the variable is not set. toset turns a list into a set for for_each. agent.<name>[*].output lists every output of a count agent, and values(agent.<name>)[*].output every output of a for_each agent.

Prices

When max_cost_usd is set, every model needs a price: the provider’s price, else the price in its type’s model block. The built-in types’ prices, USD per million tokens:

TypeModelInputOutputCache readCache write
claude_agent_sdkclaude-fable-5-110500.2512.5
claude_agent_sdkclaude-opus-5-54200.25
claude_agent_sdkclaude-sonnet-5-52100.22.5
claude_agent_sdkclaude-haiku-5-50.10.50.010.125
claude_agent_sdkclaude-opus-55250.56.25
claude_agent_sdkclaude-sonnet-52100.22.5
openai_agentsgpt-6-astra1050112.5
openai_agentsgpt-6.1-sol2100.12.5
openai_agentsgpt-6.1-terra150.051.25
openai_agentsgpt-6-luna0.10.50.010.125

Any other model needs a price on its provider, such as price = { input = 0, output = 0 } for a local model.

Validation codes

convoy validate reports these. Errors stop convoy run; warnings are printed.

CodeSeverityRule
TS001errorExactly one swarm block.
TS002errorA required attribute is missing.
TS003errorAn attribute has the wrong type, or a constant attribute refers to something.
TS004errorAn agent or the swarm’s overseer has no model: it sets no model, and neither does its provider.
TS010errorA reference names a block or instance that does not exist. The message suggests the closest name.
TS011errorsource is neither a built-in type name nor a well-formed address; version is not a valid constraint or is set on a built-in type; both source and sdk are set, or neither; sdk is not one of the three built-in types.
TS012errorThe provider block does not match its type: a required attribute is missing (such as base_url for openai_compatible), an attribute the type does not define is set, or a value fails its type or its checks.
TS013errorA tools entry the provider’s type does not offer. The message lists the offered tools.
TS014errorAn env_name attribute, such as api_key, is not a literal environment variable name (for example, it calls env() or contains a key).
TS015errorAn agent is named overseer, which is reserved for the built-in overseer.
TS016errorThe provider type could not be resolved: no version meets the constraint, the repository was not found, the manifest is invalid, or its runner contract is not supported.
TS017warningThe provider type was not checked, because no server could be reached. When a cached manifest was used instead, the message names its version and age.
TS018errorsettings on a provider or an agent does not match the type’s settings: an unknown key, a wrong type, or a failed check.
TS019warningmodel is not in the type’s catalog, and the type does not set open_models. The message suggests the closest name.
TS020errorThe dependency graph (inputs and depends_on) has a cycle.
TS021errordone_when or an inputs value reads agent.X.output.<field> where X declares no output.
TS022errordone_when or an inputs value reads a field that is not in X’s output type.
TS023errordone_when or an inputs value references something other than an agent’s output.
TS030errorfor_each is a list, a set of non-strings, or not known before the swarm runs.
TS031erroreach is used in an agent without for_each.
TS032errorcount is not a whole number from 0 to 1000, or is not known before the swarm runs.
TS033errorcount.index is used in an agent without count.
TS034errorAn agent sets both count and for_each.
TS040errorA file() path does not exist, is outside the swarm folder, or is not UTF-8.
TS041errorA file(), templatefile(), fileexists(), or env() argument is not a constant string, so convoy run cannot bundle what it names.
TS042errorA variable named by env() is not set when convoy run builds the bundle.
TS050warningA topic that no agent writes to.
TS051warningA topic that no agent watches.
TS052warningAn agent with non-empty watches and no explicit max_turns.
TS053warningAn agent with no watches, no inputs, and no writes, whose output no inputs or done_when reads: its work reaches no one.
TS054warningA var in vars that the prompt never uses.
TS055warningAn agent with no watches, no output, and no explicit max_turns: it takes continue turns until it calls finish, so it should set its own limit.
TS060errormax_cost_usd is set and a model used by an agent or the declared overseer has no price: no price on its provider and none in its type’s model block.
TS061warningmax_cost_usd is not set; nothing limits the swarm’s spend.
TS062errormax_cost_usd is not a number greater than zero.
TS063errorprice is not an object with numeric input and output of 0 or more, or has keys other than input, output, cache_read, cache_write.
TS070warningA deprecated attribute, setting, or model of the provider’s type is used. The message carries the type’s deprecated text.

Manifest codes

convoy provider validate reports these for a provider type’s convoy-provider.hcl. All are errors.

CodeRule
PM001Exactly one provider block, whose label matches ^[a-z][a-z0-9_]*$.
PM002A required attribute is missing, an attribute or block type is unknown, a value has the wrong type, or the file does not parse.
PM010Not exactly one of driver and command.
PM011driver is not a built-in type, or tools lists a tool the built-in type does not offer.
PM012driver_config or driver_settings references an attribute or setting the manifest does not declare, or does not produce the built-in type’s attributes or settings.
PM013An attribute or block of the other kind: tool blocks, contracts, or inject_as in a preset; driver_config, driver_settings, or tools in a driver plugin.
PM020A duplicate or invalid name among attribute, setting, model, or tool blocks, or an attribute named like a core attribute (source, version, sdk, model, price, settings).
PM021An invalid type; a default or enum value that does not fit the type or its checks; pattern on a non-string or min/max on a non-number; an invalid pattern.
PM022env_name on a setting; an env_name attribute with no inject_as in a driver plugin; inject_as on another type or not a variable name; an env_name default that is not a variable name.
PM030A model price is malformed (the rule of TS063).
PM040contracts is missing, empty, or lists a number below 1; format is not supported.
PM041command is empty, or a {package} path in it leaves the package.
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