Skip to content

fix(review-workflow): prevent context overflow in Expert Code Review workflow#8199

Merged
Evangelink merged 2 commits into
mainfrom
copilot/fix-expert-code-review-failure
May 14, 2026
Merged

fix(review-workflow): prevent context overflow in Expert Code Review workflow#8199
Evangelink merged 2 commits into
mainfrom
copilot/fix-expert-code-review-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

Bug Fix

What was the bug?

The primary agent (claude-sonnet-4.6) was reading the background expert-reviewer subagent's full result after launching it. The subagent spawns ~21 dimension sub-agents, accumulating 2.3M+ tokens. Reading that result into the primary agent's context caused the model server to return "Response was interrupted due to a server error" on every attempt, exhausting all 4 retries with exitCode=1.

The review itself was posted successfully — the subagent calls the safe-output tools (create_pull_request_review_comment, add_comment, submit_pull_request_review) directly. The primary agent reading the result was entirely unnecessary.

How did you fix it?

Changed the Instructions body in .github/workflows/shared/review-shared.md to:

  • Launch expert-reviewer as a background task (mode: "background")
  • Immediately call noop and stop — without reading the background agent result
  • Added an explicit inline warning explaining why reading the result causes the server error
-2. Call the `expert-reviewer` agent. Make sure to call it as subagent (`task` tool,
-   `agent_type: "general-purpose"`, `model: "claude-opus-4.6"`).
-3. Do **not** post comments or reviews yourself, except for the fallback in step 4...
-4. If the subagent does not post anything..., post a brief fallback review...
+2. Call the `expert-reviewer` agent as a **background** task (`task` tool,
+   `agent_type: "general-purpose"`, `model: "claude-opus-4.6"`, `mode: "background"`).
+3. **Immediately after launching** — do NOT wait or read its result — call `noop`.
+   The subagent posts the review directly via safe-output tools.
+
+> **Important**: Reading the background agent result would pull its entire conversation
+> (2+ million tokens) into your context, causing a server error.

No lock file recompilation needed — both review-on-open.agent.lock.yml and review.agent.lock.yml load the body via {{#runtime-import}} at runtime. Only the frontmatter is compiled.

Copilot AI self-assigned this May 13, 2026
Copilot AI review requested due to automatic review settings May 13, 2026 18:09
Copilot AI review requested due to automatic review settings May 13, 2026 18:09
Copilot AI linked an issue May 13, 2026 that may be closed by this pull request
…ubagent result

The primary agent was reading the background expert-reviewer subagent's
result after launching it, causing the context to grow to 2.3M+ tokens.
When the model tried to produce a final text response, it failed with a
server error (context too large).

The fix changes the Instructions to:
1. Launch the expert-reviewer as a background task (mode: "background")
2. Immediately call noop and stop - do NOT read the background agent result
3. Add an explicit warning explaining why reading the result causes failure

The subagent already posts the review directly via safe-output tools
(create_pull_request_review_comment, add_comment, submit_pull_request_review),
so no further action from the primary agent is needed.

Since review-shared.md is loaded at runtime via {{#runtime-import}},
no lock file recompilation is required.

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 13, 2026 18:25
Copilot AI changed the title [WIP] Fix expert code review workflow failure fix(review-workflow): prevent context overflow in Expert Code Review workflow May 13, 2026
Copilot AI requested a review from Evangelink May 13, 2026 18:26
@Evangelink Evangelink marked this pull request as ready for review May 14, 2026 07:38
Copilot AI review requested due to automatic review settings May 14, 2026 07:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the shared “Expert Code Review” workflow instructions to avoid context overflow/server errors caused by ingesting the expert-reviewer subagent’s extremely large output back into the primary agent context.

Changes:

  • Run expert-reviewer via the task tool in mode: "background" instead of as a foreground subagent call.
  • Immediately emit a noop safe-output after launching (and stop), explicitly instructing not to wait for or read the background agent result.
  • Add an inline warning explaining why reading the background agent result causes server errors.
Show a summary per file
File Description
.github/workflows/shared/review-shared.md Switches expert-reviewer invocation to background + immediate noop to prevent context overflow from large subagent output.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@Evangelink Evangelink merged commit 1eb0527 into main May 14, 2026
22 checks passed
@Evangelink Evangelink deleted the copilot/fix-expert-code-review-failure branch May 14, 2026 07:42
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.

[aw] Expert Code Review (on open) failed

3 participants