Skip to content

feat(agents): specialists hand routing back instead of spawning - #123

Draft
knihit wants to merge 2 commits into
fix/direct-work-hardeningfrom
feat/specialists-return-routing
Draft

knihit wants to merge 2 commits into
fix/direct-work-hardeningfrom
feat/specialists-return-routing

Conversation

@knihit

@knihit knihit commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

On GPT models under Kiro CLI v3, specialists re-delegate to orchestrators and cascade to the depth limit: about 19 spawns per run on main against about 2 for Claude. About 70% of deep spawns sit under an orchestrator self-spawn, and the rest are specialist-to-specialist chains. This PR gives specialists one always-loaded rule: do your part and hand routing back. The stacked PR enforces it in config.

Context / system prompts:

  • context/k-core-rules.md: new ## Specialist handoffs section. A k-* specialist never spawns an orchestrator or another specialist. It finishes its part, then returns a note naming the role the rest needs, or a proposed parallel split with the files each part touches. A denied action is not a handoff: the specialist reports it and stops. The rule wins over skill or SOP text that says to spawn.
  • context/k-orchestrator-routing-rules.md: orchestrators route a handoff note to the named role, and check a proposed split for disjoint files before fanning it out.

Skills:

  • skills/delegation-protocol/SKILL.md: the same handoff and split handling, next to the disjoint-files rule.

Agents:

  • k-architect, k-quality-assurance, k-tpm: removed the "Subagent Delegation" sections and "offer to spawn" steps, so the prompts do not contradict the rule.

Docs / Other:

  • docs/user-guide/concepts.md, docs/user-guide/sop-workflows/testing-and-specs.md: say specialists return to the orchestrator instead of spawning.
  • CHANGELOG.md: one [Unreleased] bullet. No VERSION bump.

Always-loaded bytes added per agent (same on Kiro CLI v3, Kiro CLI v2 and Claude Code): k-browser, k-developer, k-media-analyzer, k-product-manager, k-researcher +682; k-quality-assurance +545; k-tpm +475; k-architect +467; the three orchestrators +1044. The three specialists come in lower because their old delegation sections were removed.

Type of Change

  • Modify existing skill
  • New or updated agent spec
  • Context / system prompt update
  • Documentation

Testing

  • npm test passes (runs tests/scripts/**/*.test.js)
    Not clean: 119 of 136 pass. The same 17 fail on unmodified main (missing scripts/brand-config/lib/constants.js).
  • make build, make synth, make test-skills-sh, make claude-plugin-check, make kiro-power-check: pass
  • make test-py: 222 passed. make test-rust: cli 1779, mcp 318, shared 76 passed (one known macOS-flaky test passed on an isolated rerun)
  • Smoke tested affected agent(s): installed with konductor install --from <tree> into a scratch project on Kiro CLI v3 and Claude Code, ran k-architect and konductor headless. With this rule in place, Claude Code's k-architect refused a spawn request and cited the rule.
  • Ran the benchmark harness for the affected agent (npm run benchmark)
    Not run. A separate 72-run A/B was run against the top of the stack instead; see Benchmark below.
  • No new code files; only Markdown and JSON changed

make guide-check reports one failure that also exists on main (config is listed as withdrawn but cli/README.md no longer declares it). Unrelated to this PR.

Benchmark

This change was not benchmarked on its own. The numbers below cover this PR and the stacked config deny PR together, measured at the top of the stack.

Setup: main vs the stacked branch, three cells (a GPT model on Kiro CLI v3, a Claude Sonnet model on Kiro CLI v3, a Claude Sonnet model on Claude Code), 4 cases (small feature with tests, bug fix, design doc plus threat model, implement then document then review), 3 reps each, every run in a fresh isolated project and HOME installed with --no-telemetry. 72 runs.

cell n spawns/run self-spawns spec to spec max depth depth-limit rejections cost/run wall s/run success
GPT, Kiro CLI v3 main 12 7.9 4 30 6 6 59.2 credits 478 9/12
GPT, Kiro CLI v3 branch 12 3.2 0 0 1 0 30.5 credits 253 9/12
Claude Sonnet, Kiro CLI v3 main 12 1.9 0 0 1 0 5.2 credits 122 10/12
Claude Sonnet, Kiro CLI v3 branch 12 2.0 0 0 1 0 5.0 credits 120 8/12
Claude Sonnet, Claude Code main 12 1.8 0 0 1 0 $0.87 105 11/12
Claude Sonnet, Claude Code branch 12 1.9 0 0 1 0 $0.93 114 11/12

Spec to spec counts spawns where a specialist spawned another specialist; max depth 6 means an attempt hit Kiro's depth limit.

On the GPT cell, specialist spawning, self-spawns and depth-limit hits went to zero, and spawns, credits and wall time roughly halved, with task success unchanged. The Claude cells did not change on spawns or cost. One regression to watch: Claude on Kiro CLI v3 went from 3/3 to 1/3 on the implement, document and review case, both times on the file-scope check, not on the feature itself.

Follow-up on that case: neither miss involved a specialist spawn or a handoff note. One was a review file written by Kiro's built-in reviewer, which the orchestrator chose on its own, and the other was a README line k-developer edited during implementation. Five more reps per side, with the branch at this stack's final head: main 2/5, branch 5/5, and main hit the same reviewer-file miss once. Over 8 reps that is main 5/8 and branch 6/8, so the drop reads as run-to-run variance.

Caveats: n=3 per case, so only the design plus threat model case shows a clear, non-overlapping difference. One main GPT run timed out, so its counts are lower bounds. The later wording change to the denial sentence in context/k-core-rules.md is wording-only and was made after the benchmark.

Checklist

  • My code follows the style guidelines of this project (see AGENTS.md's Code Style & Conventions)
  • I have performed a self-review of my own changes
  • I have commented my code where necessary
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings: build is clean (no cli/ change in this PR)
  • I have added or updated tests that prove my change works
    Prompt-only change; the stacked PR adds tests for the config deny.

Agents Affected

  • konductor
  • konductor-mux-orchestrator
  • konductor-cmux-orchestrator
  • k-developer
  • k-architect
  • k-researcher
  • k-product-manager
  • k-quality-assurance
  • k-tpm
  • k-browser
  • k-media-analyzer

Notes for Reviewers

  • Stacked on fix(orchestrator): tighten the direct-work rules #114, which edits the same three files. The denial sentence here points at the routing rules' definition of a denied action, which fix(orchestrator): tighten the direct-work rules #114 adds.
  • Skill and SOP text that still tells a specialist to spawn (for example the review and test-coverage SOPs and deliberation-panel) is overridden by the core rule, not rewritten.
  • Spawn grants in the spec configs are unchanged here. The stacked PR removes them and denies the spawn tools in synth output.
  • The hand-authored HTML guide bundles were not updated for the Markdown prose edits.

Nihit Kasabwala added 2 commits October 29, 2026 00:32
Specialists (k-*) now follow one always-loaded rule in k-core-rules.md:
never spawn an orchestrator or another specialist. They do their own
part, then return a note naming the role the rest needs, or a proposed
parallel split with the files each part touches. A permission denial is
not a handoff; the specialist asks the user. Orchestrators get a matching
instruction in k-orchestrator-routing-rules.md and delegation-protocol.

Removes the "Subagent Delegation" sections and "offer to spawn" steps from
k-architect, k-quality-assurance and k-tpm so the prompts do not
contradict the rule. Spawn grants in spec configs are unchanged.

Always-loaded bytes added (same on Kiro v3, Kiro v2, Claude Code):
k-browser, k-developer, k-media-analyzer, k-product-manager,
k-researcher +646; k-quality-assurance +509; k-tpm +439;
k-architect +431; konductor, konductor-mux-orchestrator,
konductor-cmux-orchestrator +1008.

Verified: make build, make synth, test-skills-sh, claude-plugin-check
pass; test-py 222 passed and kiro-power-check pass (pytest 8.3.4,
PyYAML 6.0.2 venv); test-rust cli 1779, mcp 318, shared 76 passed
(resolve_cwd_json_envelope flaked once, passed rerun alone).
guide-check reports one failure that also exists on main (withdrawn
config command).
…ition

Wording only: a denied action is not a handoff, report it and stop.
Verified: make build, make synth, make test-skills-sh pass.
@knihit
knihit removed this pull request from stack #125 October 29, 2026 04:37
@knihit
knihit force-pushed the feat/specialists-return-routing branch from f1f6718 to f5dd0ad Compare October 29, 2026 04:37
@knihit
knihit changed the base branch from main to fix/direct-work-hardening October 29, 2026 04:37
@knihit
knihit added this pull request to stack #134 October 29, 2026 04:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant