Skip to main content
Glama

pi_execute

Dispatch sub-tasks to another model and verify completion by running a command; returns exit-code-backed evidence and automatically retries with stronger models on failure.

Instructions

把子任务派给另一个模型跑,用命令行验收兜底。 你(主会话)负责指挥,它负责干活;干完用退出码证明做没做成,而不是听它自述。

【核心能力】 · 省 token — 子任务读文件/跑命令的消耗不算在你的上下文里。只传文件路径,让它自己读。 · 验收兜底 — 给一条 verify 命令,系统真跑一次,退出码 0 才算完成。零 token 成本。 · 证据链 — 任务前后拍文件快照,如实报告实际改了什么,不听模型自述。 · 返工升档 — 验收不过时自动换更强的模型重试(弱模型打头阵,强模型兜底保成)。 · 程序级约束 — explore 模式在进程层面禁用 write/edit;scope 越界改动直接判失败。

【两种模式(重要)】 · 同步(默认) — 发出后等整条验收链跑完才返回(云端任务通常 1–3 分钟)。 适用:拿到结果才能往下做(例:先跑测试,看结果决定下一步)。 · 异步(async=true) — 200ms 返回 taskId,你立刻能继续干自己的活。 适用:想同时推两件事、或派完就走。之后用 pi_result(taskId) 取结果。 例:pi_execute(task="…", verify="npm test", async=true) → 拿 taskId → 干自己的活 → pi_result 收结果

【何时用】 · 批量文本处理、代码审查、跑测试/构建、日志分析、批量改代码 · 一件事你自己做要读很多文件/跑很多命令 —— 派出去更省 context · 想同时推进两件独立的事 —— 用 async=true 真并行

【何时不用】 · 简单问答、几秒能做完的小事 —— 直接做更快 · 需要精确控制每一步的关键改动 —— 自己做更稳

【前置条件】 · 本地模型:推理引擎必须已由用户手动启动(本工具不会替你拉进程)。 返回 unreachable 说明端点没起来 —— 先启动它,不要反复重试。 · 云端/网关模型:端点可达即可(通常无需额外启动)。

【强烈建议带 verify】 模型(尤其量化小模型)会说『我做完了』但工具可能没真执行。 只有验收命令跑出退出码 0 才是唯一可信的完成信号。 ⚠️ 验收命令要设计成无法取巧:别用『检查某文件是否存在』(模型会直接创建它), 优先用『跑测试』『校验产物内容』『断言功能正确』这类。

【示例】 pi_execute(task="给 src/utils.ts 补空值检查", verify="npm test") pi_execute(task="分析 logs/ 里的报错", mode="explore") // 只读,绝不改文件 pi_execute(task="重构认证模块", scope="src/auth/", rework=1) // 验收不过自动升档重试 pi_execute(task="调研 CRDT 方案", async=true) // 派完就走,稍后 pi_result 取

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": {
      "task": "<task>"
    },
    "name": "pi_execute"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNoimplement=可写(默认)。explore=只读:write/edit 在**进程层面**被禁用,模型物理上写不了任何文件。只要分析/调研/理解代码就用 explore,绝不会误改文件。
taskYes任务描述。说清三件事:要做什么、改哪些文件、做到什么程度算完成。
asyncNotrue = 异步派发:毫秒级返回 taskId,不阻塞你,执行/验收/返工/升档全部在后台照常跑;之后用 pi_result(taskId) 取完整结果。适合『派完就继续干自己的活』或一次派多个任务。默认 false(同步等结果,与旧行为一致)。
filesNo相关文件路径。**只传路径,不传内容**——模型会自己去读,别把代码塞进来。
modelNo不填 = 自动按任务类型路由到默认模型(见配置的 routing 表)。 本地(占显存,串行排队):bonsai / ornith35b / ornith9b / kat  · 主力模型最聪明也最慢;快速模型起步快但能力弱 云端/网关(不占本地显存,可与本地真并行):cloud_best / cloud_chat / cloud_fast / cloud_long  · 只在『要快出结果』或『本地引擎没启动』时用 任务类型关键词(也可直接填,自动路由):coding / analysis / research / review / quick / text / stable / cloud / cloud_fast / cloud_long / cloud_best
scopeNo限定可改动的路径,如 ["src/auth/"]。改了范围外的文件会被判失败。改动范围明确时务必填,能防模型乱改。
reworkNo验收不通过时自动把『命令的实际报错输出』打回给模型重试几次(0-3,默认 0)。默认每轮返工自动**升档**到更强的模型(如 ornith9b→ornith35b→bonsai→cloud_best);1 意味着最多跑两轮、时间翻倍。任务简单时保持 0。
verifyNo验收命令——**最重要的参数**。派活后系统会真实执行一次,退出码 0 才算完成。 Windows 示例:"npm test"、"if exist out.json (exit 0) else (exit 1)" 不填 = 不验收,等于只能相信模型自述(本地模型会假完成,建议尽量填)。
workdirNo工作目录,模型的所有文件操作都在这里发生。默认当前项目根。相对路径以此为基准。
escalateNo返工是否升档(默认 true)。true = 验收不过时下一轮换更强的模型重试;false = 原地用同一个模型重试(旧行为)。仅在 rework>0 时有意义。
timeoutMsNo超时毫秒,默认 600000(10 分钟)。本地 27B 慢:改一个文件约 80–190 秒,跑大型重构可能要几分钟,默认值够用;只有跑超大任务时才需要调大。
constraintsNo额外约束:技术栈、代码风格、明确禁止做的事。
includeContextNo是否把项目状态简报(SessionRelay 看板/决策)一起带给模型,默认 true。让子任务开局就知道项目现在什么状态。只在任务与本项目完全无关时关掉。

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.8/5.0
Behavior5/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: it discloses that local inference engines must be manually started and that 'unreachable' should not be retried, that sync calls take 1-3 minutes, that explore mode disables write/edit at the process level, that out-of-scope edits fail the run, and that file snapshots produce an evidence chain rather than trusting self-reports.

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 bolded one-line summary is front-loaded and the bracketed sections make it scannable. It is still long and repeats itself (async behavior and the model escalation ladder each appear in both prose and schema), costing some tightness.

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?

For a 13-parameter, no-output-schema, unannotated tool, this covers what an agent needs: prerequisites, failure signals, mode selection, timeout expectations, return of taskId in async mode, and the warning that the only trustworthy completion signal is a zero exit code.

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 100%, so the baseline is 3, and the description adds meaning beyond it mainly through the verify guidance — design commands that cannot be gamed (don't check file existence; run tests or assert content) — which is genuinely actionable design advice absent from the schema. The async, rework and escalate explanations largely restate schema text, keeping this below a 5.

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 opening line states a concrete verb and resource ('把子任务派给另一个模型跑,用命令行验收兜底') and immediately distinguishes the division of labor: the caller directs, the sub-model executes, exit codes certify. The 【两种模式】 section further separates this tool from pi_result by naming the retrieval sibling explicitly.

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

Usage Guidelines5/5

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

Provides explicit 【何时用】 and 【何时不用】 lists, including the counter-case of just doing small tasks yourself. It also gives a decision rule for sync vs async ('拿到结果才能往下做' vs '派完就走'), and names pi_result as the follow-up for async dispatch.

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

Deploy Server

Other Tools