# Tool Design & Rules

The rules a tool definition must follow, and the flags that mark its behavior.

## Tool design rules

The four mandatory rules for adding or editing tools (build-time contract from `reasoning_guide(topics=["tool_generate"])`, exposed to external agents as `tool_generate_guide`; ongoing quality checked by the `code-reviewer` skill, which is no longer bundled since v1.0.17 and is installed with `/skill` → `system` (`/skills` before v1.0.22)):

1. **Name is the primary semantic carrier** — since v1.2.0 the model sees only tool names until `find_tools` fetches a schema — in the per-turn `Tools` list for every provider except `claude-code` and (since v1.6.0) `agy`, which receive the names alone as well, so the name is what the model picks from
2. **Description is exactly 3 lines, 60-200 chars** — What (core action) / When (trigger vs alternatives, e.g. `use for X; Y for Z`) / Precondition (key constraint, omit if none). No filler, no bold, no output-schema dump.
3. **English only** — Chinese only appears in user-facing handler return messages
4. **Optional fields must declare a `default`** — handlers still defend against nil/missing

Trigger conditions and comparisons with similar tools are required in the When line, not forbidden — a description with only the core action and no trigger signal is treated as incomplete. Parameter descriptions must cover How/When/Example, and a non-trivial type (object/array/enum) under 20 chars is incomplete.

## Tool concurrency markers

`toolRegister.Def` carries six behavioral flags:

| Flag | Effect |
|---|---|
| `AlwaysAllow` | Exempt from the confirm gate (read-only tools); `write_tool`, `write_skill`, `write_hook`, `test_tool` and `test_hook` lost it in v1.5.0. A script tool gets the same exemption from `always_allow: true` in its `tool.json` |
| `Concurrent` | Opts into Pass 2 fan-out (one goroutine per call) |
| `Background` | Result is not awaited by the loop |
| `SystemUse` | Internal bookkeeping tool — left out of `find_tools(mode=list)` (the `system` parameter that surfaced these tools was Removed in v1.3.5) |
| `SystemDefault` | Added in v1.3.17. Generic built-in kept as the fallback when an `mcp__*` or `script_*` tool covers the same intent: marked `system_default` in `find_tools` results and ranked one point lower in `query` matching (`search_web`, `fetch_page`, `download_file`, `http_request`, `generate_image`, `generate_audio`) |
| `Timeout` | Per-tool override of the default (`DEFAULT_TOOL_TIMEOUT`, 15 min since v1.1.2 — 1 min before); `NoToolTimeout` (used by `ask_user` since v1.0.23) removes the limit |

The `AlwaysLoad` flag was removed; a schema is loaded through `find_tools` (Removed in v1.2.0).

Adding `Concurrent: true` requires both "no side effects" and "upstream allows parallelism". The current concurrent set is listed on the Execution Engine page.
