Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/orchestrate-fold-subagents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"j03fr0st-skills": minor
---

`orchestrate` now keeps work with the root by default and delegates only for a fresh, discardable context (parallel work or context-heavy reading), an independent review or check, or a user or repository requirement. Slices are split by context rather than role, so chained steps that consume each other's output go to one worker; dependent workers receive artifacts ahead of reports; and the worker contract gains a shared return shape.
6 changes: 5 additions & 1 deletion docs/engineering/orchestrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ The definitions use `orchestrate-` names to coexist with existing roles. There i

## How it chooses work and models

Work stays with the root by default. One context can connect steps that a worker's summary loses, and each dispatch adds a nested model loop. The root delegates a slice only when it needs a fresh context it can throw away (independent parallel work, or reading so much that the root's context would degrade), when it needs independence (a review or check that must not see the producer's reasoning), or when the user or repository rules require agents. Slices are split by context, not by role: steps that use each other's output or touch the same data go to one worker. A dependent worker gets the earlier worker's diff or files, not just its report, and every worker returns the same shape: status, artifacts, evidence, open decisions and skills loaded.

The root first checks the available native tools, role definitions, model catalog and governing instructions. An explicit user or repository profile wins over an economical default. The selected root model remains unchanged.

Routing considers ambiguity, failure impact and how easily the result can be checked. Narrow extraction can use a fast model; difficult diagnosis and consequential review justify stronger reasoning. Availability is checked in the active host, so a model mentioned in a template is not treated as proof of access.
Expand Down Expand Up @@ -58,7 +60,7 @@ Model selection does not expand permissions. Setup, profile changes and installa

## Evaluation and design basis

The [evaluation cases](../../skills/engineering/orchestrate/evals/evals.json) cover small-task routing, forced model overrides, interrupted writers, locked roles, stale verification, unavailable native tools, shared-schema dependencies, repeated failure and worktree isolation on a feature branch. Offline scenario evaluations test decisions; live native dispatch and repeated task benchmarks are needed to establish model identity, correctness and usage improvements.
The [evaluation cases](../../skills/engineering/orchestrate/evals/evals.json) cover small-task routing, forced model overrides, interrupted writers, locked roles, stale verification, unavailable native tools, shared-schema dependencies, repeated failure, worktree isolation on a feature branch, collapsing an explorer-to-worker chain into one worker, and keeping an in-context multi-file diagnosis with the root. Offline scenario evaluations test decisions; live native dispatch and repeated task benchmarks are needed to establish model identity, correctness and usage improvements.

See the [skill validation record](../research/2026-09-26-model-orchestration/skill-validation.md) and [native agent validation](../research/2026-09-26-model-orchestration/native-agents-validation.md) for the checks performed and their limits.

Expand All @@ -67,3 +69,5 @@ The [research report](../research/2026-09-26-model-orchestration/README.md) and
The [2026-10 source sweep](../research/2026-10-06-source-repos-sweep.md) adds file-based worker results, returning only a path, from EveryInc's `ce-compound`.

The [2026-11 source sweep](../research/2026-11-16-source-repos-sweep.md) adds fresh-context workers with consolidated scope (Matt Pocock's subagent change, Cursor pstack's `poteto-mode`), batching same-shape edits and one fixer for a review's findings (Superpowers' `subagent-driven-development`), reasoning-blind verification (Trail of Bits' `patching-bugs`), a capped fix loop with recorded rulings, and a final list of rulings with their cost if wrong (Superpowers).

The [2026-11-30 fold research](../research/2026-11-30-orchestrate-fold-subagents.md) adds the root-only default, the three delegation cases, splitting by context, artifact-first handoffs and the shared return shape, from Anthropic's article on folding subagents into the main agent loop, supported by Superpowers' `dispatching-parallel-agents` and Addy Osmani's orchestration patterns.
137 changes: 137 additions & 0 deletions docs/research/2026-11-30-orchestrate-fold-subagents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Orchestrate: when to fold subagents into the root loop

Date: 2026-11-30. Scope: tighten when `orchestrate` delegates, how it splits
slices, and what workers return, based on one article and a check of the
preferred source repositories.

## Source article

[Building agents: when to fold subagents into your main agent loop](https://claude.com/resources/articles/building-agents-when-to-fold-subagents-into-your-main-agent-loop)
(Anthropic Applied AI, 2026-10-22). It targets production enterprise agents, not
coding-agent skills, so the claims below are translated rather than applied
literally. It reports few numbers (one customer saw roughly 2x faster runtime
with a single loop) and gives no methodology for them.

Claims used:

1. A single loop with progressive disclosure (skills and deferred tools) now
beats a coordinator-plus-specialists design for many tasks, because one
context can connect steps that subagent summaries lose.
2. Keep a subagent only when (a) the single loop measurably degrades from
context bloat, (b) work runs in parallel in fresh contexts that can be
discarded, or (c) tool selection or conflicting instructions break the
single loop.
3. Split by context, not by problem type. A split by problem type becomes a
"telephone game" where fidelity drops at each handoff. Good candidates:
independent research paths, components with clean interfaces, and
black-box verification.
4. Merge specialists that chain on each other's output, touch the same data, or
are usually called together.
5. Subagents return compact results in a shared response schema; the main agent
checks conclusions against real data.
6. Each subagent call is a nested model loop, so it adds latency.
7. Change one thing at a time, run tasks more than once, and compare which
tasks flipped rather than only the total score.

Claims not used here: org ownership, MCP tool design, and the migration kit
apply to product agents. Claim 7 belongs to evaluation work (a cross-skill
routing eval is the planned follow-up).

## Preferred repositories

Read `docs/source-repos.md` first; order unchanged. Revisions checked
2026-11-30 unless noted. The 2026-09-26 orchestration ledger
([preferred-sources.md](2026-09-26-model-orchestration/preferred-sources.md))
still describes the earlier influence of each repository.

| # | Repository | Revision | Influence on this change |
| --- | --- | --- | --- |
| 1 | `mattpocock/skills` | `255351f0a1d3` | `.out-of-scope/subagent-recursion.md`: recursion limits belong to the harness, not skill prose. Confirms not adding depth-limit prose; orchestrate's existing no-recursion line stays because the role definitions enforce it as tool policy. |
| 2 | `obra/superpowers` | `22f0b463e7a5` | `dispatching-parallel-agents`: dispatch only for independent domains with no shared state; related failures go to a single agent. `subagent-driven-development/references/batching.md`: batch same-shape work into one dispatch (already adopted). Supports claims 3 and 4. |
| 3 | `addyosmani/agent-skills` | `e997ac5b9a74` | `references/orchestration-patterns.md`: direct invocation is the default; research isolation is worth it when the alternative is loading large material into the main context; an LLM lifecycle orchestrator loses nuance by summarizing at each handoff. Strongest support for the "context-heavy reading" criterion and against chained handoffs. |
| 4 | `cursor/plugins` (pstack) | `4d5593ed7f5d` | No new delegation guidance since the 2026-11 sweep; earlier influence (done predicates, isolated outputs) unchanged. |
| 5 | `DietrichGebert/ponytail` | not re-checked | Evaluation guidance (measure per workload) already recorded; not applicable to routing prose. |
| 6 | `mvanhorn/last30days-skill` | not re-checked | Research mechanics only; not applicable. |
| 7 | `anthropics/skills` | `e4bb5d960d87` | No orchestration skill; skill-creator's baseline-comparison method informs the eval additions. |
| 8 | `trailofbits/skills` | not re-checked | Reasoning-blind verification already adopted (Step 6); it is the article's "black-box verification" case. |
| 9 | `EveryInc/compound-engineering-plugin` | not re-checked | File-based worker results already adopted; unchanged. |
| 10 | `garrytan/gstack` | not re-checked | Dispatch-identity guard and stall deadlines already adopted; nothing on fold criteria. |
| 11 | `affaan-m/ECC` | not re-checked | Chain bounds already reflected; nothing new. |
| 12 | `wshobson/agents` | `c96b5f6552db` | Large specialist-per-domain catalog (for example a context-manager agent). Cited as the sprawl pattern the article warns about; not adopted. |
| 13 | `nahid-sparktales/agent-dispatcher` | `564c3f0e39d9` | "Direct" route for trivial or one known-file work, and passing the request verbatim rather than a summary. Supports passing artifacts and full directives instead of summaries. |
| 14 | `humanlayer/skills` | `4d69d20f6e9b` | RPI's locator/analyzer subagents are read-only context-isolation workers that return locations, not analysis. Matches the "context-heavy reading" case. |
| 15 | `testdouble/han` | `abba73a77352` | ADR 0001 sizes swarms by work band and announces the chosen band. Not adopted: orchestrate already caps concurrency at two by default. |

## Gap in orchestrate before this change

- Step 2 delegated on "difficult diagnosis or research" without asking whether
the root's own context would serve better. Diagnosis often needs one context
to connect symptoms, so the trigger is context volume, not difficulty.
- No rule merged slices that chain on each other's output; Step 3 passed an
earlier worker's report to the next, which is the telephone-game handoff.
- Role definitions shared a return skeleton, but the contract template had no
return slot, so a worker spawned without the bundled roles had no shape to
follow.

## Decisions

1. Step 2 defaults to root-only and names three delegation cases: a fresh,
discardable context (parallel independent work or context-heavy reading),
independence (review or verification blind to the producer), or a user or
repository requirement.
2. Split by context: a slice needs little from the rest of the run and returns
a compact result. Slices that consume each other's output, touch the same
data, or always run together are one slice.
3. A dependent slice receives the producing worker's artifacts (diff, files,
branch) ahead of its report.
4. The contract template gains a `Return shape` slot matching the roles'
existing skeleton: status first, artifacts by path or diff, evidence, open
decisions, skills last.
5. `routing.md` replaces the "difficult diagnosis" row with context-heavy
reading and adds a chained-steps row.

Rejected: rewriting the role return formats (they already share the skeleton),
adding depth limits in prose (harness concern, per mattpocock), and swarm-size
bands (concurrency cap already exists).

## Verification

Two offline evals cover the new branches. Paired runs on 2026-11-30: each sample
ran in a fresh Opus context that read only the skill directory (evals, assets
and scripts removed). Control arm A was the `main` version; arm B the edited
one. Graded by hand against `expectations`, unblinded.

**Round 1** used first-draft scenarios (a function rename chain; a one-file race
plus a p-retry version question). Both arms scored the same on every
expectation: the old skill merged the rename through its same-shape batching
rule and delegated the version question through its "current external fact"
row. The rename scenario's "keep a reviewer" expectation also conflicted with
the skill (1/3 in each arm). Both scenarios were replaced.

**Round 2** (current `evals.json`):

| Eval | Expectation | Arm A (old) | Arm B (new) |
| --- | --- | --- | --- |
| 13, CSV export with explorer, worker, tester, reviewer proposed | No explorer summary handed to the implementer | 0/3 | 3/3 |
| 13 | Dependants get artifacts, not only reports | 0/3 | 3/3 |
| 13 | Reviewer gets diff and contract only | 3/3 | 3/3 |
| 14, deadlock across three files already read | Diagnosis stays with the root | 3/3 | 3/3 |
| 14 | Reason is context held, not difficulty | 3/3 | 3/3 |
| 14 | Any agent serves independence (reviewer) | 3/3 | 3/3 |
| 1 (regression, round 1) | | — | 2/2 |
| 7 (regression, round 1) | | — | 2/2 |

All three old-arm runs of eval 13 kept the four-stage chain and passed the
explorer's report to the worker as its starting input; all three new-arm runs
merged mapping, implementation and tests into one worker and kept only the
independent reviewer, citing "split by context, not by role".

Eval 14 does not discriminate: the old skill already kept an in-context
diagnosis with the root ("small, localized, readily checked in the current
context"), so removing the "difficult diagnosis" trigger has no measured effect.
It stays as a regression guard.

Result: the split-by-context and artifact-first rules change behaviour (eval 13,
0/3 to 3/3); the root-only default and the diagnosis rewording are supported by
the article and source repositories but not by a measured difference. Grading
was by the author with arms known; three reps per arm is a small sample.
13 changes: 10 additions & 3 deletions skills/engineering/orchestrate/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: orchestrate
description: Coordinate non-trivial engineering work with bounded native subagents when independent execution, difficult diagnosis, current research, or an independent review materially helps. Use when asked to use subagents, run slices in parallel, delegate to workers, or install/configure orchestrate agents. Keep small, local, readily verifiable work with the root agent; slicing belongs to planning-and-task-breakdown, local execution to implement, and isolated checkouts to git-worktrees.
description: Coordinate non-trivial engineering work with bounded native subagents when independent parallel work, context-heavy research or investigation, or an independent review materially helps. Use when asked to use subagents, run slices in parallel, delegate to workers, or install/configure orchestrate agents. Keep small, local, readily verifiable work with the root agent; slicing belongs to planning-and-task-breakdown, local execution to implement, and isolated checkouts to git-worktrees.
---

# Orchestrate
Expand All @@ -24,14 +24,20 @@ Treat the host's native tool schema, configured roles, model catalog, permission

Read [references/routing.md](references/routing.md) when deciding whether to delegate or which role/model tier to request.

Keep the work root-only when it is small, localized, and readily checked in the current context. Delegate when there is an independent bounded slice, useful parallel work, difficult diagnosis or research, a material independent review, or an explicit request for agents. Split by observable outcome and dependency; keep shared contracts and architecture decisions with the root.
Default to root-only: one context connects steps that a worker's summary loses, and every dispatch adds a nested loop. Delegate a slice only when it needs:

- **a fresh, discardable context:** independent parallel work, or reading so much material (wide search, long logs, external research) that the root's context would degrade;
- **independence:** a review or verification that must not see the producer's reasoning;
- **compliance:** the user or repository rules require agents.

Split by context, not by role: each slice needs little from the rest of the run and returns a compact result. Slices that consume each other's output, touch the same data, or always run together are one slice for one worker or the root. Keep shared contracts and architecture decisions with the root.

**Complete when:** the route is `root-only` or a list of ready slices with dependencies and ownership.

## 3. Dispatch real bounded work

- **Real native calls only:** Call the active harness's native spawn/subagent tool before doing that slice in the root. A plan, simulated transcript, or narration is not a spawn. Dispatch independent ready slices together; serialize dependent slices. Batch the same small edit repeated across files into one contract for one worker and review it as one diff.
- **Fresh context with consolidated scope:** Start every worker with a fresh context window, not a fork of the root conversation, passing the original contract, every later directive, and any earlier worker's report and branch (including fix rounds, follow-ups, and retries). Resume an existing worker only when the new work needs state that lives inside it and is costly to move, such as uncommitted changes or a running process; chained resumes can drop directives silently.
- **Fresh context with consolidated scope:** Start every worker with a fresh context window, not a fork of the root conversation, passing the original contract, every later directive, and any earlier worker's artifacts (diff, files, branch) ahead of its lossy report, including for fix rounds, follow-ups, and retries. Resume an existing worker only when the new work needs state that lives inside it and is costly to move, such as uncommitted changes or a running process; chained resumes can drop directives silently.
- **Contract shape:** Give every worker outcome and constraints while leaving method to the worker:

```text
Expand All @@ -41,6 +47,7 @@ Applicable skills: exposed identifiers or exact SKILL.md paths; required versus
Files/subsystem owned; files that must not change:
Prerequisites:
Expected artifact and acceptance criteria:
Return shape: status (completed/blocked/failed); artifacts by path or diff; evidence; open decisions for the root; skills loaded/missing:
Role, requested model and effort when the native schema supports them:
Inherited tools/permissions:
Deadline and stall recovery (what the root does if it passes or the dispatch returns nothing):
Expand Down
Loading