DSL / MVP

Language rules

The rules of the Convoy language that apply to every block, including file merging, names, value types, durations, strings, and comments.

View .md

A swarm is written in HCL, the syntax Terraform uses, in files that end in .cvy. There are four block types: swarm, provider, topic, and agent. This page covers what is true of the whole language. Each block has its own page, References and functions covers expressions, and Validation rules lists every error and warning.

The language follows Terraform where Terraform has a rule and adds agent-specific rules where it does not.

Files and merging

convoy validate and convoy run read every *.cvy file in the swarm folder and merge them into one configuration.

  • Block order and file boundaries do not matter. A reference can point at a block in another file.
  • Exactly one swarm block must exist across all files.
  • Files whose names start with . or #, or end with ~, are ignored (editor temp files).
  • A folder with no .cvy files is an error: No .cvy files found in <dir>.
  • A syntax error in one file is reported, and the other files are still parsed, so one bad file does not hide errors in the rest.
  • Top-level attributes are not allowed. Only blocks.
  • Prompt files live in prompts/ by convention. They are plain text, read with file(), and are not part of the HCL.

Typical layouts: one main.cvy, or a split like the Vending-Bench example, which uses main.cvy, providers.cvy, and topics.cvy.

Text
my-swarm/
  main.cvy
  providers.cvy
  topics.cvy
  prompts/
    research.md
    writer.md

Blocks

A block is a type, one label, and a body:

HCL
agent "writer" {
  # attributes
}

The label is the block’s name. Every block type takes exactly one label, including swarm, where it is the swarm’s name.

Names must match [A-Za-z_][A-Za-z0-9_]*: letters, digits, and underscores, not starting with a digit. A name must be unique within its type across all files. Two blocks of different types may share a name: topic "review" and agent "review" are allowed, and references tell them apart (topic.review, agent.review).

An unknown block type is an error with a suggestion (Unsupported block type "agnet". Did you mean "agent"?). So is an unknown attribute inside a block: attributes are checked against a fixed schema, and a misspelling gets a suggestion too.

Attributes

An attribute is name = expression. Convoy distinguishes three kinds, by when the expression is evaluated:

KindExamplesEvaluatedMay reference
Staticgoal, max_runtime, model, tools, settings, max_turns, source, version, api_key and every other provider attributeOnce, on your machine and again on the server, when the file is loadedNothing, only constants and functions
Per-instanceprompt, varsOnce per agent instance, during count or for_each expansioncount.index, or each.key and each.value
Reference or lateprovider, writes, watches, depends_on, inputs, done_when, overseer.providerReferences are checked at load. inputs and done_when are evaluated by the server as agents finishprovider., topic., agent.

A static attribute that contains a reference fails with This attribute must be a constant value. The full list of which attribute is which is on References and functions.

Value types

TypeWritten asUsed by
string"text" or a heredocgoal, model, prompt, description
number60, 0.5max_cost_usd, max_turns, price
booltrue, falsecan_spawn, done_when
list["bash", "web_search"]tools, writes, watches, depends_on
settoset(["a", "b"])for_each
map{ vendor = "nvidia" }vars, inputs, for_each
object{ provider = provider.anthropic, model = "x" }overseer, price

Maps and objects both use { key = value }. Keys that are valid identifiers need no quotes. Commas between entries are optional when entries are on separate lines.

Durations

A duration is a string with a unit: "30s", "10m", "4h", "168h". Units are s, m, and h, and they may be combined ("1h30m"). A bare number (max_runtime = 3600) or another unit ("2d") is an error at the attribute. Only max_runtime is a duration today.

Strings and interpolation

Strings are double-quoted. "${expr}" interpolates any expression into the string:

HCL
vars = { me = "implementer[${count.index}]" }

Multi-line strings use a heredoc. <<-EOT strips common leading indentation:

HCL
goal = <<-EOT
  Raise pass^4 of the airline agent by improving its playbook on the
  train split, then prove the gain on the held-out split.
EOT

Prompt files are not interpolated. file("prompts/x.md") returns the text unchanged, which is why ${...} in a prompt file stays literal. To put per-instance values into a prompt, set vars on the agent and write {{name}} in the file. See Prompt variables.

Comments

HCL
# a line comment
// also a line comment
/* a block
   comment */

Reserved names in expressions

Five roots can start a reference: provider, topic, agent, and, inside the agents that declare them, count and each. Using each anywhere else is TS031, and count.index is TS033. The other names, such as var or local, do not exist: Convoy has no variables, locals, or modules. To parameterize a swarm, use env() and vars.

Why HCL

HCL gives Convoy a syntax that people already read, a parser with precise source ranges for error messages, an expression language with references, and count and for_each. The model that writes a swarm for you (convoy goal) has seen a great deal of Terraform, and the same discipline carries over: declare the shape, let references define the graph, and let a tool check the whole thing before anything runs. Convoy uses hashicorp/hcl/v2 directly and borrows OpenTofu’s diagnostics, DAG, and function code.

A complete annotated example

This is the edge_chips swarm. Four researchers gather facts in parallel. When all four finish, a writer drafts the report. A critic reviews each draft and sends feedback through the board. The writer revises. The swarm ends when the critic approves.

main.cvy
swarm "edge_chips" {
  goal         = "Ship a sourced 10-page market report on edge inference chips"
  done_when    = agent.critic.output.approved == true    # late: server evaluates
  max_runtime  = "4h"                                    # duration string
  max_cost_usd = 60                                      # dollars, whole run
  overseer     = { provider = provider.anthropic, model = "claude-sonnet-5" }
}

provider "anthropic" {
  source  = "claude_agent_sdk"
  api_key = "ANTHROPIC_API_KEY"   # name of a variable in convoyd's environment
}

provider "openai" {
  source  = "openai_agents"
  api_key = "OPENAI_API_KEY"
}

topic "findings" { description = "One sourced fact per message, with URL" }
topic "drafts"   { description = "Report drafts, newest wins" }
topic "review"   { description = "Critic feedback on drafts" }
topic "human"    { description = "Questions that need a person" }

agent "researcher" {
  for_each  = toset(["nvidia", "groq", "cerebras", "tenstorrent"])  # 4 instances
  provider  = provider.anthropic
  model     = "claude-sonnet-5"
  prompt    = file("prompts/research.md")
  vars      = { vendor = each.key }       # fills {{vendor}} in the prompt
  tools     = ["web_search", "bash"]      # claude_agent_sdk built-ins
  writes    = [topic.findings]
  max_turns = 40
}

agent "writer" {
  provider = provider.openai
  model    = "gpt-6.1-sol"
  prompt   = file("prompts/writer.md")
  inputs   = { findings = values(agent.researcher)[*].output }  # graph edge
  writes   = [topic.drafts]
  watches  = [topic.review]                                     # not an edge
}

agent "critic" {
  provider = provider.anthropic
  model    = "claude-opus-5"
  prompt   = file("prompts/critic.md")
  watches  = [topic.drafts]
  writes   = [topic.review]
  output   = { approved = bool, score = number }  # typed finish payload
}

The dependency graph here has one set of edges: each researcher to the writer. The writer and critic loop through the board, and the board is not part of the graph. See References and functions.

Block reference

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