# Subagent Tools

Tools that run subtasks in their own sessions, in the foreground or in the background.

| Tool | Description |
|---|---|
| `subagents` | `mode=invoke` runs a subtask in its own session (in-process, no HTTP); `mode=list` returns the reusable named sessions and their roles. Written to stand alone — the leg sees none of the parent conversation. **Foreground legs run at most `min(MAX_CONCURRENT_TOOLS, MAX_CONCURRENT_SUBAGENTS)` at a time** — half the CPU cores, at least 3, since v1.3.0 (a fixed 3 before) — and the next one queues while its own timeout runs, so wide fan-outs dispatch in batches of that size. Results carry a `[subagent · <model> · session=<id> · usage: in=X out=Y cached=Z write=W]` header that rolls up into parent-session usage. Since v1.0.22 the leg's report body no longer comes back inline: it is written to `~/.config/agenvoy/download/temp-<report_name>.md` and the result is that header plus the file path, which the caller reads with `read_files` before relaying or synthesizing. `report_name` is a short kebab-case name (job + entity, e.g. `nvda-news`); a taken name gets a random suffix, and a blank one uses a random name. `self_id` reuses an existing non-temp session verbatim — it replaced `name` / `session_id` in v0.35.0 and is now required for `mode=list`, which resolves one delegated name instead of dumping every session. Since v1.1.0 `model` is required on every `mode=invoke` call — the dispatcher fallback for a blank model was removed, and `model: "auto"` (hotfix after v1.1.0) hands the choice to the dispatcher, which picks from the task as for a normal request; when `self_id` resolves to a session pinned to its own model that model runs instead, and a session left on `auto` runs the given one. Foreground legs are capped at `MAX_SUBAGENT_TIMEOUT_MIN` (30 min). The `background` and `timeout_min` parameters (added in v1.3.0) were Removed in v1.3.2; use `background_subagents` instead, and the description sends legs very likely over 5 minutes, or a request such as "take your time" / "let me know when it's done" / "run it in the background" (English-only trigger phrases since v1.3.7), there. Since v1.0.21 each leg has one job — collect, analyze, compare, review, transform or code — mapped to a work kind; since v1.1.0 the leg's tier order runs one tier lower than the dispatcher's (collect → `fetch` C>B>A>S, transform → `chat` C>B>A>S, analyze / compare / review → `work` B>A>C>S, code or high-precision → `code` A>B>C>S). The former `reason` job was split into analyze, compare and code. `model` is checked against the live registry, so models added after startup work; an unregistered or `pass`-tier name is rejected with the list of usable models. `reasoning` defaults to `auto` (the leg's session setting, else the dispatcher's pick); a value that is not a reasoning level is rejected. Legs only gather: a leg never gets `subagents`, `background_subagents`, `write_file` (every mode, `mode=remove` included), `restore_file`, `write_tool`, `test_tool`, `test_hook` (since v1.4.0), `write_skill`, `write_hook` (since v1.4.0), `write_result`, `html_template`, any `generate_*` tool, `open_file`, `schedules`, `store_secret`, or the TUI-only tools (`configs/jsons/tui_tools.json`, whose tool list is empty in v1.3.2), and code comes back as text for the main agent to apply; `exclude_tools` adds to that set. `remove_file`, `edit_tool` and `edit_skill` left that list when they were replaced by `write_file(mode=remove)`, `write_tool` and `write_skill` (Removed in v1.5.0). Full dispatch protocol and model tiers → `reasoning_guide(topics=["subagent_dispatch"])` |
| `background_subagents` | Added in v1.3.2. Starts one leg in the background and returns a task id at once, so the turn continues. Takes the `subagents` `mode=invoke` parameters (`task` and `model` required; `report_name`, `self_id`, `reasoning`, `new`, `system_prompt`, `exclude_tools`) plus `timeout_min` (1-60, default 60) in place of the 30-minute cap, and since v1.3.8 `objective` and `next`. Legs started in the same turn form one group (v1.3.8). When a leg finishes, its saved report path goes to the starting task while that task is running or pending; once it has ended, the group waits for all its legs and runs `objective` + `next` + every report as a new task, which can read the starting task through `chat_history`. Before v1.3.8 each report resumed the original task on its own. A background leg never raises a confirmation: a call that would need one is not run and the leg is told to report that it still needs approval; it also gets no `ask_user`. Each leg's progress (model, tool calls and results, text, errors) is written to `~/.config/agenvoy/sessions/<session>/background/<task id>.log`, removed when the leg ends. The leg takes a background task slot instead of a foreground one: at most `MAX_BACKGROUND_TASKS` per session (half the CPU cores, at least 3), shared with `background_command`. The description reserves it for legs very likely over 5 minutes, or a request such as "take your time" / "let me know when it's done" / "run it in the background"; an action the user wants after the gathering goes into `next`, and a request that finishes in a few minutes stays in the foreground (v1.3.8). Every leg of a group is started in the same turn. Excluded unless the request comes from the TUI (`cli-` origin with no deliver target) |
