opencode-dynamic-subagents
v0.3.1
Published
OpenCode plugin that generates native model-pinned subagents from config.
Readme
Dynamic Subagents Plugin
Adds generated model-pinned subagents to OpenCode.
Instead of trying to create truly ad hoc subagents at runtime, this plugin reads dynamicSubAgents.json and generates normal OpenCode subagents for each allowed model and thinking-level combination.
What You Get
- Native OpenCode subagents with no
taskoverride - One generated agent per allowed model and variant
- Model descriptions kept in config and surfaced in agent descriptions
- Predictable native task/session behavior
Install
{
"plugin": ["opencode-dynamic-subagents@latest"]
}Restart OpenCode after installing or updating the plugin.
Quick Start
Create ~/.config/opencode/dynamicSubAgents.json:
{
"$schema": "https://github.com/cgasgarth/opencode-dynamic-subagents/blob/main/dynamicSubAgents.schema.json",
"version": 1,
"defaults": {
"allowedModels": [
{
"id": "openai/gpt-5.4",
"name": "gpt54",
"description": "Best default choice for broad reasoning and higher-quality subagent work."
},
{
"id": "openai/gpt-5.3-codex-spark",
"name": "spark",
"description": "Faster, cheaper code-focused option for small code implementations or quickly searching for things. Best for tightly scoped, shorter tasks because it has a more limited context window."
}
],
"allowedVariants": ["low", "high"]
}
}This generates native subagents like:
@dsa-gpt54-low@dsa-gpt54-high@dsa-spark-low@dsa-spark-high
How It Works
The plugin only runs at config time.
- It loads
dynamicSubAgents.json. - It expands the allowed model list and allowed variant list into concrete subagent definitions.
- It injects those generated agents into
config.agent. - OpenCode then treats them like normal named subagents.
If a generated name collides with an existing agent, the existing agent wins and the generated one is skipped.
Configuration
The plugin reads:
~/.config/opencode/dynamicSubAgents.json$OPENCODE_DYNAMIC_SUBAGENTS_CONFIGfor testing overrides
Supported config:
{
"$schema": "https://github.com/cgasgarth/opencode-dynamic-subagents/blob/main/dynamicSubAgents.schema.json",
"version": 1,
"defaults": {
"model": "openai/gpt-5.4",
"variant": "high",
"prompt": "Optional shared prompt for generated subagents.",
"temperature": 0.2,
"top_p": 0.9,
"hidden": false,
"steps": 20,
"permission": {},
"options": {},
"allowedModels": [
{
"id": "openai/gpt-5.4",
"name": "gpt54",
"description": "Best default choice for broad reasoning and higher-quality subagent work."
},
{
"id": "openai/gpt-5.3-codex-spark",
"name": "spark",
"description": "Faster, cheaper code-focused option for small code implementations or quickly searching for things. Best for tightly scoped, shorter tasks because it has a more limited context window."
}
],
"allowedVariants": ["low", "medium", "high", "xhigh"]
},
"limits": {
"maxSubagentNameLength": 64
}
}Notes:
allowedModelsis the source of truth for which model families get generated.nameis optional but recommended when you want short agent names likedsa-spark-high.descriptionis optional and becomes part of the generated agent description.- If
allowedModelsis omitted, the plugin falls back todefaults.model. - If
allowedVariantsis omitted, the plugin generates one agent per model and usesdefaults.variantif provided.
Usage
Once generated, use the agents like any other OpenCode subagent:
Use @dsa-spark-high to scan a small part of the codebase.
Use @dsa-gpt54-high to review the final shortlist.This approach keeps model choice explicit and stable without depending on dynamic runtime task rewriting.
Dev
npm install
npm run check
npm run build