feat: add resumable review threads to /codex:review and /codex:adversarial-review#375
feat: add resumable review threads to /codex:review and /codex:adversarial-review#375rrva wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2214d4db27
ℹ️ 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".
144e14b to
2921634
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2921634835
ℹ️ 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".
2921634 to
217572a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 217572a3a6
ℹ️ 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".
|
Both Codex review findings are addressed as of
For reviewer context: the change is opt-in and non-breaking — The PR description also sketches a small upstream |
217572a to
57db7b6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57db7b6027
ℹ️ 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".
…arial-review Add opt-in `--resume` / `--fresh` / `--within-hours` flags so an iterative review -> fix -> re-review loop can reuse a Codex review thread instead of re-exploring the repo from a cold start every time, which sharply cuts token burn. Reuse is scoped to the git worktree and bounded by recency. - `--resume` reuses the worktree's recent review thread if one exists and otherwise starts a fresh resumable thread; `--fresh` forces a new thread; `--within-hours <n>` sets the reuse window (default 3h). - Native one-shot `review/start` cannot carry context between runs, so the resumable path uses a turn-based reviewer. Only persisted session-mode review jobs are eligible for resume, scoped to the same review kind (`/codex:review` vs `/codex:adversarial-review`, which share jobClass but differ by kind); native one-shot review threads are ephemeral and never selected. The newest resumable review run is reused only if it completed -- a cancelled, failed, or in-progress run (including a concurrent run still starting, before it records a thread id) is never reused, even if an older run on the same thread completed. If a persisted thread was pruned/expired the run falls back to a fresh thread instead of failing, and the reuse- continuation note is injected only when the resume actually succeeds. - The resumable plain-review prompt (prompts/review.md) is adapted from Codex's native reviewer system prompt (codex-rs/core/review_prompt.md) so that `/codex:review --resume` reviews like native `/codex:review`; only the output section is remapped to this plugin's review-output schema. - Default (no-flag) `/codex:review` and `/codex:adversarial-review` behavior is byte-identical to before -- the change is purely additive. Tests cover the new flags in tests/commands.test.mjs and tests/runtime.test.mjs (reuse, recency fallback, native-thread exclusion, kind scoping, non-completed/ newest-not-completed/still-starting exclusion, and pruned-thread fallback). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57db7b6 to
dc09fb6
Compare
Opt-in, non-breaking feature: lets an iterative review → fix → re-review loop reuse a Codex review thread instead of re-exploring the repo cold on every pass, which sharply cuts token/quota burn.
Summary
--resume,--fresh, and--within-hours <n>to/codex:reviewand/codex:adversarial-review.--resumereuses-or-creates: it reuses this git worktree's recent review thread if one exists, and otherwise starts a fresh resumable thread — safe to use on every review, never has to be seeded with--fresh.--within-hours).--freshforces a new thread for the worktree (discard prior context)./codex:reviewstill uses the native one-shot reviewer and the no-flag prompt is unchanged. The change is purely additive (new flags only).Why turn-based, and why
prompts/review.mdis includedNative
review/startspawns a fresh reviewer task each run (inopenai/codex,codex-rs/core/src/tasks/review.rsseeds it withinitial_history: None), so it can't carry context between runs — resume fundamentally requires aturn/startinstead, and a turn needs a prompt./codex:adversarial-reviewalready has one (prompts/adversarial-review.md); plain/codex:reviewdid not, because its reviewer is Codex's built-in one.So
prompts/review.mdis the prompt for the resumable plain-review path only. It is adapted from Codex's own native reviewer system prompt (codex-rs/core/review_prompt.md) — same bug-flagging rubric, the same P0–P3 priorities, the same overall-correctness verdict — with only the output section remapped to this plugin'sschemas/review-output.schema.json. The intent is for/codex:review --resumeto review as much like native/codex:reviewas a structured turn allows. It can't be identical: the native reviewer's rubric is injected as the review thread'sbase_instructions, which a normalturn/startcan't set, so the rubric is carried in the turn prompt instead.On this repo's own diff (measured runs), the resumed pass re-explored only a fraction of the repo — roughly 1–10 exploration commands vs 26–35 for the cold pass — and finished several× faster.
Changes
scripts/lib/codex.mjs: persistent review-thread naming; opt-inresumeFallbackinrunAppServerTurn(start a fresh thread if a pruned/expired thread can't be resumed — resume fails before any turn starts, so no tokens are wasted). The prompt is built from the actual outcome, so a fresh-fallback thread is never told to reuse context it doesn't have.scripts/codex-companion.mjs: parse--resume/--fresh/--within-hours; worktree-scoped, recency-bounded thread resolution that only selects persisted session-mode review jobs. Native one-shot review jobs persist a thread id too, but those threads are ephemeral, so they are tagged non-resumable and never selected.prompts/review.md: the resumable plain-review prompt, adapted from Codex's nativereview_prompt.md(see above). The resume continuation note is injected programmatically only when resuming, so the no-flag path is unaffected.commands/review.md,commands/adversarial-review.md: document the flags.A cleaner long-term fix (in Codex itself)
This plugin-side prompt would be unnecessary if native review could carry context — and the machinery already exists upstream.
run_codex_thread_one_shotacceptsinitial_history: Option<InitialHistory>withResumed/Forkedvariants (used by normal thread resume), but the review task always passesNone(codex-rs/core/src/tasks/review.rs). A small change toopenai/codexwould make native review resumable:ReviewStartParams(clients already receive areviewThreadIdfrom a detached review);InitialHistory::Resumed(...)instead ofNone, keepingbase_instructions = REVIEW_PROMPTand appending the new per-target prompt.That would give native review context reuse for every client. After it lands,
/codex:review --resumehere collapses to a nativereview/startcall, andprompts/review.mdplus the whole turn-based plain-review path can be deleted. I'm happy to open that PR againstopenai/codexas well.Test plan
npm test— green. New coverage:tests/commands.test.mjs(flag surface on both commands) andtests/runtime.test.mjs(--fresh→--resumereuse, recency fallback, native-thread exclusion, pruned-thread fallback).npm run build(tsc) — green.Not in scope