--- name: delegation-router description: Decide execution mode and model tier for tasks with low noise. Use when planning work and choosing between direct execution, spawning a subagent/fresh implementation session, or delegating via ACP sessions_spawn. Includes a routing matrix, complexity/risk model-tier policy (including Claude ACP tiers), fresh-session implementation rule, and practical sessions_spawn payload patterns. --- # Delegation Router Use this as a fast preflight before implementation. ## 1) Route selection matrix (direct vs subagent vs ACP) Choose the **least heavy path** that still gives reliable outcomes. | Task shape | Route | Default reason | |---|---|---| | Tiny, low-risk, 1-3 edits/commands, no long wait | **Direct in current session** | Lowest overhead, fastest feedback | | Multi-step implementation, broad file exploration, likely >10 min, or context getting long | **Subagent / fresh isolated session** | Keeps main session clean; better execution focus | | Explicit provider/runtime requirement (Claude/Codex/Pi) or model-specific quality need | **ACP via `sessions_spawn`** | Deterministic runtime + model control | | High-stakes review/architecture where correctness risk is high | **ACP high tier (or experienced subagent + review)** | Better reasoning headroom | Quick routing rules: - Stay **direct** for simple fixes and read-only checks. - Spawn **fresh implementation context** by default for non-trivial build/refactor/debug tasks. - Use **ACP** when runtime/model selection is itself part of the requirement. ## 2) Model-tier policy Pick the lowest tier that safely meets quality. ### Complexity bands - **Light**: small rewrite, single-file tweak, straightforward lookup, routine formatting. - **Medium**: multi-file feature/fix, moderate debugging, synthesis across several sources. - **Heavy**: architecture changes, ambiguous root-cause investigations, high-impact reviews, security-sensitive reasoning. ### Tier map (LiteLLM / aliases) - **Light** → economy/fast tier - default target: **GLM 4.7 Flash** (`litellm/glm-4.7-flash`) - **Medium** → balanced default - default target: **GLM 5** (`litellm/glm-5`) - **Heavy** → top-reasoning tier - default target: **GPT 4.5** (`litellm/gpt-4.5`) Escalate only when: - prior attempt failed quality bar, - ambiguity remains high after basic triage, - failure cost is materially high. ## 3) Fresh-session implementation rule For non-trivial work: 1. Scope and plan in current session. 2. Write concise baton files (`WIP.md`, optionally `HANDOFF.md`) with goal, next actions, blockers, success criteria. 3. Execute in a **fresh implementation session** (subagent or ACP run). 4. Return with outcome + evidence (diff/tests/outputs), not long play-by-play. Do not drag long conversational context into implementation if file-based handoff is enough. ## 4) `sessions_spawn` patterns (ACP examples) Use one clean spawn per coherent task (avoid noisy micro-spawns). ### Light (GLM 4.7 Flash) ```json { "runtime": "acp", "agentId": "claude", "model": "litellm/glm-4.7-flash", "task": "Apply a small docs wording fix in docs/README.md and return exact diff." } ``` ### Medium (GLM 5, default) ```json { "runtime": "acp", "agentId": "claude", "model": "litellm/glm-5", "task": "Implement feature X across files A/B/C, run targeted tests, and summarize decisions." } ``` ### Heavy (GPT 4.5) ```json { "runtime": "acp", "agentId": "claude", "model": "litellm/gpt-4.5", "task": "Review architecture tradeoffs for Y, propose final design, then implement with safety checks." } ``` If `sessions_spawn` is unavailable in the current tool surface, use the available delegation primitive (for example, `subagents`) and keep the same routing + tier logic. ## 5) Low-noise defaults - Prefer one solid delegation run over many tiny ones. - Do not poll aggressively; rely on push completion or sparse status checks. - Keep instructions compact and outcome-based (goal, constraints, acceptance criteria). - Ask for only necessary artifacts: patch/diff, test result, short rationale. - Summarize back in 5-10 lines unless user asks for depth. ## 6) Fast decision checklist - Is task tiny and safe? → direct. - Is it non-trivial implementation? → fresh session/subagent. - Do I need explicit runtime/model control? → ACP `sessions_spawn`. - Complexity/risk band? → Light/Medium/Heavy tier. - Can I reduce noise further? → fewer spawns, fewer polls, concise outputs.