Skip to content

fix(codex): opening a Codex session with large tool output freezes the Control UI - #136282

Merged
obviyus merged 2 commits into
openclaw:mainfrom
goslingmanagment:fix/codex-transcript-bounded-pages
Sep 4, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
goslingmanagment:fix/codex-transcript-bounded-pages

Conversation

@goslingmanagment

@goslingmanagment goslingmanagment commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #136281

What Problem This Solves

Opening a native Codex session from the Control UI sidebar can render whole tool outputs and return more transcript items than requested. This repair keeps catalog reads item-bounded and applies the existing tool-result preview limit to both text and raw fallbacks.

Root cause and repair

  • The catalog passed an item count to thread/turns/list, then flattened every item from those turns.
  • The UI preferred text, bypassing the existing 500-character raw-output preview.
  • Native paginated stores now use thread/items/list. The existing shared 512 KiB text and 20 MiB page limits apply before transport, including nested node payload encoding.
  • Byte-limited pages re-read the same native anchor with a smaller count so the returned cursor cannot skip omitted items.
  • Supported legacy stores and older/native node readers retain the shipped turn command. A native turn anchor plus an exclusive item ID continues within a turn without newest-relative offsets.
  • The UI chooses text or raw output, then applies one Unicode-safe 500-character preview and marks shortened output. Full native source data and generic raw output remain intact.

No configuration, database schema, global protocol version, or generic output policy changes. The original proposed 4 KiB truncation and raw-data removal are not retained.

Evidence

Baseline: 5b6db6d4436afd1d9413e50bea2836425457b929.
Repaired head: 52948f7f3ac3feca3ab8870f1e5792bac71736fd.

Disposable benign native sessions were created with supported Codex app-server operations. The same sessions were opened through a real Gateway, actual dashboard pairing, the Control UI sidebar, and upward scrolling. No operator history, fabricated transcript rows, mocked Gateway, or substituted transport was used.

Scenario Baseline Repaired local and paired-node paths
Small control 3 items, full short output 3 items, full short output
Unicode, 57 items 57 items for limit 50; no next cursor 50 + 7 items
Large ASCII, 67 items Visible safe-response-size error 19 + 17 + 17 + 14 items
Tool previews Approximately 39,000–42,000 characters in the Unicode case At most 500 characters, marked when shortened
Browser responsiveness A 16,333 ms main-thread task while loading Unicode output Largest observed task across repaired loads and scrolling: 550 ms

Every returned item ID matched the native source in order, with no omissions or duplicates. Every raw tool-output byte length and SHA-256 matched the native source. Visible messages matched chronological source order. All pages stayed below 20 MiB; the largest observed catalog frame was 19,592,925 bytes. These timings are observations from the same isolated browser environment, not a general performance guarantee.

A real paired headless node was approved through the normal pairing flow. Its sidebar entries and node: catalog reads exercised the bounded node command; these are not local-only results.

A real paired-node Codex session showing a shortened tool-result preview and its truncation marker

Dependency and compatibility evidence

OpenClaw pins @openai/codex 0.153.0. Direct upstream implementation inspection and actual native capability probes confirmed that paginated stores support thread/items/list, while the supported legacy store returns method-not-found. Relevant upstream code: app-server-protocol/src/protocol/v2/thread.rs, app-server/src/request_processors/thread_processor.rs, and thread-store/src/local/thread_history/read.rs.

The existing raw codex.appServer.thread.turns.list.v1 command remains unchanged for continuation and older/native nodes. The bounded command is optional and is not advertised by app-owned embedded workers whose native catalog can use another home.

A legacy turn response or single item above the transport ceiling still fails visibly. This change does not claim to remove that native legacy limitation. Inline Canvas-card history duplication is outside this repair.

Validation and review scope

  • Main-first real browser failure captured before repair.
  • Exact-head full build passed.
  • Exact-head Codex transcript, node-listing, and node-continuation test files passed; all 34 UI catalog tests passed.
  • New count regression failed on unchanged main with 57 instead of 50 items. Four preview regression cases also failed on main.
  • The complete changed-scope checker passed on the exact head: formatting,
    policy guards, doctor tests, core-test/UI/plugin/plugin-test type checks,
    translations, dead exports, lint, and runtime import cycles.
  • git diff --check passed.
  • Previous review's persistent-store concern does not apply: cursors are request values, and no stored representation or schema changes. No Rank-up moves: list was present in that review.
  • Regression introduction is not attributed; the failure was directly reproduced on the recorded main baseline.

Production: +294/-49, net +245. Tests and support: +496/-94. Docs: +13/-6. Production growth supplies native item paging, bounded node transport, and the supported legacy cursor path without changing the shipped raw-turn contract. The preview policy is unified in the UI; the obsolete flattened-turn-only reader is removed.

Thanks @goslingmanagment and @dmsrg399 for the report and original repair. Revised and verified with AI-assisted maintenance.

…e Control UI

`sessions.catalog.read` forwarded whatever `thread/turns/list` returned. Its
`limit` bounds App Server turns rather than transcript items, so a thread whose
turns are long arrived as a single page, and the projection then shipped every
tool payload twice: the full `aggregatedOutput` as `text` plus the entire item
as `raw`. One real session answered with 19.19 MB in one response and the
Control UI tab stopped responding for good.

Bound the payload at the producer, the way the sibling catalogs already do:

- preview tool text at 4 KiB, flag it `truncated`, and drop the duplicated
  `raw` item, which no other catalog provider sets and core strips before
  history import
- page the flattened turn window through the shared
  `sessionCatalogPaging.boundTranscriptPage`, with a cursor pairing the upstream
  turn cursor with the item offset already delivered, so a page boundary can
  fall inside a turn without losing or repeating items
- stop echoing the upstream `backwardsCursor`, which the closed read-result
  schema never declared and no client consumes
- render the truncation marker in the Control UI and delete the raw-item
  fallbacks whose 500-character clamp `text` had been short-circuiting

Measured through the production read path against a 34.7 MB rollout:
19.19 MB / 1382 items in one page becomes 63 KiB / 50 items, cursor-resumable.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@goslingmanagment
goslingmanagment marked this pull request as ready for review September 2, 2026 11:55
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui extensions: codex size: M labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 11:02 AM ET / 15:02 UTC.

ClawSweeper review

What this changes

The PR pages Codex session transcripts, bounds tool-output previews, and preserves continuation across native and legacy Codex stores.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

The revised branch fixes the large-payload paging and preview paths, but its new legacy continuation encoding can emit a cursor that the next read rejects. Repair that boundary before merge.

Priority: P1
Reviewed head: 52948f7f3ac3feca3ab8870f1e5792bac71736fd

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The real-flow evidence is strong and the repair direction is sound, but the continuation-cursor defect is a material correctness gap.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The supplied exact-head evidence exercises the real Codex-to-Gateway-to-Control-UI transcript flow before and after the repair; this review could not independently fetch the linked artifact because name resolution is unavailable.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The supplied exact-head evidence exercises the real Codex-to-Gateway-to-Control-UI transcript flow before and after the repair; this review could not independently fetch the linked artifact because name resolution is unavailable.
Evidence reviewed 7 items Introduced composite cursor: The PR encodes a legacy upstream turn cursor and item ID as JSON followed by base64url, expanding the opaque cursor before returning it to callers.
Accepted cursor limit: Catalog cursors longer than 4,096 characters are rejected, including response cursors validated by the transcript path.
Legacy continuation path: When a legacy turn is split, the returned backwards cursor is passed to the composite encoder, so a near-limit native cursor becomes the next client-supplied catalog cursor.
Findings 1 actionable finding [P2] Keep legacy continuation cursors within the accepted bound
Security None None.

How this fits together

The Codex plugin reads stored Codex threads through the Gateway session catalog for display in the Control UI. It transforms native transcript items into paged catalog records, which the UI imports as bounded chat-history previews.

flowchart LR
  A[Codex stored thread] --> B[Codex plugin]
  B --> C[Transcript paging]
  C --> D[Gateway session catalog]
  D --> E[Control UI]
  E --> F[Bounded history preview]
Loading

Before merge

  • Keep legacy continuation cursors within the accepted bound (P2) - A valid opaque legacy turn cursor near 4,096 characters is expanded by JSON/base64url plus the item ID, then rejected by the next catalog read before it reaches Codex. Preserve the opaque cursor without truncation and add a near-limit round-trip regression test.
  • Resolve merge risk (P1) - A legacy Codex transcript whose valid opaque native cursor is near 4,096 characters can receive a continuation cursor that OpenClaw rejects on the next read, preventing older history from loading.
  • Complete next step (P2) - Repair the legacy composite continuation cursor and add a maximum-length regression test before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P2] Keep legacy continuation cursors within the accepted bound — extensions/codex/src/session-catalog-transcript.ts:39-43
Agent review details

Security

None.

PR surface

Source +245, Tests +402, Docs +7. Total +654 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 11 294 49 +245
Tests 5 496 94 +402
Docs 1 13 6 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 803 149 +654

Review metrics

Metric Value Why it matters
Production and test delta production +294/-49; tests/support +496/-94; docs +13/-6 The production growth is justified by producer-side transcript paging and output bounds, but the cursor boundary remains incorrect.

Stored data model

Persistent data-model change detected: serialized state: extensions/codex/src/session-catalog-transcript.ts, unknown-data-model-change: extensions/codex/src/session-catalog-listing.ts, unknown-data-model-change: extensions/codex/src/session-catalog-transcript.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #136281
Summary: This PR is the candidate fix for the linked large-Codex-transcript Control UI hang.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Repair legacy cursor continuation (recommended)
    Keep every emitted legacy continuation cursor valid under the catalog boundary and add a maximum-length round-trip regression test before merge.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Repair the legacy composite continuation cursor and add a maximum-length round-trip regression test.

Technical review

Best possible solution:

Retain producer-side paging and preview bounds, but represent legacy continuation without expanding an accepted opaque cursor beyond the catalog limit, and cover the maximum-length round trip.

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

Yes, source and the supplied exact-head user-flow evidence establish the affected transcript path, although this read-only review did not execute it.

Is this the best way to solve the issue?

No: producer-side item paging and unified UI preview bounds are the right design, but the legacy continuation cursor violates the established input boundary for a valid upstream cursor.

Full review comments:

  • [P2] Keep legacy continuation cursors within the accepted bound — extensions/codex/src/session-catalog-transcript.ts:39-43
    A valid opaque legacy turn cursor near 4,096 characters is expanded by JSON/base64url plus the item ID, then rejected by the next catalog read before it reaches Codex. Preserve the opaque cursor without truncation and add a near-limit round-trip regression test.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head evidence exercises the real Codex-to-Gateway-to-Control-UI transcript flow before and after the repair; this review could not independently fetch the linked artifact because name resolution is unavailable.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The supplied exact-head evidence exercises the real Codex-to-Gateway-to-Control-UI transcript flow before and after the repair; this review could not independently fetch the linked artifact because name resolution is unavailable.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The supplied exact-head evidence exercises the real Codex-to-Gateway-to-Control-UI transcript flow before and after the repair; this review could not independently fetch the linked artifact because name resolution is unavailable.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 availability: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The PR addresses a deterministic Control UI hang when opening Codex sessions with large tool output.
  • merge-risk: 🚨 compatibility: The new legacy cursor representation can make a valid upstream continuation unusable to existing catalog clients.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The supplied exact-head evidence exercises the real Codex-to-Gateway-to-Control-UI transcript flow before and after the repair; this review could not independently fetch the linked artifact because name resolution is unavailable.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head evidence exercises the real Codex-to-Gateway-to-Control-UI transcript flow before and after the repair; this review could not independently fetch the linked artifact because name resolution is unavailable.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The supplied exact-head evidence exercises the real Codex-to-Gateway-to-Control-UI transcript flow before and after the repair; this review could not independently fetch the linked artifact because name resolution is unavailable.

Evidence

Acceptance criteria:

  • [P1] pnpm vitest extensions/codex/src/session-catalog-transcript.test.ts.
  • [P1] pnpm vitest extensions/codex/src/session-catalog-node-listing.test.ts extensions/codex/src/session-catalog-node-continue.test.ts.

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Repair the legacy composite cursor and add a maximum-length round-trip regression test.

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 (2 earlier review cycles)
  • reviewed 2026-09-02T12:03:25.140Z sha fff68ad :: needs maintainer review before merge. :: none
  • reviewed 2026-09-04T14:44:13.891Z sha fff68ad :: needs real behavior proof before merge. :: [P1] Page items before retrieving full turns | [P1] Keep raw fallbacks for generic catalog items | [P2] Keep composite cursors within the accepted size | [P2] Mark shared-pager text truncation

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 4, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 4, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
@obviyus
obviyus merged commit 67351d8 into openclaw:main Sep 4, 2026
195 of 196 checks passed
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@obviyus

obviyus commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks @goslingmanagment and @dmsrg399!

Landed as 67351d8, from verified head 52948f7.

Proof: Real native Codex sessions opened through the Gateway and Control UI sidebar, with older pages loaded by scrolling. Both local and normally paired headless-node paths passed.

  • Bug: Turn counts were treated as item counts, and projected tool text bypassed the existing preview clamp.
  • Fix: Use native item paging where supported, preserve legacy native anchors and raw output, and apply one Unicode-safe 500-character UI preview.
Before After
57 items for a 50-item request, no continuation 50 + 7 items, complete and ordered
Large-session response-size error All 67 items over four bounded pages
16,333 ms observed browser task At most 550 ms across the repaired proof run

All native item IDs and raw-output hashes matched. Short output remained complete. The existing over-ceiling legacy-turn limitation is unchanged.

Exact-head independent review, the complete changed-scope checker, and CI passed.

vincentkoc added a commit that referenced this pull request Sep 4, 2026
…9-prep

* commit '407a8f453c0f0306af1ddc0aafa8697c1d49a9e7': (312 commits)
  perf(ui): coalesce automation event refreshes (#138065)
  fix: reject incomplete Skill Workshop directory reads (#138082)
  test(ui): decouple rendering checks from generated wording (#138283)
  perf: avoid temporary entries in bounded JSON traversal (#138017)
  fix(irc): render complete messages before splitting (#138328)
  perf: prepare worker trajectory payloads only for recorded events (#138086)
  fix(mcp): paginated listings no longer time out after a forward clock step (#137206)
  fix(codex): page native transcripts and bound UI previews (#136282)
  feat(gateway): apply more settings without restarting (#138112)
  fix(docs): preserve mirrored ClawHub maturity links (#138241)
  fix(test): own UI animation and legacy database setup (#138296)
  fix(tts): preserve literal directives in Markdown code (#138319)
  fix: load chat widgets behind authenticated gateways (#138074)
  chore(ui): cover native approval finalization (#137259)
  fix(cron): cancel conditions before main-session handoff (#138313)
  fix(backup): preserve text after embedded NUL characters (#138327)
  fix(android): align composer control sheets (#137442)
  fix(ci): wait for replacement PR runs instead of stale failures (#138307)
  fix(sessions): keep Gateway responsive with long transcripts (#138094)
  fix(computer): map window inputs to delivered image coordinates (#138271)
  ...

# Conflicts:
#	scripts/release-check.ts
#	test/release-check.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…36282)

Page native Codex catalog reads by items and shared byte bounds. Preserve native cursor progress, legacy node compatibility, full raw output, and the existing 500-character UI preview contract.

Verified real local and paired-node sidebar pagination with small, large ASCII, and Unicode native sessions. All items retained their order and raw output. The observed long browser task fell from 16,333 ms to at most 550 ms in the repaired proof run.

Co-authored-by: Dmitriy <[email protected]>
Co-authored-by: Ayaan Zaidi <[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 docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Control UI hangs when opening a Codex session with large tool output

3 participants