Examples / MVP

Research team

Three researchers search the web in parallel, a writer turns their findings into a briefing, and an editor sends it back until it scores 8 out of 10.

View .md

Three researchers search the web at the same time, one per option. When all three have finished, a writer turns their findings into a two-page briefing. An editor scores it and sends it back until it reaches 8 out of 10. The folder is examples/research_team.

Text
researcher["pgvector"] ─┐
researcher["qdrant"]   ─┼─inputs─> writer ──drafts──> editor
researcher["milvus"]   ─┘             ^──── review ─────┘
Fig. 1 Solid arrows into the writer are graph edges (inputs). The writer and the editor loop through the board.

The result is a sourced briefing, report.md, in the folder you ran convoy from. Measured runs took two to four minutes and cost about $0.46 on claude-sonnet-5-5 and $0.55 on gpt-6.1-sol, most of it spent by the three researchers.

Run it

With convoyd running:

Shell
cd examples/research_team
convoy run
convoy watch research_team      # or: convoy ui research_team

When the run ends, report.md is the briefing, and convoy status research_team shows what each agent did and what it cost.

The swarm file

main.cvy
# A research team. Researchers search the web at the same time, a writer turns
# what they found into a briefing, and an editor sends it back until it scores
# 8 out of 10.
#
#   researcher["pgvector"] ─┐
#   researcher["qdrant"]   ─┼─inputs─> writer ──drafts──> editor
#   researcher["milvus"]   ─┘             ^──── review ─────┘
#
# The briefing is saved as report.md in the folder you run convoy from.

swarm "research_team" {
  goal         = "A sourced two-page briefing: which open-source vector database should a five-person team pick: pgvector, Qdrant, or Milvus?"
  done_when    = agent.editor.output.score >= 8
  max_runtime  = "20m"
  max_cost_usd = 3
  overseer     = { provider = provider.llm, can_spawn = false }
}

# One API key is enough. With an OpenAI key, use the values in the comments.
provider "llm" {
  source = "claude_agent_sdk"  # "openai_agents"
  model  = "claude-sonnet-5-5" # "gpt-6.1-sol"
}

topic "drafts" { description = "Writer: a draft is saved. Its number and what changed since the last one" }
topic "review" { description = "Editor: the score and numbered fixes for the newest draft" }

# One researcher per option, all running at once. Add a line to add a researcher.
agent "researcher" {
  for_each = {
    pgvector = "pgvector, the Postgres extension"
    qdrant   = "Qdrant"
    milvus   = "Milvus"
  }
  provider  = provider.llm
  prompt    = file("prompts/researcher.md")
  vars      = { subject = each.value }
  tools     = ["web_search"]
  output    = { subject = string, summary = string, facts = list(string), sources = list(string) }
  max_turns = 4
}

# Starts when every researcher has finished, with their outputs as its input.
agent "writer" {
  provider  = provider.llm
  prompt    = file("prompts/writer.md")
  vars      = { report = "${env("PWD")}/report.md" }
  tools     = ["write_file"]
  inputs    = { research = values(agent.researcher)[*].output }
  writes    = [topic.drafts]
  watches   = [topic.review]
  max_turns = 6
}

agent "editor" {
  provider  = provider.llm
  prompt    = file("prompts/editor.md")
  vars      = { report = "${env("PWD")}/report.md" }
  tools     = ["read_file"]
  watches   = [topic.drafts]
  writes    = [topic.review]
  output    = { score = number, verdict = string }
  max_turns = 6
}

What it adds

  • for_each makes several agents from one block. The map has one entry per option, so there are three researchers, named researcher["pgvector"] and so on. each.value goes into the prompt through vars. Add a line to the map and there is a fourth. See agents.
  • inputs is the dependency graph. The writer’s inputs reads every researcher’s output, so the writer starts only when all of them have finished, and their outputs arrive as JSON in its first turn. Nobody wrote “wait for the researchers”.
  • output is typed. A researcher has to finish with a subject, a summary, a list of facts, and a list of sources. convoyd checks the payload against the declared shape, so the writer can rely on it.
  • tools are per agent. The researchers get web_search, the writer write_file, the editor read_file. The swarm tools (the board, finish, report_progress) are always there and are not listed.

done_when = agent.editor.output.score >= 8 is an ordinary expression over an agent’s output.

env("PWD") is the folder you ran convoy run from. That is how the writer and the editor agree on where report.md is.

Use an OpenAI key instead

Change the two lines of the provider block to the values in their comments:

HCL
provider "llm" {
  source = "openai_agents"
  model  = "gpt-6.1-sol"
}

The tool names are the same on both providers, so nothing else changes. convoyd needs OPENAI_API_KEY in its environment instead of ANTHROPIC_API_KEY.

Change it

  • A different question. Change the goal and the for_each map together: one entry per thing to research.
  • Mix models. Give the editor a stronger model with model = "claude-opus-5-5" in its block, or add a second provider block and put the researchers on it. A swarm can mix providers freely.
  • Steer it. convoy say research_team review "Weigh operational cost more heavily" --to writer.

Next: the code team adds a worker pool, addressed messages, and a done_when backed by a test suite.

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