Skip to main content
Glama

execute_subtask

Execute AI prompts using the cheapest provider with automatic fallback. Supports file creation, surgical edits, and convergence retries.

Instructions

Execute a prompt via the cheapest available AI CLI provider.

Routes to the cheapest model for the given tier across all installed CLI tools (GitHub Copilot, Codex, Cursor, and others). Falls back to next cheapest on failure.

When target_file is provided, writes the result directly to that path and returns file metadata. This is the preferred way to create files for low-tier subtasks — saves tokens by avoiding round-trip through the main agent.

Surgical edit modes (set mode=): rewrite (full-file injection + length-ratio guard), blocks (Aider-style SEARCH/REPLACE, token-efficient), patch (unified diff).

Returns:

  • result: the model's response text

  • provider: which CLI tool was used

  • model: which model handled it

  • tier: the tier that was requested

  • fallback_used: whether a fallback provider was needed

  • file_written: path written to (when target_file is set)

  • lines_written: line count of written file

  • diff: unified diff showing changes (when target_file is set)

  • change_type: 'created', 'modified', or 'unchanged'

  • lines_added: number of lines added

  • lines_removed: number of lines removed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNoWrite mode for target_file edits: 'write' (default) — model output written verbatim. Safe for new files. 'rewrite' — injects current file, asks for complete rewrite with length-ratio guard (rejects if output < 50% of original). Max file size: 32 KiB. 'blocks' — Aider-style SEARCH/REPLACE blocks. Token-efficient surgical edits. Max file size: 128 KiB. 'patch' — provider returns unified diff applied with patch semantics.
tierNoComplexity tier: low, medium, or high (default: low)
effortNoOptional reasoning effort hint. When supported by the selected provider, this is passed through to execution.
promptYesThe prompt to send to the model
task_idNoOptional caller-supplied task identifier used for inspection and telemetry correlation.
timeoutNoTimeout in seconds (default: per-tier from config, max: 600)
wave_idNoOptional wave identifier. Subtasks sharing the same wave_id are shown as a parallel group in list_subtasks. Use the same value for all execute_subtask calls dispatched simultaneously (e.g. 'wave-1', 'wave-2').
prefer_freeNoPrefer free-tier providers (default: true)
provider_idNoOptional exact provider identifier, such as 'codex'. When set, execution is restricted to that provider.
target_fileNoAbsolute path to write the result to. When set, the model's output is written directly to this file. Parent directories are created automatically. Ideal for low-tier file generation.
convergence_targetNoOptional quality convergence policy (plan 14). Re-executes until gate score meets min_score or max_rounds is exhausted. Each round appends prior output to the prompt.
allow_out_of_workspaceNoAllow writing target_file to a path outside the workspace root. Every grant is logged. Explicit per-call opt-in.
Behavior5/5

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

No annotations are provided, so the description carries the full burden. It thoroughly explains the routing mechanism (cheapest provider, fallback), file writing behavior (automatic parent directory creation), edit modes (rewrite with length-ratio guard, blocks, patch), and convergence policy. This gives a complete picture of the tool's behavior.

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, starting with the main purpose, then detailing routing, file writing, edit modes, and return fields. It is informative but slightly verbose; some sentences could be tightened without losing clarity.

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 the tool's complexity (12 parameters, nested objects), the description covers all major aspects: routing, file output, edit modes, convergence, and return values. No output schema exists, but the description lists all return fields. This is comprehensive for effective use.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds value by explaining the rationale for target_file (saves tokens) and providing context for modes, but this largely repeats the schema descriptions. Hence, marginal additional value.

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 clearly identifies the tool's core function: executing prompts via the cheapest AI CLI provider. It distinguishes itself from sibling tools by focusing on cost-optimized execution and direct file output, which is unique among the listed tools.

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?

The description provides context on when to use the tool, such as being the preferred way to create files for low-tier subtasks to save tokens. It also explains different modes for file edits. However, it lacks explicit guidance on when not to use it or alternative tools for specific scenarios.

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/timjensgrossinger/threnody'

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