tool-selector
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTool Selector Protocol
工具选择器协议
Determine which tools are needed to solve the task, plan the most efficient sequence, and eliminate unnecessary calls before they happen.
Core principle: Every tool call costs time, tokens, and rate limits. The right tool, in the right order, called once.
确定解决任务所需的工具,规划最高效的执行顺序,并提前避免不必要的工具调用。
核心原则:每次工具调用都会消耗时间、令牌(tokens)和调用限额。要选择正确的工具,按正确的顺序,只调用一次。
Tool Catalog
工具目录
| Tool | Cost | Side Effect | Best For |
|---|---|---|---|
| Web search | Medium | None (read-only) | Current info, external sources |
| Code execution | Medium | Environment-dependent | Computation, transformation, testing |
| File read | Low | None | Local data, config, content |
| File write | Medium | Persistent change | Saving output, updates |
| API call | High | Rate limits, cost | External service integration |
| Database query | Medium-High | Persistent on writes | Data read/write |
| Memory/context | Low | None | Retrieve previous information |
| 工具 | 成本 | 副作用 | 最佳适用场景 |
|---|---|---|---|
| 网页搜索 | 中等 | 无(只读) | 最新信息、外部资源 |
| 代码执行 | 中等 | 取决于运行环境 | 计算、转换、测试 |
| 文件读取 | 低 | 无 | 本地数据、配置、内容 |
| 文件写入 | 中等 | 产生持久化变更 | 保存输出、更新内容 |
| API调用 | 高 | 受调用限额、成本限制 | 外部服务集成 |
| 数据库查询 | 中-高 | 写入操作会产生持久化变更 | 数据读写 |
| 内存/上下文 | 低 | 无 | 检索历史信息 |
Selection Algorithm
选择算法
For each tool candidate, ask these questions in order:
1. Can this tool actually solve this task? → No = eliminate
2. Can a cheaper/simpler tool do the same job? → Yes = use that instead
3. Was this tool already called for this task? → Yes = use cached result
4. Is this call actually needed right now? → No = defer
5. Does this tool depend on another tool's output? → Yes = add to sequence对于每个候选工具,按顺序提出以下问题:
1. Can this tool actually solve this task? → No = eliminate
2. Can a cheaper/simpler tool do the same job? → Yes = use that instead
3. Was this tool already called for this task? → Yes = use cached result
4. Is this call actually needed right now? → No = defer
5. Does this tool depend on another tool's output? → Yes = add to sequenceAnti-Patterns — Block These
反模式 — 需避免
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Reading the same file repeatedly | Each read costs tokens | Cache on first read |
| Web search for known information | Unnecessary latency | Use existing knowledge |
| Serial API calls (could be parallel) | Slow | Plan parallel calls |
| Tool chain when one tool suffices | Extra steps | Consolidate |
| Read before write (when unnecessary) | Extra call | Skip the read |
| Loading memory every step | Token waste | Load once, reference |
| 反模式 | 问题 | 解决方案 |
|---|---|---|
| 重复读取同一文件 | 每次读取都会消耗令牌 | 首次读取后缓存结果 |
| 对已知信息进行网页搜索 | 造成不必要的延迟 | 使用已有知识 |
| 串行API调用(可并行) | 速度慢 | 规划并行调用 |
| 可用单个工具却使用工具链 | 额外步骤 | 合并操作 |
| 不必要的先读后写 | 额外调用 | 跳过读取步骤 |
| 每步都加载内存 | 浪费令牌 | 加载一次后复用 |
Output Format
输出格式
TOOL SELECTOR
Task : [task summary]
Selected: N tools | Total calls: N | Blocked: NTOOL SELECTOR
Task : [task summary]
Selected: N tools | Total calls: N | Blocked: NTool Plan
Tool Plan
| Step | Tool | Purpose | Depends On | Cached? |
|---|---|---|---|---|
| 1 | [tool] | [why] | — | No |
| 2 | [tool] | [why] | #1 | Yes — use #1 output |
| Step | Tool | Purpose | Depends On | Cached? |
|---|---|---|---|---|
| 1 | [tool] | [why] | — | No |
| 2 | [tool] | [why] | #1 | Yes — use #1 output |
Blocked Calls
Blocked Calls
| Blocked | Reason | Alternative |
|---|---|---|
| [tool call] | [rationale] | [what to do instead] |
| Blocked | Reason | Alternative |
|---|---|---|
| [tool call] | [rationale] | [what to do instead] |
Optimization Notes
Optimization Notes
- [Parallel opportunities]
- [Cached outputs]
- [Rate limit warnings]
Approve? Proceed?
---- [Parallel opportunities]
- [Cached outputs]
- [Rate limit warnings]
Approve? Proceed?
---Tool Combination Guide
工具组合指南
| Task Type | Typical Chain | Block |
|---|---|---|
| Research & Report | Search → File read → Code (analyze) → File write | Searching same topic twice |
| Data Processing | File read → Code → File write | Re-reading file each step |
| API Integration | Memory (creds) → API → Code (parse) → DB write | Re-auth per request |
| Code Development | File read → Code (test) → File write → Code (verify) | Full test suite on every change |
| Database Operation | Memory (schema) → DB (SELECT) → Code (prepare) → DB (write) | Running same SELECT twice |
| 任务类型 | 典型工具链 | 需避免的操作 |
|---|---|---|
| 研究与报告 | 网页搜索 → 文件读取 → 代码(分析)→ 文件写入 | 重复搜索同一主题 |
| 数据处理 | 文件读取 → 代码执行 → 文件写入 | 每步重复读取文件 |
| API集成 | 内存(凭证)→ API调用 → 代码(解析)→ 数据库写入 | 每次请求重复认证 |
| 代码开发 | 文件读取 → 代码(测试)→ 文件写入 → 代码(验证) | 每次变更都运行完整测试套件 |
| 数据库操作 | 内存(Schema)→ 数据库(查询)→ 代码(预处理)→ 数据库(写入) | 重复执行同一查询 |
When to Skip
跳过场景
- Single-tool task ("read this file")
- User already specified which tool to use
- Single-step, side-effect-free task
- 单工具任务(如“读取此文件”)
- 用户已指定要使用的工具
- 单步骤、无副作用的任务
Guardrails
防护规则
- Never call an API when cached data suffices — always check cache first.
- Prefer low-cost tools — file read over web search when local data exists.
- Cross-skill: works with (parallel tool calls) and
parallel-planner(tool needs per subtask).task-decomposer
- 当缓存数据可用时,绝不调用API — 始终先检查缓存。
- 优先使用低成本工具 — 当存在本地数据时,优先使用文件读取而非网页搜索。
- 跨技能兼容:可与(并行工具调用)和
parallel-planner(子任务工具需求)配合使用。task-decomposer