Skip to content

/review: run the whole pipeline in a fork subagent context (prereq: #9782) #9784

Description

@wenshao

Background

A full /review high run injects the ~95k-token SKILL.md, then accumulates 14(+) agent returns, ceil(F/8) verifier shards, 2–10 reverse-audit rounds (per-chunk on 3B), pr-context, compose and submit output — all in the user's main conversation. Two costs:

  1. Correctness: if the main session compacts mid-review, Step 4 dedup/merge state and Step 6 compose inputs silently degrade to a compaction summary.
  2. UX: after one PR review the user's prior working context is effectively gone; concurrent reviews are impossible at the orchestration layer even though worktree isolation already makes them safe on disk.

Claude Code runs its entire /code-review in a fork context by default (tool output never reaches the parent conversation) unless a findings-rendering tool takes over. DESIGN.md's "Future optimization: Fork Subagent" proposes forking each finder (a token optimization); this issue is the other, independent layer: run the whole orchestrator in one fork.

Prerequisite

#9782 — nested sub-agent approvals under a background/fork parent hang forever. The fix is on branch fix/nested-agent-approval-bubble. Without it, Agent 7's build/test run_shell_command deadlocks the review silently under the default approval mode.

Remaining work (verified against current source)

  1. Fork systemPrompt conflict: the fork agent's systemPrompt says "Do not spawn sub-agents." (fork-subagent.ts:32), which contradicts the review fan-out. fork-profile's promptHint caps at 200 chars (fork-profile.ts:17) — needs a dedicated profile or an override for this line. The hard guard only blocks nested forks (agent.ts), and nested regular sub-agents are forced foreground — which matches SKILL.md's required run_in_background: false.
  2. Interactive stop paths: SKILL.md has 9+ "tell the user and stop" branches (match-remote ambiguity, refused resume, Aone URL outside its clone, empty capture…). A fork has no inline UI; these must become "fail inside the final report with the explanation".
  3. Progress: today the user watches the review advance; in a fork, tool output stays out of the parent. Needs progress surfacing (the Background-tasks activity feed already carries per-tool events).

Rollout

Gate by effort: low (0 sub-agent calls) can fork today; medium/high after #9782 lands. Since high is the default for PR targets, #9782 is the first domino.

Non-goals

  • This does not reduce tokens (a fork inherits parent context; the per-finder fork cache-sharing from DESIGN.md is a separate, compatible optimization).
  • No recall/precision change intended.
中文摘要

把整个 /review 编排放进 fork 子上下文:95k token 的 SKILL、十几个 agent 返回、逆审各轮输出不再占用主对话;评审在不被压缩的独立窗口跑完(修复 Step 4/6 中途被压缩的正确性风险);顺带解锁并发评审。前置缺陷 #9782(嵌套审批挂起)已在修。剩余工作:fork systemPrompt 的 "Do not spawn sub-agents" 冲突(需专用 profile)、9+ 处"告知用户并停下"分支改造为报告内失败、进度上报。推广顺序:low 先行,medium/high 等 #9782。注意这不省 token——与 DESIGN.md 的 per-finder fork 优化是两层,可叠加。

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    category/coreCore engine and logicpriority/P0Critical/Blocker - Catastrophic failure, immediate attentionroadmap/multi-agentRoadmap: Multi-agent collaborationscope/coretype/enhancementNon-bug improvement or optimization

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions