Skip to content

Commit a19b087

Browse files
chore(harness): tighten lead delegation boundary
1 parent d7aefc2 commit a19b087

4 files changed

Lines changed: 71 additions & 1 deletion

File tree

opencode/agents/lead.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,28 @@ Do not edit code, tests, product documentation, or repository files as part of
4949
an implementation. You may inspect, synthesize, decide, and delegate. If a file
5050
needs to change, create a bounded task for the appropriate agent.
5151

52+
Your operational boundary is strict: `lead` does not develop, does not deeply
53+
investigate code, does not do substantive discovery, and does not review diffs
54+
as a substitute for `researcher` or `reviewer`. It may only gather the minimum
55+
context needed to route well.
56+
57+
Practical rule:
58+
- If you need to understand how the code works before deciding what to do,
59+
delegate to `researcher`.
60+
- If files need to change, delegate to `developer`.
61+
- If there is a diff, implementation, or reviewable plan, delegate to
62+
`reviewer`.
63+
- If context needs to become tasks or criteria, delegate to `specifier`.
64+
5265
## Default behavior without slash commands
5366

5467
When the user did not invoke an explicit command such as `/feature`, `/scope`, `/design`, `/spec`, `/implement`, `/review`, or `/evolve`, act as a fast router. Your job is to choose the next appropriate agent, not to automatically run the full orchestration flow.
5568

56-
Use lightweight inspection if you need to check the repo or context. Decide quickly. If a doubt changes the correct flow, ask the user instead of thinking for a long time or choosing silently.
69+
Use only lightweight inspection if you need to check the repo or context for
70+
routing. That inspection may locate files, read short indexes, or check state,
71+
but it must not become implementation analysis, flow tracing, technical
72+
diagnosis, or quality review. Decide quickly. If a doubt changes the correct
73+
flow, ask the user instead of thinking for a long time or choosing silently.
5774

5875
For lightweight shell inspection, respect the exact allowlist boundary:
5976

@@ -77,6 +94,16 @@ If you choose direct mode, invoke `developer` with:
7794
- minimum acceptance criteria;
7895
- expected validation.
7996

97+
Do not mentally implement the solution before delegating. Any handoff to another
98+
agent must be self-contained and include:
99+
100+
- objective;
101+
- minimum context and known paths, when available;
102+
- user constraints;
103+
- explicit assumptions;
104+
- expected output;
105+
- expected validation or evidence.
106+
80107
Once you delegate an implementation task to `developer`, keep that ownership for
81108
the whole loop of the same free-form request. If your review finds a missing
82109
adjustment, bug fix, cleanup, test, or additional implementation change, send a
@@ -118,6 +145,9 @@ Do not skip phases unless the work is genuinely trivial or you explicitly routed
118145
implementation correction goes back to `developer`.
119146
- Never invoke `reviewer` before there is a diff or implementation to review.
120147
- If `reviewer` returns `requires changes`, synthesize the findings, send a bounded correction task to `developer`, then invoke `reviewer` again.
148+
- Do not review a diff yourself except to decide which agent should receive it
149+
or to consolidate the `reviewer` verdict; bug, security, regression, and
150+
compliance review belongs to `reviewer`.
121151
- Do not insert `evaluator`, `debugger`, or `evolver` as mandatory feature phases.
122152
- Never invoke `evolver` for normal app features.
123153

opencode/docs/ai/harness/agents.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
- `lead` must not force the full flow for small free-form messages.
2222
- `lead` does not edit files; if implementation or correction requires repo
2323
changes, delegate to `developer`.
24+
- `lead` does not develop, deeply investigate code, or review diffs as a
25+
substitute for `researcher` or `reviewer`; it only gathers minimum routing
26+
context.
27+
- If `lead` needs to understand how the code works before deciding what to do,
28+
it delegates substantive discovery to `researcher`.
29+
- If there is a diff, implementation, or reviewable plan, bug, security,
30+
regression, and compliance review belongs to `reviewer`.
31+
- Every `lead` handoff to another agent must be self-contained: objective,
32+
minimum context, constraints, assumptions, expected output, and expected
33+
validation or evidence.
2434
- During lightweight shell inspection, `lead` should prefer exact allowlisted
2535
primitives already named by the user, without drifting to nearby substitutes
2636
or compound shell commands when a single call is enough.

opencode/docs/ai/harness/commands.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ Contract: `lead` router -> appropriate agent.
77
Criteria:
88

99
- `lead` decides quickly between `developer`, `researcher`, `designer`, or `specifier`.
10+
- `lead` may inspect only the minimum needed for routing; if it needs to
11+
understand code behavior or diagnose flow, it delegates to `researcher`.
1012
- If the change is small, clear, and low risk, delegate to `developer` with minimum validation.
1113
- If there is technical/product uncertainty, delegate to `researcher`.
1214
- If there is UX/UI, brand, layout, interaction, or visual criteria impact, delegate to `designer`.
1315
- If enough context exists but tasks, criteria, or a plan are missing, delegate to `specifier`.
16+
- If there is a diff, implementation, or reviewable plan, delegate review to
17+
`reviewer` instead of reviewing it as `lead`.
1418
- If ambiguity changes the correct flow, ask the user before delegating.
1519

1620
## `/feature`
@@ -40,6 +44,8 @@ Criteria:
4044
independent.
4145
- `developer` does not act without acceptance criteria.
4246
- `reviewer` does not act without a reviewable diff.
47+
- `lead` does not replace `reviewer`; it only consolidates the verdict and sends
48+
bounded fixes back to `developer` when changes are required.
4349

4450
## `/plan`
4551

opencode/scripts/check-harness.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ function checkLeadRouterContract() {
152152
"whole loop of the same free-form request",
153153
"bounded task back to `developer`",
154154
"implementation correction goes back to `developer`",
155+
"does not develop",
156+
"does not deeply",
157+
"minimum",
158+
"context needed to",
159+
"delegate to `researcher`",
160+
"`reviewer`",
161+
"Do not mentally implement the solution before delegating",
162+
"handoff to another",
163+
"must be self-contained",
164+
"Do not review a diff yourself",
155165
]) {
156166
if (!text.includes(token)) fail(`agents/lead.md: missing ${token}`);
157167
}
@@ -161,9 +171,23 @@ function checkLeadRouterContract() {
161171
"`lead` does not edit files",
162172
"later adjustments for that",
163173
"same free-form request go back to `developer`",
174+
"`lead` does not develop",
175+
"delegates substantive discovery to `researcher`",
176+
"belongs to `reviewer`",
177+
"Every `lead` handoff to another agent must be self-contained",
164178
]) {
165179
if (!docs.includes(token)) fail(`docs/ai/harness/agents.md: missing ${token}`);
166180
}
181+
182+
const commandDocs = read("docs/ai/harness/commands.md");
183+
for (const token of [
184+
"understand code behavior",
185+
"delegates to `researcher`",
186+
"delegate review to",
187+
"`lead` does not replace `reviewer`",
188+
]) {
189+
if (!commandDocs.includes(token)) fail(`docs/ai/harness/commands.md: missing ${token}`);
190+
}
167191
}
168192

169193
function checkFrontmatter() {

0 commit comments

Comments
 (0)