Codex PR Review

  • Agents and operations
  • Agentic Tools
  • 2026
  • Open source

GitHub Actions, Codex CLI, Python, OpenAI API and 2 more

Codex PR Review is a GitHub Action that reviews a pull request when someone with write access asks in a comment. Codex’s native reviewer does the reading, the same logic as the review command in the Codex CLI. The model runs on the OpenAI API or on Amazon Bedrock through GitHub OIDC, chosen per request. Back comes a merge verdict, an issues table with line links pinned to the reviewed commit, and inline comments.

Since 1 October 2026 it has been the only automated pull request reviewer on the production conversational AI backend at Spyne, where I work. It replaced a Claude Code review workflow there, and runs pinned to v1.4.0 from a private organization mirror.

calltranscript

# pull request thread, deliberate bugs in e2e/pricing.tsAuthor @gpt revieweyes reaction, progress note links the live runCodex Changes requested · Health 70/100 · Confidence: high5 issues to address (4 P1, 1 P2) · 2 resolvedP1 e2e/pricing.ts:16 Convert percentage points to a fractionP1 e2e/pricing.ts:22 Round average unit prices to integer centsP2 e2e/pricing.ts:26 Sort ascending to select the cheapest itemHealth 45 -> 70 (+25 since last review)gpt-6.1-sol via OpenAI API · medium effort · ~$0.03

2 turnsone call

A GitHub Action that runs Codex’s native reviewer when a pull request comment asks for it, on the OpenAI API or Amazon Bedrock, and posts a merge verdict.
Chapter
Agents and operations
Category
Agentic Tools
Year
Availability
Open source
Last commit
stack6 parts
  • GitHub Actions
  • Codex CLI
  • Python
  • OpenAI API
  • Amazon Bedrock
  • GitHub OIDC

GitHub Actions, Code Review, Codex, Amazon Bedrock, Python

Why a native reviewer

The obvious version is a model call with a review prompt I maintain. I wanted OpenAI’s own review behaviour instead, so codex exec review does the reading and the action does everything around it. A prompt does not settle who may ask, which credentials the model sees, what it actually read, or whether to trust the answer. Those questions are most of the code. With agents doing most of my typing, review is the gate I refuse to skip, as I wrote in how I work with coding agents. Nothing runs on open or push, so nobody pays for a review nobody asked for.

From comment to review

scripts/trigger.py parses @gpt review [openai|bedrock] [low|medium|high|xhigh] [full] [force] from a comment. It checks write access, an open pull request, a same-repository head and an allowed base branch, then reacts with eyes. scripts/history.py reads a hidden codex-pr-review-state marker from the last review: the commit, a settings digest, and one fingerprint per finding. scripts/rereview.py stops the run before anything is installed when both match. scripts/write_config.py writes a config.toml with a read-only sandbox, approval_policy = "never" and shell_environment_policy.inherit = "core", so commands Codex runs never see the API key. Then codex exec review --base "$BASE_REF" --json runs. Review mode reports zero token usage, so scripts/usage.py reads the real counts from the session rollouts Codex wrote. scripts/publish_review.py parses the findings and posts the review, and scripts/status.py clears the progress note.

Reading the whole diff

One review pass samples. On a 48,773-line pull request across 406 files, it made 29 model requests in about four minutes, and all six findings sat in two areas. Under review-mode: full, scripts/shards.py cuts the diff into shards of about 2,500 changed lines, never splitting a file and packing tests after their source. Each shard is reviewed in the full head against a synthetic base: HEAD’s tree with only that shard’s files restored to the merge base. Git plumbing builds those commits against a temporary index, so no ref is created. Four passes run at once by default, each with its own CODEX_HOME. A follow-up pass takes any file nobody read, and a final pass looks only for issues that span areas. scripts/coverage.py counts a file as inspected only when a rollout shows Codex reading it, or reading a diff that contained it.

Decisions and costs

  • Compute the verdict in scripts/verdict.py, since Codex’s overall_correctness field comes back empty on the pinned versions. Health loses 40, 20, 5 or 1 per P0 to P3 finding, capped so all nits together cost at most one P1. Low confidence turns a clean result into “Needs a full review”. The weights are my judgement, and the verdict is advisory.
  • Fingerprint a finding by its path and the sorted meaningful words of its title, so it survives line shifts. Codex is not deterministic, so before v1.3.0 a reworded finding on an unchanged commit counted as fixed. A finding now resolves only when its file changed.
  • Keep fetch-depth: 0 with persist-credentials: false. On one repository, a blob:none partial clone fetched 4.4 MB instead of 81 MB. It loads blobs lazily, though, and git diff then fails on a private repository without a credential. I would revisit this, since a huge repository is left with a warm mirror or a skipped review.

Asking for a review

Add an OPENAI_API_KEY secret, or an AWS_ROLE_TO_ASSUME secret naming a role trusted only for the default branch. Then call the reusable workflow from the default branch, where comment triggers run.

yaml13 lines
on:
  issue_comment: { types: [created] }
  pull_request: { types: [labeled] }
jobs:
  codex:
    permissions:
      contents: read
      pull-requests: write
      issues: write
      id-token: write
    uses: piyush-gambhir/codex-pr-review/.github/workflows/review.yml@v1
    with: { base-branches: main }
    secrets: inherit

Comment @gpt review on an open pull request, @gpt review bedrock xhigh to change provider and effort, or @gpt review full for a sharded pass. A second request for the same commit and settings links the existing review and calls no model, unless it adds force.

Limits and status

Only trusted contributors get reviews, and fork pull requests are skipped because the job holds model credentials. Coverage is a floor: an inspected file was in front of the reviewer, not proven free of bugs. Costs on the meta line are a price table estimate, not a bill. The reusable workflow depends on job.workflow_*, which GitHub Enterprise Server lacks, so a standalone example ships beside it. Seven releases, v1.0.0 to v1.4.0, went out on 29 and 30 September 2026. It is MIT licensed and independent of OpenAI and AWS. Its scripts need only the Python standard library, and 457 unit tests cover them.

All 43 projects