From 205d62f8abc91dafd5824a8b2a558d6c94fa89e6 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong <277547417+bong-water-water-bong@users.noreply.github.com> Date: Sat, 27 Jun 2026 22:25:51 -0300 Subject: [PATCH] ci: add PR-Agent for automated PR reviews and descriptions Adds Codium AI PR-Agent via GitHub Actions: - Auto-describe and auto-review on PR open/reopen - Comment-triggered /describe, /review, /improve, /ask commands - C++/HIP/CMake-specific review focus in .pr_agent.toml Config prioritizes thread safety, memory correctness, build correctness, error handling, and backward compatibility. Co-Authored-By: Claude --- .github/workflows/pr-agent.yml | 33 +++++++++++++++++++++++++ .pr_agent.toml | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/pr-agent.yml create mode 100644 .pr_agent.toml diff --git a/.github/workflows/pr-agent.yml b/.github/workflows/pr-agent.yml new file mode 100644 index 00000000..c69f0f83 --- /dev/null +++ b/.github/workflows/pr-agent.yml @@ -0,0 +1,33 @@ +name: PR-Agent +on: + pull_request_target: + types: [opened, ready_for_review, reopened] + issue_comment: + types: [created, edited] + +permissions: + pull-requests: write + issues: write + contents: read + +jobs: + pr-agent: + runs-on: ubuntu-latest + if: | + (github.event_name == 'pull_request_target' && github.event.action != 'closed') || + (github.event_name == 'issue_comment' && github.event.issue.pull_request && + contains(github.event.comment.body, '/describe') || + contains(github.event.comment.body, '/review') || + contains(github.event.comment.body, '/improve') || + contains(github.event.comment.body, '/ask')) + steps: + - name: PR-Agent + uses: Codium-ai/pr-agent@v0 + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + github_action_config.auto_describe: "true" + github_action_config.auto_review: "true" + github_action_config.auto_improve: "false" + github_action_config.enable_output: "true" + pr_agent.extra_config: ".pr_agent.toml" diff --git a/.pr_agent.toml b/.pr_agent.toml new file mode 100644 index 00000000..f17d72ac --- /dev/null +++ b/.pr_agent.toml @@ -0,0 +1,44 @@ +[pr_description] +# Keep auto-generated descriptions concise — this is a focused C++ engine, +# not a sprawling monorepo. +extra_instructions = """ +Focus on: +1. What behavior changed (not just what code changed) +2. Backend/platform impact (ROCm, Metal, CPU, NPU) +3. Breaking API or build changes +4. Performance implications +Use bullet points. Keep it under 250 words. +""" + +[pr_reviewer] +# Review focus areas for the MLX engine codebase. +extra_instructions = """ +Prioritize: +1. Thread safety and memory correctness (C++20, raw pointers, HIP streams) +2. Build correctness — CMakeLists.txt changes, new targets, platform guards (#ifdef __linux__, #ifdef __APPLE__) +3. Error handling — are new code paths handling allocation failures, HIP errors, file-not-found? +4. Performance — blocking calls on hot paths, unnecessary copies, missing reserve() calls +5. Test coverage — do new features have corresponding tests? +6. Backward compatibility — does this break the HTTP API, CLI interface, or model format? + +Ignore minor style nits (naming, formatting) unless they genuinely obscure intent. +Flag security issues (buffer overflows, unsanitized inputs) as critical. +""" + +[pr_code_suggestions] +extra_instructions = """ +Suggestions should be actionable and specific. Avoid generic advice like "consider refactoring." +Prefer concrete rewrites over abstract critiques. +""" + +[pr_questions] +# Enable /ask for answering questions about PRs. +enabled = true + +[config] +# Verbose logging in CI is fine — it's ephemeral. +verbosity_level = 1 +# The model to use — gpt-5-mini for cost efficiency on routine reviews, +# gpt-5 for deeper reviews when someone explicitly requests /review. +model = "gpt-5-mini" +fallback_models = "claude-3-sonnet"