Skip to main content
Glama

beam

Run parallel candidate agents, score them with a cheap evaluator, and select the top result. Optimizes for best output under budget constraints.

Instructions

Sample N candidates in parallel, score each, commit to the top-1.

The simplest search combinator: proposes width candidates via par, scores each with a cheap haiku evaluator, and returns the highest-scoring ref. Losing candidates are preserved on the winner's search.alternatives field (unless keep_losers is false). This is self-consistency / majority-vote with arbitrary scoring — the same shape as the governor beam search, but applied to arbitrary agent output.

Evaluator forms:

  • score:<criterion> — direct haiku call, returns a float in [0, 1] plus a reason string. Use for rubric-style scoring.

  • validate:<type> — runs the type validator; VALID=1.0, PARTIAL=0.5, INVALID=0.0. Use when the acceptance criterion is a registered type.

Budget semantics: a hard cap on total proposer spend. If exceeded, the winner's search stamp records prune_reason="budget exhausted" but the result is still returned — best-effort rather than abort. Evaluator cost is not counted against budget for phase 1; evaluators are already constrained to haiku.

Anti-pattern: the Tree Search paper flags evaluator-as-expensive-as-proposer as a non-starter. This combinator hardcodes haiku for scoring — if you need a stronger evaluator, lift that logic into a governor instead.

Args: prompt: Task prompt sent to every candidate agent. width: Number of parallel candidates (default: 3). evaluator: Scoring directive. Must start with score: or validate:. sandbox: Named sandbox spec or inline JSON for candidate agents. model: Candidate agent model (default: sonnet — the proposer). timeout: Per-candidate timeout in seconds. mcps: JSON array of MCP server names attached to candidates. keep_losers: Preserve losing candidates on winner search stamp (default: true — useful for inspection + future step-lookahead). budget: Total USD cap on proposer cost. Best-so-far semantics on breach. max_concurrency: Upper bound on concurrent candidate agents.

Returns: JSON with run_id, winner ref (search-stamped), scores, and total_cost. If all candidates scored 0, error is populated.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes
widthNo
evaluatorNoscore:overall quality, rigour, and correctness
sandboxNo
modelNosonnet
timeoutNo
mcpsNo
keep_losersNo
budgetNo
max_concurrencyNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully discloses behavior: parallel execution, scoring, best-effort budget cap, preservation of losers, evaluator cost exclusion, and return format. It covers edge cases like budget exhaustion and all-zero scores, and explains the search stamp recording.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear lead sentence, bullet points, and sections. It is thorough but not overly verbose; every sentence adds value. Minor conciseness could be improved by merging some explanations, but overall it is efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given ten parameters, no schema description coverage, and an output schema that exists, the description covers all aspects: input semantics, behavioral quirks, return schema, error handling, and anti-patterns. It leaves no obvious gaps for an agent to understand when and how to invoke the tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate, and it does comprehensively. Every parameter is explained with context—e.g., evaluator must start with 'score:' or 'validate:', default values, and the effect of 'keep_losers' on preserving alternatives. This adds substantial meaning beyond the schema's basic type definitions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Sample N candidates in parallel, score each, commit to the top-1.' It clearly distinguishes from sibling tools like 'par' and 'race' by explaining it's a search combinator with scoring, comparing to self-consistency/majority-vote.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides explicit guidance on evaluator forms (score: vs validate:) and when to use each. It mentions an anti-pattern (expensive evaluator) and recommends using a governor instead. However, it does not explicitly contrast with all sibling tools like 'chain' or 'map', leaving some usage context implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/stiege/swarm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server