Seven tools for OpenCode V2 that let an agent inspect and control subagent sessions: list children and usage, cancel one session or the caller's running descendants, steer or queue messages, and inject context.
Plugin ID:
subagent-tools. Default tool namespace:subagent.
Requires OpenCode 2.3.0+; tested against 2.4.1.
opencode plugin add opencode-subagent-toolsGitHub:
opencode plugin add github:finnseefly/opencode-subagent-toolsAfter install, run opencode reload and ask the agent to call subagent_list.
For manual/local installation, see installation.
| Tool | What it does |
|---|---|
subagent_list |
List child sessions with status, activity, age, cost, and token usage. |
subagent_usage |
Read cost, tokens, current context, status, and activity for a session. |
subagent_cancel |
Stop one session and report background work it cannot stop. |
subagent_cancel_descendants |
Stop running descendants and report idle background jobs. |
subagent_steer |
Send an instruction at the child's next model request. |
subagent_queue |
Queue a message as the next independent turn. |
subagent_context |
Inject a synthetic context message without starting a turn. |
The plugin also registers a subagent-tools skill with operational guidance.
See the tool reference for output formats and
per-tool defaults. Set allowedOutputFormats to ["text"] or ["json"] to
allow only one format; the default ["text", "json"] enables the per-call
format choice.
Tool names above use the default subagent namespace. Change the namespace
option to use a different prefix. Nested subagents require
experimental.subagent_depth to be at least 2 in OpenCode; this is an OpenCode
setting, not a plugin option.
One power-user example; every option is optional. The values below are the defaults. See configuration for ranges and examples.
Mutations call the subagent.control permission action. Setting
enforcePermissions: true by itself does not prompt; add an ask or deny rule
to be asked or blocked. See security model.
finishedis not task completion. It means the last execution succeeded. The child may still own a shell, image, video, subagent, or Code Mode job. UseactiveandsubtreeActiveto find work that is still in progress.cancelis a soft interrupt. It does not cascade. A long tool call may finish first, and jobs owned by an idle session keep running. The result reports observed background work, but this tool cannot stop it.cancel_descendantsonly targets running executions. Idle descendants that own background jobs are counted inbackgroundJobCount, not interrupted. It stops up tomaxCancelBatchrunning descendants per call and only touches the caller's subtree; usecursorto continue. Nested cancellation can wake an intermediate parent.- Discovery stops at 200 nodes, 8 levels, or 5 pages by default. Raise them
for large trees. An empty or partial list is not proof that no subagents
exist, and incomplete discovery can make
subtreeActivefalse. See limitations. - Usage can lag while a child is active. Values are persisted at step
boundaries;
usageMayLagmeans re-query after the step or after cancellation. - Permissions are not prompted by default. Add an
askordenyrule forsubagent.controlif you rely on approval.
- Installation
- Configuration
- Tool reference
- Security model
- Security policy
- Limitations
- Development
- Changelog
MIT. See LICENSE.
{ "$schema": "https://opencode.ai/config.json", "plugins": [ { "package": "opencode-subagent-tools", "options": { "namespace": "subagent", // tool prefix "enforcePermissions": true, // check mutations with subagent.control "sessionControlPolicy": "descendants", // mutations only; reads are unrestricted "allowedOutputFormats": ["text", "json"], // or ["text"] / ["json"] "registerSkill": true, // register SKILL.md as a skill "limits": { "maxDiscoveryNodes": 200, "maxDiscoveryDepth": 8, "maxDiscoveryPages": 5, "maxListRows": 20, "maxCancelBatch": 20, "maxTextLength": 16000, }, }, }, ], }