Skip to content

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

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-expert-code-review-failure
Draft

fix(review-workflow): prevent context overflow in Expert Code Review workflow#8199
Copilot wants to merge 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
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

2 participants