Skip to content

fix(codex): preserve continuity across races and paginated history - #114309

Closed
kevin2966n wants to merge 1 commit into
openclaw:mainfrom
kevin2966n:qa-laptop-qa08-c66ca2f
Closed

kevin2966n wants to merge 1 commit into
openclaw:mainfrom
kevin2966n:qa-laptop-qa08-c66ca2f

Conversation

@kevin2966n

Copy link
Copy Markdown
Contributor

Closes #114302
Closes #114304
Closes #114305
Closes #114306
Closes #114308

What Problem This Solves

Fixes five Codex continuity failures where users could lose a message during a request-input race, fail to continue or fork paginated threads, leave request handlers running after disconnect, or miss client-close cleanup when observers throw or subscribe late.

Why This Change Was Made

The change honors the compare-and-resolve result before steering, adds one validated full-history reader for paginated and inline Codex threads, and makes the client close transition abort active inbound handlers while delivering terminal state to every observer exactly once. The implementation follows the currently checked-out official Codex app-server contracts and remains internal to the Codex extension.

User Impact

Messages survive request-input resolution races, paginated threads can be continued/materialized/message-forked, and disconnect cleanup is deterministic across active, throwing, and late observers.

Evidence

  • Steering, fork boundary, catalog, and lifecycle group: 227/227 passed.
  • Client, shared-client, and turn-router group: 112/112 passed.
  • User-input bridge: 6/6 passed.
  • Upstream session fork: 6/6 passed.
  • Production extensions typecheck, targeted oxfmt, targeted oxlint, git diff --check, public Plugin SDK surface, protected-path, and secret scans passed.
  • Fresh independent autoreview: no actionable findings, correctness 0.98.
  • Official Codex source was inspected at 18f50c9e628af083a52d9240de09fc2db24d79ce for paginated-history and request-resolution semantics.
  • AI-assisted implementation and review; no public Plugin SDK or generated protocol boundary changed.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The PR preserves unanswered messages through steering, reads paginated Codex history, and improves client-close cancellation and observer notification.

Example: Register a close observer after the Codex client has closed.

  • Before: The observer never receives the terminal callback.
  • After: The observer is called immediately and receives a no-op disposer.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful internal fixes and regression coverage remain, with no concrete introduced bug found; required real-client proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Codex conversation continuity and cleanup can fail when input requests resolve concurrently or observers subscribe after connection closure.
Reason: The remaining terminal-notification defect has concrete value, stays within the existing plugin boundary, and introduces no public configuration or API.

Merge readiness

⛔ Blocked before merge - 2 items remain

Meaningful late-close notification work remains missing on current main and the latest release. This PR remains paired with unresolved same-author issues, and the author recently confirmed continued work; no close rule applies.

Priority: P2
Reviewed head: 28b2d65466b1257c61b435fecebf9b8ce5de4467

Before merge

  • Add real behavior proof - The PR reports regression tests, but no attributable after-fix production-client observations for this head. Inspected screenshots belong to related merged fork work. Show late-close notification through an actual client and, for any retained answer-race change, the exact reply reaching ordered steering once when answering loses; demonstrate a remaining supported-version history failure before retaining that fix. Redact credentials, IPs, personal details, and private endpoints. Existing serialized formats and storage schemas are unchanged. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Complete next step - Resolve GitHub-reported merge conflicts while preserving current request-lifetime, steering, and native-history ownership.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted production-client evidence for late-close subscription and any retained input-race or history fix; reported mocked regressions do not establish those shipped-path results.
Agent review details

How this fits together

The Codex plugin carries OpenClaw messages into native app-server turns and returns history, tool requests, and connection lifecycle events to session and cleanup owners.

flowchart TD
  A[OpenClaw conversation] --> B[Input bridge and steering]
  B --> C[Codex app-server client]
  C --> D[Native Codex turns]
  D --> E[History readers]
  E --> F[Session import and forks]
  C --> G[Close observers and cleanup]
Loading

Technical review

Best possible solution:

Carry the missing late-close notification into the current Codex client owner and retain other changes only where supported current behavior still requires them.

Do we have a high-confidence way to reproduce the issue?

Closing a client and then registering a close observer deterministically misses notification in current-main source and v2026.10.4; this read-only review executed no target code. The older pagination failure is not established on managed Codex 0.161.0, and the answer-resolution race remains unverified through a production client.

Is this the best way to solve the issue?

Immediate terminal-state replay belongs in the existing Codex client, matching its adjacent transport-exit subscription pattern. The older branch as a whole is not the best landing shape: current main already owns cancellation, observer isolation, and supported native history hydration. Preserve those owners rather than introducing parallel lifecycle paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 204ff9770617.

Provenance checked

  • Pending-input answer handling keeps the original intent (f1f4b8a: Preserve complete text-and-image input while claiming and releasing the exact pending prompt.)
  • Paginated fork rejection changes intended behavior with a stated reason (ea54060: Fail closed when native history could not provide a verifiable fork boundary; inspected later native source supports full turn hydration.)
  • Client close lifecycle keeps the original intent (8d72aaf: The app-server module split carried one-shot close registration and cleanup; the PR preserves the transition while extending notification to late subscribers.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned PR introduction: Read the introduced production and test hunks from the verified merge base to the reviewed head, rather than attributing newer main changes to this PR. (28b2d65466b1)
  • Remaining current-main behavior: addCloseHandler still only stores callbacks, while markClosed dispatches once. The turn router and shared-client lifecycle consume these callbacks; the adjacent transport-exit subscription already replays terminal state. (extensions/codex/src/app-server/client.ts:528, 204ff9770617)
  • Latest release retains the gap: The v2026.10.4 source also registers close handlers without replaying an already-reached closed state. (extensions/codex/src/app-server/client.ts:732, 383c124cc32f)
  • Existing lifecycle owners: Current main isolates throwing close observers and delegates inbound cancellation to CodexServerRequests.close; client-server-request-lifetime.test.ts covers cancellation on physical-client close. (extensions/codex/src/app-server/client.ts:700, 204ff9770617)
  • Personally inspected sibling contract: Inspected sibling Codex source directly: this revision rejects paginated includeTurns reads with the exact error used by the PR and hydrates full ascending turn pages. The cache origin verifies openai/codex ownership. The PR's claimed 18f50c9 revision was unavailable locally. (codex-rs/app-server/src/request_processors/thread_processor.rs:2365, 25af12f7e615)
  • Current managed dependency changes the assessment: OpenClaw main pins Codex 0.161.0. Its verified release source hydrates paginated full history for both persisted and loaded threads, so the historical pagination failure is not established for the current managed pin. (codex-rs/app-server/src/request_processors/thread_processor.rs:2943, 979011409de0)

Likely related people:

  • Alexis Gallagher: Raw commit 7a3c26b adds extensions/codex/src/app-server/attempt-steering.ts:191 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 7a3c26b509f1; files: extensions/codex/src/app-server/attempt-steering.ts)

PR surface

Source +84, Tests +251. Total +335 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 157 73 +84
Tests 5 255 4 +251
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 412 77 +335

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +157/-73; tests +255/-4 Growth consolidates history reads and covers lifecycle behavior, although newer native hydration and cancellation owners reduce how much production code still needs carrying forward.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded, source-backed Codex lifecycle defect remains, without evidence of an urgent current outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Demonstrate the retained lifecycle behavior through a real Codex client.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-14T13:10:24.096Z sha 28b2d65 :: needs real behavior proof before merge. :: [P1] Route paginated history from metadata, not an error string
  • reviewed 2026-08-15T15:51:12.730Z sha 28b2d65 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-18T23:34:42.979Z sha 28b2d65 :: needs real behavior proof before merge. :: [P1] Route pagination from history-mode metadata
  • reviewed 2026-08-25T00:09:09.222Z sha 28b2d65 :: needs real behavior proof before merge. :: [P1] Select paginated history from metadata
  • reviewed 2026-09-01T17:14:40.823Z sha 28b2d65 :: needs real behavior proof before merge. :: [P1] Route paginated history from metadata, not error text
  • reviewed 2026-09-22T04:12:33.050Z sha 28b2d65 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-27T03:08:43.049Z sha 28b2d65 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-01T13:47:04.564Z sha 28b2d65 :: needs real behavior proof before merge. :: none

Reviewed October 15, 2026, 10:41 PM ET / October 16, 2026, 02:41 UTC (Revision 13).

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 2, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Sep 22, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Oct 1, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Please keep this open pending validation. This is still a draft at 28b2d65. The latest review calls for current-main integration checks and after-fix evidence from a real Codex client.

The next checks would be:

  • Reconcile the retained fixes with main’s current request-lifetime and native-history/fork code on a pinned merge candidate.
  • Capture redacted real-client evidence tied to that commit for paginated supervised materialization, close handlers registered after closure, and the Codex user message can be dropped when requestUserInput resolves during answer #114302 answer-resolution race. For that race, verify that the exact reply reaches ordered steering once when answering loses.

Those checks haven’t been verified in this PR yet. The existing mocked regression tests don’t establish the real-client behavior.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 15, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 16, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale after 7 days without qualifying human activity.
Without new human activity, Barnacle may close it as not planned 7 days after this message was posted. This is administrative inactivity cleanup, not a claim that the problem is fixed.
A human update restarts the inactivity clock; a new PR head also restarts it. A maintainer can add no-stale for a durable hold, or bad-barnacle to suppress Barnacle. Remove the hold when work can resume.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 23, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This draft has had no commits since July 27 and still needs current-main integration and real Codex client proof. Please open a fresh PR against current main once you have that evidence; smaller per-issue PRs would also be easier to review.

@steipete steipete closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

2 participants