Skip to content

Replay thread rollback from rollout history#13615

Merged
aibrahim-oai merged 4 commits intomainfrom
dev/replay-thread-rollback
Mar 6, 2026
Merged

Replay thread rollback from rollout history#13615
aibrahim-oai merged 4 commits intomainfrom
dev/replay-thread-rollback

Conversation

@aibrahim-oai
Copy link
Collaborator

@aibrahim-oai aibrahim-oai commented Mar 5, 2026

  • Replay thread rollback from the persisted rollout history instead of truncating in-memory state.\n- Add rollback coverage, including rollback-behind-compaction snapshot coverage.

@aibrahim-oai
Copy link
Collaborator Author

@codex review this

Copy link
Contributor

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

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: 3f44378f13

ℹ️ 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 +4552 to +4555
sess.flush_rollout().await;

let initial_history =
match RolloutRecorder::get_rollout_history(rollout_path.as_path()).await {
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Abort rollback if rollout flush fails before replay

thread_rollback replays from disk right after sess.flush_rollout().await, but flush_rollout only logs errors. If flush fails (writer task closed or I/O failure), rollback reads stale rollout data and then replaces in-memory history from that stale snapshot, producing incorrect rollback results. Treat flush failure as a hard rollback error before loading history.

Useful? React with 👍 / 👎.

Comment on lines +4539 to +4544
let Some(recorder) = recorder else {
sess.send_event_raw(Event {
id: turn_context.sub_id.clone(),
msg: EventMsg::Error(ErrorEvent {
message: "thread rollback requires a persisted rollout path".to_string(),
codex_error_info: Some(CodexErrorInfo::ThreadRollbackFailed),
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Badge Keep rollback working when persistence is unavailable

This change makes rollback fail whenever services.rollout is None. Previously rollback still pruned the active in-memory context; now non-persisted sessions cannot rollback at all despite having valid history. This is a functional regression for ephemeral/no-persistence runs and contradicts rollback’s in-memory behavior.

Useful? React with 👍 / 👎.

@aibrahim-oai aibrahim-oai merged commit 629cb15 into main Mar 6, 2026
29 of 31 checks passed
@aibrahim-oai aibrahim-oai deleted the dev/replay-thread-rollback branch March 6, 2026 00:40
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants