Skip to main content

What This Example Shows

  • A choice question that picks the swarm_type for a task
  • A /v1/swarm/completions run of three copywriter agents with that swarm type
  • A second choice question, whose options are the agent names, that picks the best draft from the swarm’s output
  • What each step cost in a live run on production

Why This Matters

A swarm gives you several outputs, and someone still has to choose the architecture before the run and the winner after it. Hard-coded rules get both wrong as tasks vary, and asking another LLM agent to choose costs as much as a swarm member and returns prose. A decision model makes each choice for about $0.00002 and returns probabilities you can log, compare and threshold.

Step 1: Setup

decide sends one decision completion and returns its answers.

Step 2: Pick the Swarm Type

Each option’s description tells the model when that architecture fits.

Step 3: Run the Swarm

Three copywriters with different styles each write a draft. The swarm’s output holds one {"role", "content"} message per agent, so drafts maps each agent’s name to its draft.

Step 4: Pick the Best Draft

The options are the agent names mapped to None, so the model compares the drafts in the state rather than option descriptions.

The Live Run

The script above, run on production with gpt-5-mini: Both decisions together cost about $0.00006, under 0.2% of the swarm run.

Other Decisions to Hand Off

The same choice and noul questions fit other points in a multi-agent pipeline:
  • Which specialist agent to call: a choice whose options are your agents’ names and descriptions, so only one agent runs instead of all of them.
  • Which model_name to use: a choice between a small and a large model, so hard tasks get the large model and easy ones stay cheap.
  • Whether the output needs another loop: a noul on the swarm’s output, such as “Does this fully meet the brief?”, before you run it again with feedback.

Next Steps