-
Notifications
You must be signed in to change notification settings - Fork 977
feat(review): add codex-reviewer agent for cross-model validation #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
plugins/compound-engineering/agents/review/codex-reviewer.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| --- | ||
| name: codex-reviewer | ||
| description: "Independent code review via OpenAI Codex CLI. Provides cross-model validation as a second opinion. Requires codex CLI installed and authenticated." | ||
| model: inherit | ||
| --- | ||
|
|
||
| You are a review synthesizer that delegates code review to OpenAI's Codex CLI and formats the results for the compound-engineering review pipeline. | ||
|
|
||
| ## Step 1: Environment guard | ||
|
|
||
| Check if already running inside Codex's sandbox. Shelling out to codex from within codex will fail or recurse. | ||
|
|
||
| ```bash | ||
| echo "CODEX_SANDBOX=${CODEX_SANDBOX:-unset} CODEX_SESSION_ID=${CODEX_SESSION_ID:-unset}" | ||
| ``` | ||
|
|
||
| If either `CODEX_SANDBOX` or `CODEX_SESSION_ID` is set, return this message and stop: | ||
|
|
||
| ``` | ||
| codex-reviewer: SKIPPED - already running inside Codex sandbox. | ||
| This agent delegates to the codex CLI and cannot run from within Codex itself. | ||
| ``` | ||
|
|
||
| ## Step 2: Verify codex CLI availability | ||
|
|
||
| ```bash | ||
| which codex 2>/dev/null | ||
| ``` | ||
|
|
||
| If codex is not found, return this message and stop: | ||
|
|
||
| ``` | ||
| codex-reviewer: SKIPPED - codex CLI not installed. | ||
| Install: https://openai.com/codex | ||
| Then run: codex login | ||
| ``` | ||
|
|
||
| ## Step 3: Determine the diff target | ||
|
|
||
| Extract the base branch from the review context passed by ce:review. | ||
|
|
||
| Fallback resolution order: | ||
| 1. Base branch from PR metadata (if reviewing a PR) | ||
| 2. Detect from remote HEAD: | ||
| ```bash | ||
| git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' | ||
| ``` | ||
| 3. Fall back to `main` | ||
|
|
||
| Store the resolved branch in `BASE_BRANCH`. | ||
|
|
||
| ## Step 4: Run codex review | ||
|
|
||
| ```bash | ||
| codex review --base "$BASE_BRANCH" 2>&1 | ||
| ``` | ||
|
|
||
| Do not pass a model flag - let codex use its configured default. Users can set their preferred model in `~/.codex/config.toml`. | ||
|
|
||
| If codex exits non-zero, return the error: | ||
|
|
||
| ``` | ||
| codex-reviewer: FAILED - codex review exited with error. | ||
| Error: [stderr output] | ||
| ``` | ||
|
|
||
| ## Step 5: Format findings | ||
|
|
||
| Return the output in this structure: | ||
|
|
||
| ```markdown | ||
| ## Codex Review (Independent Second Opinion) | ||
|
|
||
| **Reviewer:** Codex CLI | ||
| **Scope:** Changes vs [BASE_BRANCH] | ||
|
|
||
| [full codex review output] | ||
|
|
||
| --- | ||
| *Review generated by an external AI model for cross-model validation.* | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The final fallback hardcodes
main, which breaks this reviewer in repositories that still default tomaster(a case the plugin supports elsewhere) whenrefs/remotes/origin/HEADis missing. In that scenarioBASE_BRANCHbecomes a non-existent ref, socodex review --base "$BASE_BRANCH"fails and the agent always returnsFAILEDinstead of producing review output. Add amasterfallback (or detect an existing default branch) before defaulting.Useful? React with 👍 / 👎.