Skip to content

Add OpenRouter PR review workflow (free-only model, diff trimming, auto-labeling)#10

Merged
recursive-ai-dev merged 3 commits into
mainfrom
codex/add-github-action-for-ai-pr-review
Jan 4, 2026
Merged

Add OpenRouter PR review workflow (free-only model, diff trimming, auto-labeling)#10
recursive-ai-dev merged 3 commits into
mainfrom
codex/add-github-action-for-ai-pr-review

Conversation

@recursive-ai-dev

Copy link
Copy Markdown
Owner

Motivation

  • Provide an automated PR reviewer that sends the PR diff to OpenRouter and writes a structured review comment on each PR.
  • Enforce cost control by allowing only :free models to prevent accidental paid usage.
  • Keep reviews actionable and non-spammy by trimming oversized diffs, validating responses, and updating a single idempotent bot comment.
  • Improve triage by auto-creating and applying labels derived from the model verdict.

Description

  • Add a new GitHub Actions workflow at .github/workflows/openrouter-pr-review.yml that fetches the PR diff, trims it to 150KB, constructs a prompt, calls the OpenRouter chat endpoint, validates the response, and writes review.md as output.
  • Enforce a :free suffix on the model string (fail fast if not present) and include Diff truncated: true|false in the prompt to avoid overconfident summaries.
  • Add an auto-label step that deterministically parses the Approve? verdict and creates/applies ai:approve, ai:request-changes, or ai:comment-only labels, plus an idempotent comment poster that updates a single comment marked with <!-- openrouter-pr-review -->.
  • Include design and verification docs: LOGIC-MAP.md (logic/invariants), WE-CHOSE.md (three-perspective justification), and TESTING.md (test matrix and verification steps).

Testing

  • No automated tests were executed as part of this PR (this change adds a workflow and documentation only).

Codex Task

@codacy-production

codacy-production Bot commented Jan 4, 2026

Copy link
Copy Markdown

Codacy's Analysis Summary

0 new issue (≤ 0 issue)
0 new security issue

Review Pull Request in Codacy →

AI Reviewer available: add the codacy-review label to get contextual insights without leaving GitHub.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 790108c27c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +146 to +150
labelsToAdd.push('ai:approve');
labelsToRemove.push('ai:request-changes');
} else if (verdict === 'COMMENT_ONLY') {
labelsToAdd.push('ai:comment-only');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove stale AI labels when verdict changes

If a PR’s verdict changes over time, the workflow can leave contradictory labels on the PR. In particular, the COMMENT_ONLY branch only adds ai:comment-only and never removes ai:approve or ai:request-changes, and the APPROVE branch only removes ai:request-changes (not ai:comment-only). This means a PR can end up with both “approve” and “comment-only” (or “request-changes” and “comment-only”) labels after subsequent runs, which defeats the triage signal. Consider removing the other AI labels whenever any verdict is set so the label state is mutually exclusive.

Useful? React with 👍 / 👎.

@recursive-ai-dev recursive-ai-dev merged commit e50d685 into main Jan 4, 2026
1 of 4 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Jan 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant