# Validation rules

> Every error and warning that convoy validate reports, with its diagnostic code, an example, and how to fix it.

`convoy validate` loads the swarm folder and runs every rule below. It needs no server, unless a provider names a type that is not built in: then it asks convoyd for that type's schema (see [Provider types](/docs/providers/)). `convoy run` runs the same checks first, and the server runs them again when it receives the swarm, so a folder that validates on your laptop validates on the server.

- **Errors** stop `convoy run`.
- **Warnings** are printed and do not stop it.

Each stage keeps going when an earlier one found errors, as far as it has enough to work with, so one run reports as many problems as possible.

## Reading a diagnostic

The CLI prints one line per diagnostic in `file:line: message` form, with the code at the end:

```console
$ convoy validate
main.cvy:27: error: Unknown tool "web_serach" (TS013)
main.cvy:31: warning: agent "writer" watches topics and keeps the default max_turns (50) (TS052)
```

The full rendering, which `convoy validate` prints when it has room, adds the source line and detail:

```text
Error: Unknown tool "web_serach" (TS013)

  on main.cvy line 27, in agent "researcher":
  27:   tools     = ["web_serach", "bash"]

Provider "anthropic" uses claude_agent_sdk, which offers: web_search, bash,
read_file, write_file, edit_file. Did you mean "web_search"?
```

With `--json`, every diagnostic includes its code as a field. Codes are stable; the exact message wording in the examples below can change. The `convoy goal` retry loop and the tests match on them. Misspelled names get a suggestion when a known name is within edit distance 3.

## Errors from the parser

These come from reading the files, before any rule runs. Most have no code.

| Message | Cause | Fix |
| --- | --- | --- |
| `No .cvy files found in <dir>` | The folder has no `.cvy` files | Run in the right folder, or add a `main.cvy` |
| HCL syntax error | A file does not parse | Fix the syntax at the line shown; other files are still checked |
| `Unsupported block type "agnet". Did you mean "agent"?` | A top-level block that is not `swarm`, `provider`, `topic`, or `agent` | Use one of the four |
| `Unsupported argument` at top level | An attribute outside any block | Move it into a block |
| Invalid label | A name that is not letters, digits, and underscores | Rename the block |
| `Duplicate agent "writer"`, with the file and line of the first | Two blocks of one type share a name, even across files | Rename one |
| `An argument named "modle" is not expected here. Did you mean "model"?` | An attribute that is not in the block's schema | Fix the spelling or remove it |
| `This attribute must be a constant value` | A static attribute contains a reference | Use a literal, or `env()` |
| `Expected a reference like provider.<name>` | `provider = "anthropic"` instead of `provider = provider.anthropic` | Remove the quotes and add the prefix |
| `output must be an object type` | `output = string` or a collection at top level | Wrap in an object: `output = { value = string }` |
| `for_each requires a set or map; wrap the value in toset()` | `for_each = ["a", "b"]` | Use `toset([...])` (this is [TS030](#ts030)) |
| `env("NAME") is not set` | A variable that `env()` reads is missing on your machine | Export it before `convoy run` |
| Invalid duration | `max_runtime = 3600` or a unit other than `s`, `m`, `h` | Use `"1h"` |

## Errors and warnings by code

### TS001

**Error. Exactly one `swarm` block.**

```text
main.cvy:1: error: A swarm block is required (TS001)
main.cvy:40: error: Only one swarm block is allowed; the first is at main.cvy:1 (TS001)
```

Fix: declare one `swarm` block in exactly one file. Check other `.cvy` files in the folder, since all are merged.

### TS002

**Error. A required attribute is missing.**

```text
main.cvy:12: error: Missing required argument "prompt" (TS002)
```

Fix: add it. Required attributes: `swarm` needs `goal`, `done_when`, `max_runtime`. `provider` needs `sdk`. `topic` needs `description`. `agent` needs `provider` and `prompt`. Within `overseer`: `provider`. Within `price`: `input` and `output`. A missing `model` is [TS004](#ts004), because a provider can supply it.

### TS003

**Error. An attribute has the wrong type.**

```text
main.cvy:9: error: Incorrect type for "max_turns": a number is required (TS003)
```

Fix: use the type shown in the block's table. Common causes: a quoted number, a list where a map is expected, or `tools = "bash"` instead of `["bash"]`.

### TS004

**Error. An agent or the overseer has no model.** It sets no `model`, and neither does its provider.

```text
main.cvy:18: error: Missing model (TS004)
main.cvy:6: error: Missing overseer model (TS004)
```

```text
Agent "writer" sets no model, and neither does its provider "anthropic". Set
model on the agent, or on the provider as the default for its agents.
```

An agent runs on its own `model`, else on its provider's [`model`](/docs/dsl/provider/#model). The swarm's `overseer` object follows the same rule. Fix: set `model` on the agent (or inside `overseer = { ... }`), or set it once on the provider block so every agent on that provider takes it.

### TS010

**Error. A reference to a block that does not exist.**

```text
main.cvy:44: error: Reference to undeclared topic "reveiw". Did you mean "review"? (TS010)
```

Applies to `provider`, `overseer.provider`, `writes`, `watches`, `depends_on`, and agents inside `inputs`. Fix: correct the name or declare the block.

### TS011

**Error. The provider's type is not named correctly.** `source` is neither a built-in type 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; or `sdk` is not one of the three built-in types.

```text
providers.cvy:2: error: Unknown provider type "claude" (TS011)
```

Fix: use `claude_agent_sdk`, `openai_agents`, `openai_compatible`, or an address such as `acme/acme`. A misspelled built-in name gets a suggestion. Remove `version` from a built-in type; write a constraint such as `"~> 1.4"` for any other.

### TS012

**Error. The provider block does not match its type.** A required attribute is missing, an attribute the type does not define is set, or a value fails its type or its checks.

```text
providers.cvy:14: error: Missing base_url (TS012)
providers.cvy:3: error: Unsupported provider attribute (TS012)
```

The message lists the type's attributes. Fix: add `base_url = "http://localhost:11434/v1"` to an `openai_compatible` provider, remove an attribute its type does not define (`base_url` on `claude_agent_sdk`, for example), or fix the value. `convoy provider show <source>` prints a type's attributes.

### TS013

**Error. A `tools` entry the provider's type does not offer.** The message lists the offered tools.

```text
main.cvy:27: error: Unknown tool "web_serach" (TS013)
```

Fix: use a tool the type offers (see the [built-in types](/docs/dsl/provider/#built-in-types), or `convoy provider show <source>`). `openai_compatible` offers the four local tools (`bash`, `read_file`, `write_file`, `edit_file`) and no hosted ones, so remove `web_search` from those agents.

### TS014

**Error. An `env_name` attribute, such as `api_key`, is not a literal environment variable name.**

```text
providers.cvy:3: error: Invalid api_key (TS014)
```

Fix: write the variable name, matching `^[A-Z_][A-Z0-9_]*$`, for example `"ANTHROPIC_API_KEY"`. Set the real key in convoyd's environment.

### TS015

**Error. An agent is named `overseer`.** The name is reserved for the built-in overseer.

Fix: rename the agent, and configure the overseer with the swarm's `overseer` attribute.

### TS016

**Error. The provider type could not be resolved.** The detail is the server's reason: no version meets the constraint, the repository was not found, the manifest is invalid, or its runner contract is not supported.

```text
providers.cvy:8: error: Provider type not found (TS016)
```

Fix: check the address and the constraint. `convoy provider pull <source>` shows what the server finds; the repository must be `convoy-provider-<name>` with tags such as `v1.4.2`.

### TS017

**Warning. The provider type was not checked, because no server could be reached.** When a manifest cached by an earlier `convoy validate` was used instead, the message names its version and age, and the swarm was checked against it.

```text
providers.cvy:8: warning: Provider type not checked (TS017)
```

Without a cached manifest, that provider's attributes, and the `tools`, `settings`, and `model` of its agents, are not checked. `convoy run` checks them on the server regardless. Fix: start convoyd, or pass `--server`.

### TS018

**Error. `settings` does not match the type's settings.** An unknown key, a wrong type, or a failed check, on a provider or an agent.

```text
main.cvy:16: error: Invalid setting (TS018)
```

Fix: use a setting the type defines, with a value it accepts. The [built-in types](/docs/dsl/provider/#built-in-types) list theirs.

### TS019

**Warning. `model` is not in the type's catalog**, and the type does not accept other names. The message suggests the closest name.

```text
main.cvy:12: warning: Model "acme-large-2" is not in the catalog (TS019)
```

The model is passed through unchanged, so a model that launched before its provider published a new version still runs. The built-in types accept any model name and never warn. A model that agents take from their provider's [`model`](/docs/dsl/provider/#model) is reported once, on the provider's line. Fix: correct a typo, or pull a newer version of the type.

### TS020

**Error. A dependency cycle.**

```text
main.cvy:61: error: Dependency cycle: writer -> critic -> writer (TS020)
```

The diagnostic lists the instance names in order and points at the `inputs` or `depends_on` of the first one. Fix: remove one edge. If two agents need to exchange work repeatedly, use topics (`writes` and `watches`), which are not edges.

### TS021

**Error. A field of an output is read, but the agent declares no `output`.**

```text
main.cvy:8: error: agent "critic" declares no output, so "approved" cannot be read (TS021)
```

Applies to `done_when` and `inputs` reads such as `agent.critic.output.approved`. Fix: add `output = { approved = bool }` to the agent.

### TS022

**Error. The field is not in the agent's `output`.**

```text
main.cvy:8: error: output of agent "critic" has no field "aprroved" (TS022)
```

Fix: correct the field name, or add it to the `output` type.

### TS023

**Error. `done_when` references something other than `agent.*.output`.**

```text
main.cvy:5: error: done_when may only reference agent outputs (TS023)
```

Fix: rewrite the condition in terms of `agent.<name>.output.<field>`. To depend on a topic or other state, have an agent watch the topic and report the result in its `output`.

### TS030

**Error. `for_each` is a list or a non-string set.**

```text
main.cvy:3: error: for_each requires a set or map; wrap the value in toset() (TS030)
```

Fix: `for_each = toset(["a", "b"])`, or use a map.

### TS031

**Error. `each` used in an agent without `for_each`.**

```text
main.cvy:15: error: each is only available in an agent with for_each (TS031)
```

Fix: add `for_each`, or replace `each.key` with a literal. `each` is available only in `prompt` and `vars`. In a `count` agent, use `count.index`.

### TS032

**Error. `count` is not a whole number from 0 to 1000, or is not known before the swarm runs.**

```text
main.cvy:16: error: count must be a whole number, 0 or more; got 2.5. (TS032)
```

Fix: use a whole number. `count` may call functions, such as `length(...)`, but may not refer to an agent, a topic, or a provider.

### TS033

**Error. `count.index` used in an agent without `count`.**

```text
main.cvy:16: error: Agent "writer" has no count, so count.index does not exist. (TS033)
```

Fix: add `count`, or in a `for_each` agent use `each.key`.

### TS034

**Error. An agent sets both `count` and `for_each`.**

```text
main.cvy:16: error: Agent "writer" sets both count and for_each. (TS034)
```

Fix: keep one. Use `count` for identical agents and `for_each` when each one gets its own input.

### TS040

**Error. A `file()` path does not exist.**

```text
main.cvy:6: error: Invalid function argument: no file exists at prompts/critic.md (TS040)
```

Fix: create the file, or correct the path. Paths are relative to the swarm folder.

### TS050

**Warning. A topic that no agent writes to.**

```text
topics.cvy:3: warning: topic "review" is never written to (TS050)
```

Nothing publishes to it, so any agent that watches it can never wake. Fix: add the topic to an agent's `writes`, or delete the topic. A topic that only people write to, through `convoy say`, can ignore this.

### TS051

**Warning. A topic that no agent watches.**

```text
topics.cvy:2: warning: topic "drafts" is never watched (TS051)
```

Messages on it wake nobody. Agents can still read it with `read_topic`. Fix: add it to an agent's `watches` if someone should react, or ignore the warning when the topic is a log that agents read on demand.

### TS052

**Warning. Non-empty `watches` and no explicit `max_turns`.**

```text
main.cvy:31: warning: agent "writer" watches topics and keeps the default max_turns (50) (TS052)
```

A long-lived agent that wakes on every message can burn through turns. Fix: set `max_turns` deliberately.

### TS053

**Warning. No `watches`, no `inputs`, and no `writes`, and nothing reads its `output`.**

```text
main.cvy:20: warning: agent "solo" has no watches, no inputs, and no writes, and nothing reads its output, so its work reaches no one (TS053)
```

An agent whose `output` is read by another agent's `inputs` or by `done_when` does not get this warning: its `finish` payload is how its work travels, as with a pool of researchers that feed a writer.

Fix: add `writes` if it should talk to others, read its output from `inputs` or `done_when`, or ignore this for a solo agent whose work is its side effects.

### TS054

**Warning. A var in `vars` that the prompt never uses.**

```text
main.cvy:24: warning: var "vendor" is not used in the prompt (TS054)
```

Fix: add `{{vendor}}` to the prompt file, or remove the var.

### TS055

**Warning. No `watches`, no `output`, and no explicit `max_turns`.**

```text
main.cvy:18: warning: agent "worker" takes continue turns until it calls finish; set max_turns (TS055)
```

An agent with empty `watches` takes a continue turn after every turn that does not finish, until it calls `finish` or reaches `max_turns`. Fix: set `max_turns`.

### TS060

**Error. `max_cost_usd` is set and a model has no price.** Applies to every agent's model and to the overseer's, when declared, whether the model is written on the agent or taken from its provider's [`model`](/docs/dsl/provider/#model).

```text
main.cvy:7: error: No price for model "qwen3:32b" (TS060)
```

A model's price is its provider's `price`, else the price in its type's model catalog. The message lists the models the type prices. Fix: use a priced model, or add a `price` to the provider, for example `price = { input = 0, output = 0 }` for a local model. `openai_compatible` prices no models, so its providers need a `price` whenever `max_cost_usd` is set. If the overseer comes from convoyd's flags, the server runs this check on `PUT` and rejects the run with `unpriced_model`.

### TS061

**Warning. `max_cost_usd` is not set.**

```text
main.cvy:1: warning: max_cost_usd is not set; only max_runtime bounds this run (TS061)
```

Fix: set `max_cost_usd` on the swarm.

### TS062

**Error. `max_cost_usd` is not a number greater than zero.**

```text
main.cvy:5: error: max_cost_usd must be a number greater than zero (TS062)
```

Fix: use a positive number such as `60`.

### TS063

**Error. `price` is malformed.** It must be an object with numeric `input` and `output` of zero or greater, and may have only the keys `input`, `output`, `cache_read`, and `cache_write`.

```text
providers.cvy:9: error: price must be an object with numeric input and output (TS063)
```

Fix: `price = { input = 3, output = 15 }`.

### TS070

**Warning. A deprecated attribute, setting, or model of the provider's type is used.** The message carries the type's own text, such as a retirement date and a replacement.

```text
main.cvy:12: warning: Deprecated model "acme-small-1" (TS070)
```

Fix: move to what the message names before the provider retires it.

## Other warnings

Expansion also warns, without a code, when `count = 0` or a `for_each` set is empty, so the agent has zero instances.

## Checked by the server instead

Some checks cannot happen on your machine because they depend on how convoyd was started:

| Check | Where | Result |
| --- | --- | --- |
| No overseer in the file and none in convoyd's flags | `PUT` | HTTP 422, `overseer_missing` |
| A variable a provider reads, such as `ANTHROPIC_API_KEY`, is not set in convoyd's environment | `PUT` | HTTP 422, `missing_env` |
| A driver plugin fails its check | `PUT` | HTTP 422, `provider_check_failed` |
| Overseer from flags has no price and `max_cost_usd` is set | `PUT` | HTTP 422, `unpriced_model` |
| Bundle format version unsupported | `PUT` | Rejected before parsing |

The server also re-runs every rule above and returns the rendered diagnostics in the response body.
