feat(agent): add subagents config for per-agent task tool filtering #7271
+115
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
subagentsconfiguration option that allows primary agents to specify which subagents appear in their Task tool description. This reduces token overhead when many subagents are configured but only a subset is relevant to a particular agent.Closes #7269
Problem
The Task tool description includes all configured subagents, adding ~6-10k tokens to the system prompt regardless of whether the agent will use them. With 150+ subagents, this significantly impacts:
Solution
Add a
subagentsfield to agent config that filters which subagents appear in the Task tool description:{ "agent": { "build": { "subagents": ["explore", "general", "code-*"] } } }code-*,*-reviewer)permission.task(which controls runtime access)Changes
packages/opencode/src/config/config.ts- Addsubagentsfield to Agent schemapackages/opencode/src/agent/agent.ts- Addsubagentsto Agent.Info and statepackages/opencode/src/tool/task.ts- Filter agents based on caller's subagents configpackages/opencode/test/tool/task-subagents.test.ts- Tests for filtering logicpackages/web/src/content/docs/agents.mdx- DocumentationTesting
All 9 tests pass.