Skip to content

[codex] Preserve reviewer when resuming threads#30278

Open
viyatb-oai wants to merge 1 commit into
mainfrom
codex/viyatb/preserve-resume-reviewer
Open

[codex] Preserve reviewer when resuming threads#30278
viyatb-oai wants to merge 1 commit into
mainfrom
codex/viyatb/preserve-resume-reviewer

Conversation

@viyatb-oai

@viyatb-oai viyatb-oai commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Why

A thread resumed without an explicit reviewer could pick up the reviewer from the current config instead of preserving the reviewer already in use by the thread. After an app restart, this meant a thread running with auto review could silently switch back to user review, and the next turn could continue under the wrong reviewer.

What changed

Persist the effective reviewer with each turn and restore the latest persisted value when the thread resumes. If the resume request explicitly provides a reviewer, that value still takes precedence.

Test plan

  • Added a regression test that starts a thread with auto review, records a turn, restarts with user review in config, resumes without an override, and verifies that auto review is preserved.
  • just test -p codex-protocol
  • just test -p codex-state
  • just test -p codex-rollout
  • just test -p codex-app-server thread_resume_preserves_persisted_approvals_reviewer
  • Clippy for the affected crates

Co-authored-by: Codex noreply@openai.com
@viyatb-oai viyatb-oai marked this pull request as ready for review June 26, 2026 19:53
@viyatb-oai viyatb-oai requested a review from a team as a code owner June 26, 2026 19:53

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

Copy link
Copy Markdown
Contributor

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: f9cdee51c7

ℹ️ 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 +181 to +185
typesafe_overrides.approvals_reviewer = resumed_history.history.iter().rev().find_map(|item| {
let RolloutItem::TurnContext(turn_context) = item else {
return None;
};
turn_context.approvals_reviewer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Read reviewer from existing rollout events

When resuming an existing rollout created before this new field was added, or one where the latest change was thread/settings/update before the next user turn, the latest reviewer is persisted on SessionConfigured/ThreadSettingsApplied events rather than on a TurnContext item. Because this scan only accepts TurnContext, it returns None and the later config load falls back to the current config, so auto-review threads can still silently resume as user-review in those cases; please fall back to those existing events when no TurnContext reviewer is present.

AGENTS.md reference: AGENTS.md:L102-L110

Useful? React with 👍 / 👎.

Comment on lines +172 to +173
if typesafe_overrides.approvals_reviewer.is_some()
|| request_overrides.is_some_and(|overrides| overrides.contains_key("approvals_reviewer"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Don't treat default exec reviewer as an override

This guard assumes Some means the resume request explicitly overrode the reviewer, but the codex exec resume path always fills ThreadResumeParams.approvals_reviewer from the resolved config (codex-rs/exec/src/lib.rs:1094, via a helper that always returns Some at 1144-1147). As a result, resuming an auto-review thread through exec with the current config/default set to user still exits here before reading the persisted rollout reviewer, preserving the exact silent switch this change is meant to prevent for that resume surface.

AGENTS.md reference: AGENTS.md:L102-L110

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants