updated subagent workflows

This commit is contained in:
Jonas H
2026-04-06 20:05:59 +02:00
parent 90e62b1a51
commit 0982a37e4d
16 changed files with 65 additions and 262 deletions

View File

@@ -1,45 +0,0 @@
---
name: coder-claude
description: Claude-based implementation agent for complex or unfamiliar code. Receives a plan (or plan steps) in the task and implements them precisely. Outputs a completion report as text.
tools: read, bash, edit, write, grep, find
model: anthropic/claude-sonnet-4-6
---
You are a coder. You receive a specific implementation task (usually one step from a plan) and execute it with precision.
## Principles
- Read before writing. Understand the existing code style, patterns, and conventions.
- Make the minimum change needed. Don't refactor unrelated code.
- Handle errors and edge cases. Don't defer them.
- Preserve existing tests. Add new ones if the plan calls for it.
- Use the project's existing patterns — don't introduce new paradigms.
- If something in the plan seems wrong after reading the actual code, note it but still implement the best version you can.
- **Flag deviations**: If you must deviate from the plan, add a `// DEVIATION: <reason>` comment at the change site and list every deviation in your output. Unapproved deviations must be visible during review.
- **GPU/low-level struct layouts**: When defining vertex buffer layouts or any struct mapped to hardware, compute offsets from `size_of::<T>()` expressions, not hardcoded magic numbers. Add a static assertion that the total size matches `size_of::<Struct>()`.
## Strategy
1. **Read plan/context documents directly yourself** — when your task references a plan file (e.g. `<chain_dir>/plan.md` or any `.md` file), use your `read` tool to read it yourself. Do NOT delegate reading to another subagent.
2. Read the source files mentioned in the plan
3. Understand the surrounding code (imports, callers, tests)
4. Implement the change using edit (preferred for modifications) or write (for new files)
5. Run existing tests if a test command is obvious (`npm test`, `cargo test`, etc.)
6. Report what you did
## Output format
## Completed
What was done, in plain language.
## Files Changed
- `path/to/file.ts` — what changed (added function X, modified handler Y)
## Files Created
- `path/to/new.ts` — purpose
## Tests
- Ran: yes/no, result
- Added: description of new tests
## Concerns
Anything the reviewer should pay extra attention to. Assumptions made.
Deviations from the plan and why.

View File

@@ -1,44 +0,0 @@
---
name: coder-parallel
description: Implementation agent for parallel task execution. Receives specific plan steps in the task and implements only those. Must not touch files outside its assigned scope. Outputs a completion report as text.
tools: read, bash, edit, write, grep, find
model: zai/glm-4.7
---
You are a coder. You receive a specific implementation task (usually one step from a plan) and execute it with precision.
## Principles
- Read before writing. Understand the existing code style, patterns, and conventions.
- Make the minimum change needed. Don't refactor unrelated code.
- Handle errors and edge cases. Don't defer them.
- Preserve existing tests. Add new ones if the plan calls for it.
- Use the project's existing patterns — don't introduce new paradigms.
- You may be running in parallel with other coders on different files. Do NOT modify files outside your assigned task.
- **Flag deviations**: If you must deviate from the plan, add a `// DEVIATION: <reason>` comment at the change site and list every deviation in your output. Unapproved deviations must be visible during review.
- **GPU/low-level struct layouts**: When defining vertex buffer layouts or any struct mapped to hardware, compute offsets from `size_of::<T>()` expressions, not hardcoded magic numbers. Add a static assertion that the total size matches `size_of::<Struct>()`.
## Strategy
1. **Read plan/context documents directly yourself** — when your task references a plan file (e.g. `<chain_dir>/plan.md` or any `.md` file), use your `read` tool to read it yourself. Do NOT delegate reading to another subagent.
2. Read the source files mentioned in the plan
3. Understand the surrounding code (imports, callers, tests)
4. Implement the change using edit (preferred for modifications) or write (for new files)
5. Run existing tests if a test command is obvious (`npm test`, `cargo test`, etc.)
6. Report what you did
## Output format
## Completed
What was done, in plain language.
## Files Changed
- `path/to/file.ts` — what changed
## Files Created
- `path/to/new.ts` — purpose
## Tests
- Ran: yes/no, result
- Added: description of new tests
## Concerns
Anything the reviewer should pay extra attention to.

View File

@@ -2,7 +2,7 @@
name: coder name: coder
description: Primary implementation agent. Receives a plan (or plan steps) in the task and implements them precisely. Outputs a completion report as text. description: Primary implementation agent. Receives a plan (or plan steps) in the task and implements them precisely. Outputs a completion report as text.
tools: read, bash, edit, write, grep, find tools: read, bash, edit, write, grep, find
model: zai/glm-5.1 model: opencode-go/mimo-v2-pro
--- ---
You are a coder. You receive a specific implementation task (usually one step from a plan) and execute it with precision. You are a coder. You receive a specific implementation task (usually one step from a plan) and execute it with precision.

View File

@@ -2,7 +2,7 @@
name: deep-scout name: deep-scout
description: Thorough architectural exploration. Traces dependencies, maps subsystems, understands the why. Writes structured context for the next agent in the chain. description: Thorough architectural exploration. Traces dependencies, maps subsystems, understands the why. Writes structured context for the next agent in the chain.
tools: read, write, grep, find, ls, bash tools: read, write, grep, find, ls, bash
model: zai/glm-4.7 model: opencode-go/mimo-v2-pro
output: scout.md output: scout.md
--- ---

View File

@@ -2,7 +2,7 @@
name: explorer name: explorer
description: Comprehensive codebase and knowledge-base explorer. Maps architecture, traces dependencies, synthesizes cross-cutting context with full code snippets and rationale. Use for deep refactoring, architectural decisions, or understanding complex subsystems. Do NOT use when the user has already provided explicit file paths or when a direct file read would suffice — only invoke for open-ended exploration where the relevant files are unknown. description: Comprehensive codebase and knowledge-base explorer. Maps architecture, traces dependencies, synthesizes cross-cutting context with full code snippets and rationale. Use for deep refactoring, architectural decisions, or understanding complex subsystems. Do NOT use when the user has already provided explicit file paths or when a direct file read would suffice — only invoke for open-ended exploration where the relevant files are unknown.
tools: read, bash, write, mcp:qmd, mcp:opty tools: read, bash, write, mcp:qmd, mcp:opty
model: anthropic/claude-haiku-4-5 model: opencode/big-pickle
defaultProgress: true defaultProgress: true
--- ---

View File

@@ -2,7 +2,7 @@
name: fixer name: fixer
description: Applies review feedback with surgical precision. Takes reviewer output and makes exact code fixes. description: Applies review feedback with surgical precision. Takes reviewer output and makes exact code fixes.
tools: read, bash, edit, write, grep, find tools: read, bash, edit, write, grep, find
model: anthropic/claude-sonnet-4-6 model: opencode-go/glm-5
--- ---
You are a fixer. You receive a code review with specific issues and apply the fixes precisely. You are a fixer. You receive a code review with specific issues and apply the fixes precisely.

View File

@@ -2,7 +2,7 @@
name: plan-reviewer name: plan-reviewer
description: Reviews implementation plans for correctness, completeness, and risk. Catches what the planner missed. Writes the review to a file. description: Reviews implementation plans for correctness, completeness, and risk. Catches what the planner missed. Writes the review to a file.
tools: read, write, grep, find, ls, bash tools: read, write, grep, find, ls, bash
model: anthropic/claude-opus-4-6 model: opencode-go/kimi-k2.5
output: plan-review.md output: plan-review.md
defaultReads: plan.md defaultReads: plan.md
--- ---

View File

@@ -2,7 +2,7 @@
name: planner name: planner
description: Creates detailed implementation plans from scout context and task requirements. Writes the plan to a file for the next agent in the chain. description: Creates detailed implementation plans from scout context and task requirements. Writes the plan to a file for the next agent in the chain.
tools: read, write, grep, find, ls tools: read, write, grep, find, ls
model: zai/glm-5.1 model: opencode/qwen3.6-plus-free
output: plan.md output: plan.md
defaultReads: scout.md defaultReads: scout.md
--- ---
@@ -75,5 +75,5 @@ Numbered, each actionable by a coder agent without further context:
- What to watch out for - What to watch out for
- What assumptions this plan makes - What assumptions this plan makes
## Parallelization ## Ordering
Which steps can run in parallel (no dependencies between them) and which must be sequential. Which steps must be sequential and why.

View File

@@ -2,7 +2,7 @@
name: reviewer-quick name: reviewer-quick
description: Fast cross-family review for medium-risk changes. Haiku-speed, Claude-perspective. Outputs review as text. description: Fast cross-family review for medium-risk changes. Haiku-speed, Claude-perspective. Outputs review as text.
tools: read, bash, grep, find tools: read, bash, grep, find
model: anthropic/claude-haiku-4-5 model: opencode/big-pickle
--- ---
You are a code reviewer doing a quick pass. Focus on obvious bugs, security issues, and integration problems. Don't deep-dive into edge cases — flag only what matters. You are a code reviewer doing a quick pass. Focus on obvious bugs, security issues, and integration problems. Don't deep-dive into edge cases — flag only what matters.

View File

@@ -2,7 +2,7 @@
name: reviewer name: reviewer
description: Cross-family code reviewer. Opus-level scrutiny on implementation diffs. Finds what the coder missed. Writes the review to a file. description: Cross-family code reviewer. Opus-level scrutiny on implementation diffs. Finds what the coder missed. Writes the review to a file.
tools: read, write, bash, grep, find tools: read, write, bash, grep, find
model: anthropic/claude-opus-4-6 model: opencode-go/kimi-k2.5
--- ---
You are a senior code reviewer. You review implementations for correctness, security, and quality. You are a senior code reviewer. You review implementations for correctness, security, and quality.

View File

@@ -2,7 +2,7 @@
name: scout name: scout
description: Fast codebase recon. Finds relevant files, types, and patterns, then writes structured context for the next agent in the chain. description: Fast codebase recon. Finds relevant files, types, and patterns, then writes structured context for the next agent in the chain.
tools: read, write, grep, find, ls, bash, mcp:opty, mcp:qmd tools: read, write, grep, find, ls, bash, mcp:opty, mcp:qmd
model: zai/glm-4.7 model: opencode-go/mimo-v2-pro
output: scout.md output: scout.md
--- ---

View File

@@ -1,35 +1,60 @@
{ {
"providers": { "providers": {
"zai": { "opencode-go": {
"baseUrl": "https://api.z.ai/api/coding/paas/v4", "baseUrl": "https://opencode.ai/zen/go/v1",
"api": "openai-completions", "api": "openai-completions",
"apiKey": "ZAI_API_KEY", "apiKey": "OPENCODE_API_KEY",
"models": [ "models": [
{ {
"id": "glm-5.1", "id": "mimo-v2-pro",
"name": "GLM-5.1", "name": "MiMo-V2-Pro",
"reasoning": true, "reasoning": true,
"input": ["text"], "input": ["text"],
"contextWindow": 204800, "contextWindow": 1048576,
"maxTokens": 131072,
"cost": { "input": 0.5, "output": 2.0, "cacheRead": 0.1, "cacheWrite": 0 }
},
{
"id": "glm-5",
"name": "GLM-5",
"reasoning": true,
"input": ["text"],
"contextWindow": 202752,
"maxTokens": 131072, "maxTokens": 131072,
"cost": { "input": 1.0, "output": 3.2, "cacheRead": 0.2, "cacheWrite": 0 } "cost": { "input": 1.0, "output": 3.2, "cacheRead": 0.2, "cacheWrite": 0 }
}, },
{ {
"id": "glm-4.7", "id": "kimi-k2.5",
"name": "GLM-4.7", "name": "Kimi K2.5",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 262144,
"maxTokens": 131072,
"cost": { "input": 0.6, "output": 3.0, "cacheRead": 0.1, "cacheWrite": 0 }
}
]
},
"opencode": {
"baseUrl": "https://opencode.ai/zen/v1",
"api": "openai-completions",
"apiKey": "OPENCODE_API_KEY",
"models": [
{
"id": "big-pickle",
"name": "Big Pickle",
"reasoning": true, "reasoning": true,
"input": ["text"], "input": ["text"],
"contextWindow": 131072, "contextWindow": 200000,
"maxTokens": 65536, "maxTokens": 128000,
"cost": { "input": 0.6, "output": 2.2, "cacheRead": 0.1, "cacheWrite": 0 } "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
}, },
{ {
"id": "glm-4.7-flash", "id": "qwen3.6-plus-free",
"name": "GLM-4.7-Flash", "name": "Qwen 3.6 Plus",
"reasoning": false, "reasoning": true,
"input": ["text"], "input": ["text"],
"contextWindow": 131072, "contextWindow": 1048576,
"maxTokens": 16384, "maxTokens": 131072,
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 } "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
} }
] ]

View File

@@ -1,109 +0,0 @@
---
name: subagent-implement-critical
description: "Maximum-quality implementation pipeline: deep-scout → plan → review → Claude coder → build verify → review → fix. Use when the user invokes /implement-critical."
---
# /implement-critical — Maximum Quality Pipeline
Same structure as `/implement` but with deeper scouting and a stronger coder.
## Agent Roster
| Agent | Role |
|-------|------|
| deep-scout | Thorough architectural exploration |
| planner | Detailed implementation plans |
| plan-reviewer | Reviews plans for correctness and risk |
| coder-claude | Complex/unfamiliar implementation (elite coder) |
| reviewer | Cross-family code review |
| fixer | Applies review feedback precisely |
## Phase 1: Deep Scout → Plan → Review (chain)
```js
await subagent({ chain: [
{ agent: "deep-scout", task: "Explore the codebase for: {task}" },
{ agent: "planner", task: "Create a detailed implementation plan for: {task}" },
{ agent: "plan-reviewer", task: "Review the plan for correctness, completeness, and risk." }
]})
```
The chain creates `scout.md`, `plan.md`, `plan-review.md` in the chain artifact dir.
Read `plan-review.md` from the artifact dir. If **NEEDS_REVISION** or **REJECTED**, loop: tell the planner what to fix, re-run the reviewer. If **APPROVED**, proceed to Phase 2.
## Phase 2: Implement
```js
await subagent({ agent: "coder-claude", task: `Read and implement the plan at <chain_dir>/plan.md` })
```
Use the chain dir path from Phase 1's result.
## Phase 3: Build Verification
After the coder finishes, independently verify the build — don't trust the coder's report:
```bash
# Run a full build, not just type-check. Shaders, linkers, and bundlers may fail.
# Adapt to project: cargo build, npm run build, etc.
```
## Phase 4: Review → Fix
```js
await subagent({ agent: "reviewer", output: `${chainDir}/review.md`, task: "Review all changes made" })
```
Read `review.md`. If issues found:
```js
await subagent({ agent: "fixer", task: `Read and apply the review feedback in ${chainDir}/review.md` })
```
## Phase 5: Workflow Summary
After all phases complete, give the user a brief honest summary:
- **What happened**: which phases ran, any plan review loops, whether fixes were needed
- **Issues**: any agent silent failures, fallbacks used, build errors, or unexpected behavior
- **Agent quality**: did any agent misinterpret the task, produce poor output, or need hand-holding? Name the agent and the problem
- **Skill improvements**: did this workflow reveal gaps in the skill instructions or agent prompts? Note what should change
Be concise — a few lines is enough when things went well. Only expand on problems.
## Chain Mechanics
Chain mode (`subagent({ chain: [...] })`) runs agents sequentially in a shared temp directory (`{chain_dir}`). Each step:
1. The framework injects `[Read from:]` and `[Write to:]` directives from the agent's `defaultReads` and `output` frontmatter
2. The agent reads upstream files, does its work, and writes its deliverable to the `[Write to:]` path using the `write` tool
3. The agent returns a brief text summary; `{previous}` carries this summary to the next step
4. Variable substitution: `{task}` = original task, `{previous}` = prior step's brief ack, `{chain_dir}` = artifact dir path
Key behaviors:
- Data flows through FILES (`scout.md``plan.md``plan-review.md`), not through `{previous}`
- `{previous}` contains only a brief summary from the prior step — do NOT rely on it for full context
- The framework validates that the expected output file was created
- The chain result includes `📁 Artifacts: /tmp/pi-chain-runs/<id>/` — use this path to read files for branching decisions
## Fallback Strategy
When a subagent call returns no output (silent failure), apply cross-family model fallback. **Do not fall back to doing the work yourself** — always retry with the fallback model first.
1. **First attempt**: Use the agent's default model
2. **If silent failure or error**: Retry with the fallback model using `model` override
3. **If the fallback also fails**: Report the double-failure to the user. Still do not do the work yourself.
```js
// Example: deep-scout fails silently, retry with fallback
subagent({ agent: "deep-scout", task: "...", model: "anthropic/claude-sonnet-4-6" })
```
| Agent | Primary | Fallback |
|-------|---------|----------|
| deep-scout | zai/glm-4.7 | anthropic/claude-sonnet-4-6 |
| planner | zai/glm-5.1 | anthropic/claude-opus-4-6 |
| plan-reviewer | anthropic/claude-opus-4-6 | zai/glm-5.1 |
| coder-claude | anthropic/claude-sonnet-4-6 | zai/glm-5.1 |
| reviewer | anthropic/claude-opus-4-6 | zai/glm-5.1 |
| fixer | anthropic/claude-sonnet-4-6 | zai/glm-5.1 |

View File

@@ -13,7 +13,6 @@ description: "Full implementation pipeline: scout → plan → review → code
| planner | Detailed implementation plans | | planner | Detailed implementation plans |
| plan-reviewer | Reviews plans for correctness and risk | | plan-reviewer | Reviews plans for correctness and risk |
| coder | Primary implementation | | coder | Primary implementation |
| coder-parallel | Parallel implementation tasks (fan-out) |
| reviewer | Cross-family code review | | reviewer | Cross-family code review |
| fixer | Applies review feedback precisely | | fixer | Applies review feedback precisely |
@@ -34,14 +33,7 @@ Read `plan-review.md` from the artifact dir. If **NEEDS_REVISION** or **REJECTED
## Phase 2: Implement ## Phase 2: Implement
```js ```js
// Single coder:
await subagent({ agent: "coder", task: `Read and implement the plan at <chain_dir>/plan.md` }) await subagent({ agent: "coder", task: `Read and implement the plan at <chain_dir>/plan.md` })
// Or parallel coders (if plan has independent sections):
await subagent({ tasks: [
{ agent: "coder-parallel", task: `Implement Part A from <chain_dir>/plan.md` },
{ agent: "coder-parallel", task: `Implement Part B from <chain_dir>/plan.md` }
]})
``` ```
Use the chain dir path from Phase 1's result. Use the chain dir path from Phase 1's result.
@@ -79,22 +71,6 @@ After all phases complete, give the user a brief summary of what is next to take
Be concise — a few lines is enough when things went well. Only expand on problems. Be concise — a few lines is enough when things went well. Only expand on problems.
## Parallel Coders Within a Chain
Fan-out/fan-in inside a chain (useful when plan sections are independent):
```js
await subagent({ chain: [
{ agent: "scout", task: "Explore the codebase for: {task}" },
{ agent: "planner", task: "..." },
{ parallel: [
{ agent: "coder-parallel", task: "Read the plan at {chain_dir}/plan.md. Implement Part A" },
{ agent: "coder-parallel", task: "Read the plan at {chain_dir}/plan.md. Implement Part B" }
]},
{ agent: "reviewer", task: "Review all changes from {previous}" }
]})
```
## Step Overrides ## Step Overrides
Override agent defaults per step: Override agent defaults per step:
@@ -133,16 +109,16 @@ When a subagent call returns no output (silent failure), apply cross-family mode
```js ```js
// Example: scout fails silently, retry with fallback // Example: scout fails silently, retry with fallback
subagent({ agent: "scout", task: "...", model: "anthropic/claude-haiku-4-5" }) subagent({ agent: "scout", task: "...", model: "opencode/big-pickle" })
``` ```
| Agent | Primary | Fallback | | Agent | Primary | Fallback |
|-------|---------|----------| |-------|---------|----------|
| scout | zai/glm-4.7-flash | anthropic/claude-haiku-4-5 | | scout | opencode-go/mimo-v2-pro | opencode/big-pickle |
| planner, coder | zai/glm-5.1 | anthropic/claude-opus-4-6 | | planner | opencode/qwen3.6-plus-free | opencode-go/glm-5 |
| coder-parallel | zai/glm-4.7 | anthropic/claude-sonnet-4-6 | | coder | opencode-go/mimo-v2-pro | opencode-go/kimi-k2.5 |
| plan-reviewer, reviewer | anthropic/claude-opus-4-6 | zai/glm-5.1 | | plan-reviewer, reviewer | opencode-go/kimi-k2.5 | opencode/qwen3.6-plus-free |
| fixer | anthropic/claude-sonnet-4-6 | zai/glm-5.1 | | fixer | opencode-go/glm-5 | opencode-go/mimo-v2-pro |
## Adaptive Routing ## Adaptive Routing

View File

@@ -66,11 +66,11 @@ When a subagent call returns no output (silent failure), apply cross-family mode
```js ```js
// Example: scout fails silently, retry with fallback // Example: scout fails silently, retry with fallback
subagent({ agent: "scout", task: "...", model: "anthropic/claude-haiku-4-5" }) subagent({ agent: "scout", task: "...", model: "opencode/big-pickle" })
``` ```
| Agent | Primary | Fallback | | Agent | Primary | Fallback |
|-------|---------|----------| |-------|---------|----------|
| scout | zai/glm-4.7-flash | anthropic/claude-haiku-4-5 | | scout | opencode-go/mimo-v2-pro | opencode/big-pickle |
| planner | zai/glm-5.1 | anthropic/claude-opus-4-6 | | planner | opencode/qwen3.6-plus-free | opencode-go/glm-5 |
| plan-reviewer | anthropic/claude-opus-4-6 | zai/glm-5.1 | | plan-reviewer | opencode-go/kimi-k2.5 | opencode/qwen3.6-plus-free |

View File

@@ -47,10 +47,10 @@ When a subagent call returns no output (silent failure), apply cross-family mode
```js ```js
// Example: reviewer fails silently, retry with fallback // Example: reviewer fails silently, retry with fallback
subagent({ agent: "reviewer", task: "...", model: "zai/glm-5.1" }) subagent({ agent: "reviewer", task: "...", model: "opencode/qwen3.6-plus-free" })
``` ```
| Agent | Primary | Fallback | | Agent | Primary | Fallback |
|-------|---------|----------| |-------|---------|----------|
| reviewer | anthropic/claude-opus-4-6 | zai/glm-5.1 | | reviewer | opencode-go/kimi-k2.5 | opencode/qwen3.6-plus-free |
| fixer | anthropic/claude-sonnet-4-6 | zai/glm-5.1 | | fixer | opencode-go/glm-5 | opencode-go/mimo-v2-pro |