Skip to content

fix(sessions): recover handoffs after cancelled compaction - #5197

Merged
jbeckwith-oai merged 3 commits into
mainfrom
codex/fix-handoff-compaction-resume
Sep 27, 2026
Merged

jbeckwith-oai merged 3 commits into
mainfrom
codex/fix-handoff-compaction-resume

Conversation

@jbeckwith-oai

@jbeckwith-oai jbeckwith-oai commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This pull request fixes handoff recovery when session compaction commits replacement history during cancellation. Native atomic replacement now drains to a confirmed outcome before cancellation propagates, allowing the Runner to settle its pending checkpoint without repeating persistence or completed handoff/model work. If replacement and restoration fail, the checkpoint remains pending and unrecognized history raises a reconciliation error before further model work.

Exact restored append history still permits compaction retry. The checkpoint retains append acknowledgement plus the successful model exchange's digests and replay policy for live and JSON-restored retries, and rejects acknowledgement without a captured history boundary. These private checkpoint fields extend unreleased RunState schema 1.18; schema 1.17 remains readable. Follow-up to #4835.

Test plan

  • Real SQLite regression cancels during replacement, permits commit, then resumes live and JSON-restored state through both runner modes without duplicate persistence or repeated handoff/model work.
  • Legacy replacement tests cover successful rollback and failed restoration leaving empty or partial history, through live/JSON state and both runner modes.
  • Schema validation and filtered-history regressions verify checkpoint validity and preserve model visibility.
  • Two independent reviews passed. Formatting, lint, mypy, Pyright, and full local tests passed: 11,312 passed, 66 skipped under the prescribed Codex sandbox configuration. Native macOS sandbox coverage remains delegated to CI.

Issue number

Follow-up to #4835.

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • Completed self-review and two independent reviews before submission

@jbeckwith-oai
jbeckwith-oai requested review from a team, rm-openai and seratch as code owners September 27, 2026 18:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T19:03:32.160789Z 8f1616b New commits
🔒 Security Review ✅ Completed 2026-09-27T19:03:37.144778Z 8f1616b New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 2adb59a1b2

ℹ️ 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 thread src/agents/run_state.py
Comment thread src/agents/run_internal/session_persistence.py
markstuart-oai
markstuart-oai previously approved these changes Sep 27, 2026

@markstuart-oai markstuart-oai 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.

Reviewed at 2adb59a1b2ef4fc4286633e00590cc7863397512. The acknowledgement belongs in the existing pending-write checkpoint: it prevents replay after compaction changes the append fingerprint, while the exact-history check preserves live rollback retries. The controlled SQLite regression covers committed cancellation with live and JSON-restored state through both runner modes, including stored history and avoiding repeated handoff/model work. The schema extension is confined to unreleased 1.18; released 1.17 remains readable.

I also checked the existing inline concerns. The acknowledged/null-before combination has no supported producer. The JSON rollback concern is a real pre-existing limitation: the base revision also loses the model-exchange evidence on JSON restoration and skips compaction. It should be tracked separately from this committed-cancellation fix; this approval does not establish JSON rollback retry support.

No actionable regression or structural blocker found in this diff. Source review only; all 22 hosted checks passed at this exact head. No tests or builds were run locally.

dpiet-oai
dpiet-oai previously approved these changes Sep 27, 2026

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

Copy link
Copy Markdown

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: 6ef0f2d64a

ℹ️ 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 thread src/agents/run_internal/session_persistence.py Outdated
@jbeckwith-oai
jbeckwith-oai merged commit 802cc03 into main Sep 27, 2026
22 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/fix-handoff-compaction-resume branch September 27, 2026 19:20
@github-actions github-actions Bot mentioned this pull request Sep 28, 2026
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.

3 participants