From d96671b9e9ecbe417568b2ce7f7fa4d379c2bec2 Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Sun, 8 Mar 2026 12:51:56 -0700 Subject: [PATCH] fix(review): add serial mode to prevent context limit crashes Adds --serial flag and auto-detection (6+ agents) to run review agents sequentially instead of in parallel, preventing context limit errors with Opus 4.6. Closes #166 Co-Authored-By: Claude Opus 4.6 --- .../commands/ce/review.md | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/plugins/compound-engineering/commands/ce/review.md b/plugins/compound-engineering/commands/ce/review.md index cf4a061..65aebff 100644 --- a/plugins/compound-engineering/commands/ce/review.md +++ b/plugins/compound-engineering/commands/ce/review.md @@ -1,7 +1,7 @@ --- name: ce:review description: Perform exhaustive code reviews using multi-agent analysis, ultra-thinking, and worktrees -argument-hint: "[PR number, GitHub URL, branch name, or latest]" +argument-hint: "[PR number, GitHub URL, branch name, or latest] [--serial]" --- # Review Command @@ -65,17 +65,50 @@ Read `compound-engineering.local.md` in the project root. If found, use `review_ If no settings file exists, invoke the `setup` skill to create one. Then read the newly created file and continue. +#### Choose Execution Mode + + + +Before launching review agents, check for context constraints: + +**If `--serial` flag is passed OR conversation is in a long session:** + +Run agents ONE AT A TIME in sequence. Wait for each agent to complete before starting the next. This uses less context but takes longer. + +**Default (parallel):** + +Run all agents simultaneously for speed. If you hit context limits, retry with `--serial` flag. + +**Auto-detect:** If more than 5 review agents are configured, automatically switch to serial mode and inform the user: +"Running review agents in serial mode (6+ agents configured). Use --parallel to override." + + + #### Parallel Agents to review the PR: +**Parallel mode (default for ≤5 agents):** + Run all configured review agents in parallel using Task tool. For each agent in the `review_agents` list: ``` Task {agent-name}(PR content + review context from settings body) ``` -Additionally, always run these regardless of settings: +**Serial mode (--serial flag, or auto for 6+ agents):** + +Run configured review agents ONE AT A TIME. For each agent in the `review_agents` list, wait for it to complete before starting the next: + +``` +For each agent in review_agents: + 1. Task {agent-name}(PR content + review context) + 2. Wait for completion + 3. Collect findings + 4. Proceed to next agent +``` + +Always run these last regardless of mode: - Task agent-native-reviewer(PR content) - Verify new features are agent-accessible - Task learnings-researcher(PR content) - Search docs/solutions/ for past issues related to this PR's modules and patterns