Determine sub-agent count in pre-script based on PR size#510
Determine sub-agent count in pre-script based on PR size#510
Conversation
Add dynamic sub-agent count to the pr-context pre-script: - ≤10 files: direct review (no sub-agents) - 11-20 files: 2 sub-agents (A→Z, Z→A) - >20 files: 3 sub-agents (A→Z, Z→A, largest-first) The pre-script writes /tmp/pr-context/review-strategy.md with precise instructions so the agent follows a deterministic path. The PR review workflow reads this strategy file instead of always spawning 3 sub-agents. Recompiled all affected lock files. Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
📝 WalkthroughWalkthroughThis change introduces dynamic sub-agent sizing for PR reviews based on the number of changed files. The PR context generation now calculates a FILE_COUNT and assigns AGENT_COUNT values (0 for ≤10 files, 2 for 11–20 files, 3 for >20 files), writing these values to agent_count.txt. A new review-strategy.md artifact is generated with conditional strategy sections for Direct Review (no sub-agents), 2-agent review, or 3-agent review depending on PR size. Workflow files are updated to consume this strategy document instead of hard-coded instructions, and the PR context manifest is expanded to include these new precomputed artifacts. Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
| - Instruction to read changed files from the workspace (the PR branch is checked out) | ||
|
|
||
| Each sub-agent returns a structured findings list. They do NOT leave inline comments. | ||
| Read `/tmp/pr-context/review-strategy.md` for the pre-computed review strategy. The strategy is determined by PR size and specifies the exact number of sub-agents (0, 2, or 3). Follow the instructions in that file exactly. |
There was a problem hiding this comment.
[HIGH] Conflicting instructions still force three sub-agents
This new strategy step says to follow /tmp/pr-context/review-strategy.md (which can require 0 or 2 agents), but the workflow still imports gh-aw-fragments/pick-three-keep-many.md, whose text explicitly says “Spawn 3 sub-agents” and “Wait for all 3 sub-agents”.
Because both instructions are present in the same prompt, the model can still follow the hardcoded “3 sub-agents” rule, which defeats the deterministic sizing behavior introduced here.
Please make the prompt sources consistent (for example, gate/remove the pick-three-keep-many fragment when strategy says direct review, or rewrite that fragment to be conditional on review-strategy.md).
|
/ai resolve pr issues |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/gh-aw-pr-review.md (1)
125-125:⚠️ Potential issue | 🟠 MajorResolve conflicting sub-agent instructions in the prompt.
Line 125 makes orchestration dynamic, but this prompt still imports
gh-aw-fragments/pick-three-keep-many.md(Line 16). If that fragment still contains fixed 3-agent orchestration text, the agent receives contradictory directives and deterministic PR-size fan-out can fail.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/gh-aw-pr-review.md at line 125, The prompt imports a fixed 3-agent fragment (gh-aw-fragments/pick-three-keep-many.md) while orchestration is supposed to be dynamic via the pre-computed review strategy (read `/tmp/pr-context/review-strategy.md`), causing conflicting directives; update the prompt assembly in gh-aw-pr-review.md so the pick-three-keep-many fragment is only included when the strategy explicitly requires three sub-agents, or replace the fixed fragment import with logic that reads `/tmp/pr-context/review-strategy.md` and conditionally includes the appropriate fragment (0, 2, or 3-agent fragment names) to ensure the chosen orchestration is deterministic and consistent with the review strategy.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/gh-aw-pr-review.md:
- Line 125: The prompt imports a fixed 3-agent fragment
(gh-aw-fragments/pick-three-keep-many.md) while orchestration is supposed to be
dynamic via the pre-computed review strategy (read
`/tmp/pr-context/review-strategy.md`), causing conflicting directives; update
the prompt assembly in gh-aw-pr-review.md so the pick-three-keep-many fragment
is only included when the strategy explicitly requires three sub-agents, or
replace the fixed fragment import with logic that reads
`/tmp/pr-context/review-strategy.md` and conditionally includes the appropriate
fragment (0, 2, or 3-agent fragment names) to ensure the chosen orchestration is
deterministic and consistent with the review strategy.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
.github/workflows/gh-aw-fragments/pr-context.md.github/workflows/gh-aw-mention-in-pr-by-id.lock.yml.github/workflows/gh-aw-mention-in-pr-no-sandbox.lock.yml.github/workflows/gh-aw-mention-in-pr.lock.yml.github/workflows/gh-aw-pr-review-addresser.lock.yml.github/workflows/gh-aw-pr-review.lock.yml.github/workflows/gh-aw-pr-review.mdgithub/workflows/gh-aw-fragments/pick-three-keep-many.mdgithub/workflows/gh-aw-pr-review.md
This change makes PR review fan-out deterministic by deciding sub-agent usage in the pre-script from PR size, then writing explicit runtime instructions for the reviewer to follow.
What changed
1) Pre-script now computes review strategy from file count
In
.github/workflows/gh-aw-fragments/pr-context.md, the pre-script now:FILE_COUNTfrom/tmp/pr-context/files.jsonAGENT_COUNTusing fixed thresholds/tmp/pr-context/agent_count.txt/tmp/pr-context/review-strategy.mdwith exact instructions for one of three modes:It also adds
agent_count.txtandreview-strategy.mdto the generated/tmp/pr-context/README.mdmanifest.2) Review prompt now consumes precomputed strategy
In
.github/workflows/gh-aw-pr-review.md:/tmp/pr-context/review-strategy.md(instead of hard-coding 3 sub-agents)Thresholds
<= 10011-202> 203Generated workflow updates
.github/workflows/gh-aw-pr-review.lock.ymlincludes the compiled logic/prompt updates aboveFixes
elastic/ai-github-actions#508.