Skip to content

fix(codex): prevent steered answers from disappearing or crossing threads - #128257

Merged
roboclaw-bot merged 10 commits into
mainfrom
openclaw/root-cause-analysis-for-thread-error
Aug 26, 2026
Merged

roboclaw-bot merged 10 commits into
mainfrom
openclaw/root-cause-analysis-for-thread-error

Conversation

@clawsweeper

@clawsweeper clawsweeper commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a coupled transcript failure where a Codex answer shown immediately before a steer could disappear from durable history, while a stale shared run ID could let another session's live response replace the selected Control UI transcript or consume its queued send.

Why This Change Was Made

Completed Codex assistant items are journaled at their authoritative item-complete boundary and committed before a steer is accepted, without replaying them at terminal finalization. The Control UI now treats session ownership as authoritative before run IDs and scopes terminal queue handoff/removal by (sessionKey, agentId, runId).

The page-ingress repair preserves the intentional split-pane handoff: inactive panes may cache and retire the event owner's durable queue row, but a foreign terminal cannot mutate the selected pane's queue. Literal unscoped global events route to the default agent, matching chat-event semantics. Silent control payloads such as NO_REPLY are excluded from the new persistence boundary.

Production LOC: +164/-51 (net +113) | Tests: +309/-38 (net +271)

The production growth records two explicit ownership boundaries: Codex item completion versus enclosing turn finalization, and UI event scope versus correlation-only run IDs. Steering snapshot assembly lives in the existing snapshot owner so the projector remains below the repository line limit without a suppression.

User Impact

Users can steer an active Codex turn without losing an answer that was already displayed. Switching between threads, agents, or split panes no longer allows a same-run event from another session to contaminate the selected transcript or retire its queued prompt.

Evidence

Before / after video

The deterministic mock-Gateway scenario uses the same runId for two sessions, emits a large delta/final from the inactive session, and reconciles the selected virtualized transcript while rows resize.

Before fix — inactive-session content replaces the selected thread:

before-fix.webm

After fix — the selected thread remains isolated and rows do not overlap:

after-fix.webm

Both WebM recordings were inspected at early, middle, and final frames before upload.

Regression and focused verification

  • node scripts/run-vitest.mjs extensions/codex/src/app-server/event-projector.assistant.test.ts extensions/codex/src/app-server/run-attempt.steering.test.ts — 32/32 passed
  • node scripts/run-vitest.mjs ui/src/pages/chat/chat-send.test.ts ui/src/pages/chat/chat-gateway.test.ts — 446/446 passed
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-agent-run-transcript.e2e.test.ts — 4/4 passed
  • Lobsterdex clipboard E2E — 5 consecutive CI-mode runs passed after awaiting existing bootstrap RPCs before asserting zero clipboard-triggered Gateway requests
  • Updater CLI — 247/247 passed under CI mode after isolating native service selectors and updating owned-service fixtures to the managed-definition contract
  • Targeted update-cli changed gate — repository guards, core-test typecheck, and lint passed
  • Queue-edit reconnect E2E — 5 consecutive CI-mode runs passed via the supported Control+Enter submit path; targeted repository gate passed
  • Control UI startup bundle — 340,832 B gzip with fixed build identity (68 B below the 340,900 B baseline+tolerance limit)
  • node scripts/check-changed.mjs — passed all selected UI, extension, typecheck, lint, boundary, dead-code, database-first, and cycle gates
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --max-priority P1 — clean, no accepted/actionable findings (0.88 confidence)

Regression proof: restoring selected-pane/run-ID targeting makes both page-ingress ownership cases fail for the intended reason; restoring event-owned scope makes those cases and inactive-pane-first ordering pass. Restoring the pre-fix steering boundary makes the silent-payload regression persist a visible NO_REPLY row; restoring the predicate leaves the boundary empty.

Codex dependency contract

Direct sibling Codex source inspection confirms the contract this patch relies on:

  • codex-rs/app-server-protocol/src/protocol/v2/turn.rs requires turn/steer to name the active turn.
  • codex-rs/app-server/src/request_processors/turn_processor.rs submits steer input through steer_turn.
  • codex-rs/app-server/src/bespoke_event_handling.rs emits item/completed independently from the later enclosing turn/completed notification.

Therefore a completed answer before a same-turn steer is an authoritative boundary OpenClaw must persist.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 11:59 PM ET / August 26, 2026, 03:59 UTC.

ClawSweeper review

What this changes

The PR persists a completed Codex answer before a steer and prevents Control UI terminal events with a reused run ID from altering another session’s transcript or queued send.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review: no discrete source defect was found, but this Codex-dependent fix cannot receive a merge verdict until an owner directly verifies the required upstream completion-ordering contract and exact-head CI finishes.

Priority: P1
Reviewed head: 07a278cabbaea50a6f2b0b155d38c3589d14e4a5
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has focused source and regression coverage, but direct verification of its external Codex ordering premise is still missing.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR includes before/after Control UI video evidence, but this review does not call the Codex-dependent proof sufficient because the required upstream contract source was unavailable.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR includes before/after Control UI video evidence, but this review does not call the Codex-dependent proof sufficient because the required upstream contract source was unavailable.
Evidence reviewed 6 items Codex steering boundary: The new steering snapshot selects a completed terminal assistant item, mirrors it with an item-specific identity, and returns its identifier for post-mirror persistence marking.
Codex caller and duplicate suppression: The active-turn caller marks the boundary only after transcript mirroring succeeds; the assistant projection then excludes pre-boundary text from terminal synthesis.
Control UI ownership boundary: Terminal handling derives an outbox scope from the event session and agent, while visible cleanup remains gated by selected-session ownership; queue lookup now requires that scope plus run ID.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/codex/src/app-server/event-projector.assistant.test.ts extensions/codex/src/app-server/run-attempt.steering.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.extension-codex.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128257-W6OMdt/target

 ✓  extension-codex  extensions/codex/src/app-server/event-projector.assistant.test.ts (22 tests) 108ms
 ✓  extension-codex  extensions/codex/src/app-server/run-attempt.steering.test.ts (10 tests) 806ms
     ✓ marks the active run aborted before asynchronous cleanup releases its handle  528ms

 Test Files  2 passed (2)
      Tests  32 passed (32)
   Start at  03:59:54
   Duration  30.47s (transform 24.13s, setup 1.02s, import 28.18s, tests 914ms, environment 0ms)

[test] passed 1 Vitest shard in 36.55s
[test] starting test/vitest/vitest.extension-codex.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128257-W6OMdt/target

 ✓  extension-codex  extensions/codex/src/app-server/run-attempt.steering.test.ts (10 tests) 1798ms
     ✓ marks the active run aborted before asynchronous cleanup releases its handle  539ms
 ✓  extension-codex  extensions/codex/src/app-server/event-projector.assistant.test.ts (22 tests) 73ms

 Test Files  2 passed (2)
      Tests  32 passed (32)
   Start at  04:00:32
   Duration  14.88s (transform 7.83s, setup 467ms, import 12.31s, tests 1.87s, environment 0ms)

[test] passed 1 Vitest shard in 21.01s

Assertions:

  • PASS expect_output: passed

How this fits together

The Codex plugin converts app-server item notifications into durable agent-transcript messages before steering input is accepted. Control UI pages receive Gateway chat events and use session-and-agent ownership to decide which transcript and durable outbox row may change.

flowchart LR
  A[Codex item completion] --> B[Assistant projection]
  B --> C[Steering transcript mirror]
  C --> D[Durable agent transcript]
  E[Gateway terminal event] --> F[Session and agent ownership check]
  F --> G[Selected transcript]
  F --> H[Scoped queued-send cleanup]
Loading

Decision needed

Question Recommendation
Can a Codex-protocol owner directly verify the pinned app-server source confirms that an assistant item can complete before the enclosing turn completes, and accept this boundary before merge? Verify upstream ordering and proceed: Inspect the pinned Codex source, confirm the event-ordering premise, and merge only after exact-head checks complete successfully.

Why: Repository policy requires the acting reviewer to inspect that exact upstream runtime contract before a Codex verdict; the required sibling checkout was unavailable here.

Before merge

  • Resolve merge risk (P1) - The central persistence boundary depends on Codex emitting item completion independently of later turn completion; direct upstream-source verification required by repository policy was unavailable.
  • Resolve merge risk (P1) - This bug fix grows production code by 113 net lines, so the two explicit ownership boundaries should be accepted only after the upstream contract and exact-head checks confirm the added state is necessary.
Agent review details

Security

None.

PR surface

Source +113, Tests +271. Total +384 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 7 164 51 +113
Tests 8 309 38 +271
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 473 89 +384

Review metrics

Metric Value Why it matters
Production versus test delta production +164/-51 (net +113); tests/test support +309/-38 (net +271) The bug fix adds two durable ownership boundaries, so the positive production growth needs the upstream contract check before merge.

Merge-risk options

Maintainer options:

  1. Verify the upstream contract before merge (recommended)
    Directly inspect the pinned Codex completion-ordering source and wait for the exact-head checks before accepting the new transcript persistence boundary.
  2. Pause pending protocol evidence
    Leave the PR open if the upstream source cannot establish the asserted item-completed-before-turn-completed behavior.

Technical review

Best possible solution:

Retain the session-scoped UI and item-completion ownership boundaries, then merge only after a Codex owner verifies the pinned upstream ordering contract and the exact head is green.

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

No high-confidence end-to-end reproduction was established here: the UI collision path is source-reproducible, but the Codex ordering premise cannot be confirmed without the required upstream source.

Is this the best way to solve the issue?

Unclear; the source boundaries are coherent and targeted, but direct verification of the Codex event-ordering contract is still required to establish that this is the best fix.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 937c89675b04.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: The change addresses active-session transcript loss and cross-session queued-send contamination.
  • merge-risk: 🚨 compatibility: Existing terminal-event and outbox matching move from run-ID-only behavior to explicit session-and-agent scope.
  • merge-risk: 🚨 session-state: The patch changes durable transcript persistence and selected-session queue cleanup.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR includes before/after Control UI video evidence, but this review does not call the Codex-dependent proof sufficient because the required upstream contract source was unavailable.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. This maintainer-authored PR includes before/after Control UI video evidence, but this review does not call the Codex-dependent proof sufficient because the required upstream contract source was unavailable.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current-main blame for both the Codex projector setup and Control UI chat ownership region points to the recent consolidation commit. (role: recent area contributor; confidence: medium; commits: 3caf21bdd4c3; files: extensions/codex/src/app-server/event-projector.ts, ui/src/pages/chat/chat-gateway.ts, ui/src/pages/chat/chat-state-events.ts)

Rank-up moves

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

  • Have a Codex-protocol owner inspect and cite the pinned upstream item/turn completion ordering.
  • Wait for the current head’s required checks to finish green before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-23T17:31:30.154Z sha dd27e12 :: needs changes before merge. :: [P1] Gate terminal page effects by session ownership
  • reviewed 2026-08-24T21:02:06.347Z sha dd27e12 :: needs changes before merge. :: [P1] Gate terminal page effects by session ownership
  • reviewed 2026-08-24T21:18:59.417Z sha dd27e12 :: found issues before merge. :: [P1] Gate terminal page effects by session ownership
  • reviewed 2026-08-25T14:02:07.879Z sha 3af96fd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T14:53:09.287Z sha 0d255dc :: needs changes before merge. :: [P1] Restore the public Claude CLI credential type exports
  • reviewed 2026-08-25T15:36:32.233Z sha 0d255dc :: found issues before merge. :: [P1] Restore the public Claude CLI credential type exports
  • reviewed 2026-08-26T02:24:26.007Z sha a29d60c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T03:01:43.357Z sha 378ae5d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 23, 2026
@clawsweeper
clawsweeper marked this pull request as ready for review August 23, 2026 17:25
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 23, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/root-cause-analysis-for-thread-error branch from dd27e12 to 7478cd7 Compare August 25, 2026 13:45
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Addressed the latest ClawSweeper P1 at head 3af96fd027fec67eef29fbfc5b3b20ad12036a84.

  • Page ingress now resolves the terminal event's canonical outbox scope before handoff/removal; selected-pane cleanup remains session-gated.
  • Delivered-send read/removal now requires explicit session/agent scope; the run-ID-only fallback is gone.
  • Unscoped literal global terminals route to the default agent rather than the selected agent.
  • Added dual-outbox shared-run and default-vs-selected global regressions while retaining inactive-pane-first coverage.
  • Exact pinned Codex rust-v0.149.1 source confirms item completion can precede enclosing turn completion.

Local proof: Codex steering 10/10, chat queue 279/279, chat gateway 167/167, browser E2E 4/4, check-changed green, P1-level autoreview clean.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot
roboclaw-bot force-pushed the openclaw/root-cause-analysis-for-thread-error branch from 3af96fd to a6fe20e Compare August 25, 2026 14:38
@roboclaw-bot
roboclaw-bot requested a review from a team as a code owner August 25, 2026 14:38
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: L and removed size: M labels Aug 25, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/root-cause-analysis-for-thread-error branch from a6fe20e to 0d255dc Compare August 25, 2026 14:46
@openclaw-barnacle openclaw-barnacle Bot removed the gateway Gateway runtime label Aug 25, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 25, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/root-cause-analysis-for-thread-error branch from 0d255dc to 454a54b Compare August 26, 2026 02:11
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/root-cause-analysis-for-thread-error branch from 454a54b to a29d60c Compare August 26, 2026 02:18
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: L and removed size: M labels Aug 26, 2026
@clawsweeper clawsweeper Bot added proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 26, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/root-cause-analysis-for-thread-error branch from 07a278c to 54ff865 Compare August 26, 2026 04:12
@roboclaw-bot
roboclaw-bot merged commit ce08e25 into main Aug 26, 2026
150 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

@roboclaw-bot
roboclaw-bot deleted the openclaw/root-cause-analysis-for-thread-error branch August 26, 2026 04:27
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…eads (openclaw#128257)

* fix(codex): isolate steered thread transcripts

* fix(ui): scope terminal queue cleanup

* refactor(codex): split steering snapshot assembly

* fix(codex): suppress silent steering boundaries

* chore(ui): document chat event ownership

* test(ui): await Lobsterdex bootstrap requests

* test(update): isolate managed service selectors

* test(ui): submit queue edits by keyboard

* refactor(ui): tighten chat event ownership

* refactor(ui): narrow terminal chat payloads

Co-authored-by: Tak Hoffman <[email protected]>

---------

Co-authored-by: RoboClaw <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui cli CLI command changes extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants