Skip to main content
Glama

batch_run

Run multiple prompts in parallel through auto-selected models with bounded concurrency and automatic retry, enabling batch translation, data extraction, classification, and content generation.

Instructions

Run multiple prompts in parallel with bounded concurrency and auto-retry.

For batch workloads: translation pipelines, data extraction, classification, content generation. Picks the fastest model and runs all prompts through it. Failed items are automatically retried on alternate models.

Each prompt dict should have a "prompt" key and optional "system_prompt" (overrides the top-level system_prompt) and "metadata" keys for tracking.

When results_file is set, each completed item is appended as a JSON line immediately. If interrupted, the file contains all completed items and can be resumed (already-completed indices are skipped).

Args: prompts: List of {"prompt": "...", "system_prompt": "...", "metadata": {...}} system_prompt: Default system prompt for all items (per-item overrides) model_id: Specific model to use (skips scanning). Use list_models() to browse. provider: Limit to a specific provider min_tier: Minimum quality tier when auto-selecting (default "A") free_only: If true, only use free models max_tokens: Max response tokens per item (default 4096) temperature: Sampling temperature (default 0.0) concurrency: Max parallel requests (default 5) retry_on_fail: Auto-retry failed items on alternate models (default true) results_file: Path to JSONL file for incremental writes and resume support

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "prompts": "<prompts>"
    },
    "name": "batch_run"
  }
}

Input Schema

NameRequiredDescriptionDefault
promptsYes
min_tierNoA
model_idNo
providerNo
free_onlyNo
max_tokensNo
concurrencyNo
temperatureNo
results_fileNo
retry_on_failNo
system_promptNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.15.1
    • addedInput schema / additionalProperties
      Added value: +false
  2. First observedv0.7.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does substantial work: it discloses automatic fastest-model selection, retry-on-failure across alternate models, incremental JSONL appends, and resume semantics where already-completed indices are skipped. It omits what happens to an item that fails all retries, whether partial results are returned, and any cost or rate-limit implications of running prompts in parallel.

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?

Well front-loaded: purpose and workloads come first, item shape second, resume behavior third, parameter detail last. The Args block is long but earns its place because the schema has zero descriptions; the cost is some redundancy with parameter names already visible in the schema.

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

Completeness4/5

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

For an 11-parameter batch tool with an output schema (so return values need not be explained) and no annotations, the description covers selection, retry, concurrency, and persistence adequately. The main omission is failure semantics for items that exhaust retries, which matters for an agent interpreting partial batch results.

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

Parameters4/5

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

Schema coverage is 0% (bare titles and defaults only), so the description must compensate, and the Args block documents nearly every one of the 11 parameters with meaning and defaults, plus the accepted keys of each prompt dict. The gaps are real: no valid values are given for `min_tier` or `provider`, and there is no enum to fall back on.

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

Purpose4/5

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

The opening sentence gives a specific verb plus three distinct behavioral traits (parallel execution, bounded concurrency, auto-retry), and the second sentence names concrete workload types. It does not explicitly contrast with the sibling `run` (single-prompt) or `batch_judge`, so the boundary between batch and single execution is left to inference.

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?

"For batch workloads" plus four enumerated use cases gives a clear condition for reaching for this tool, and "Use list_models() to browse" points at the right companion tool for model selection. It never states when to prefer `run` or `batch_judge` instead, and gives no guidance on choosing a concurrency value or when to set `results_file`.

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