Repository navigation
Description
Summary
thread/start accepts experimentalRawEvents: true, which makes the app-server stream every raw ResponseItem as rawResponseItem/completed (and emit rawResponse/completed). However, there is no way to enable raw events on thread/resume or thread/fork: ThreadResumeParams and ThreadForkParams have no such field, and the app-server hardcodes raw_events_enabled: false when it attaches the listener for a resumed or forked thread. Since the flag lives only in the in-process ThreadState (it is not persisted with the thread), every resume of a non-running thread — including a same-process resume of a thread that was originally started with the flag — silently and permanently disables raw events for all subsequent turns. There is no workaround: we probed the param on thread/resume, config overrides (-c), thread/fork, and the experimental-feature APIs, and found no way to re-enable it.
Observed on codex-cli 0.144.4 via live JSON-RPC probes; the code is unchanged at current main (86102db, 2026-07-20).
Use case
We build durable session mirroring on top of the app-server: we start threads with experimentalRawEvents: true, journal each rawResponseItem/completed payload, and if the host running the app-server is lost we resume the thread on another host with thread/resume { threadId, history: [ ...journaled items ] }. This is exactly the "FOR CODEX CLOUD" flow that ThreadResumeParams.history documents. The gap means the mirror only survives one hop: after the first thread/resume, no further raw items are emitted, so the journal can never be brought up to date again and a second host failure loses the session.
Root cause (file/line, rust-v0.144.4 and main)
The flag is per-thread in-process state:
codex-rs/app-server/src/thread_state.rs:89—ThreadState.experimental_raw_events: bool(defaultfalse), set only viaset_experimental_raw_eventsfromThreadStateManager::try_ensure_connection_subscribed(..., experimental_raw_events)(thread_state.rs:497-524at main).codex-rs/app-server/src/request_processors/thread_lifecycle.rs:314-325— the listener event loop dropsEventMsg::RawResponseItem/RawResponseCompletedunless the thread's flag is set. Core always emits these events (codex-rs/core/src/session/mod.rs:3134-3142); the app-server filter is the only gate, and the flag is never persisted to the rollout.
Who sets the flag:
thread/startpassesparams.experimental_raw_eventsthrough to the listener attach —thread_processor.rs:1301-1310at main (:1285-1290at rust-v0.144.4). ✅thread/resume(both thehistoryvariant and disk resume converge on one attach site) hardcodesfalse—thread_processor.rs:3245-3255at main (:2858at rust-v0.144.4). ❌thread/forkhardcodesfalse—thread_processor.rs:4179-4189at main (:3609at rust-v0.144.4). ❌- Spawned child (subagent) threads inherit the flag from their parent thread since [codex] Inherit raw events for spawned child listeners #25603 ("Inherit raw events for spawned child listeners") —
thread_processor.rs:2981-3012at main. ✅
So the propagation gap was already recognized and fixed for spawned children in #25603; resume and fork were just not covered. A resume with history forks to a new thread id, and a disk resume of an unloaded thread builds a fresh ThreadState, so in both cases the default false wins and raw events are gone for good.
Reproduction (0.144.4)
thread/start { "experimentalRawEvents": true }→ run a turn →rawResponseItem/completednotifications arrive for every response item. ✅thread/resume { "threadId": "<id>", "history": [ ...items ] }(or plainthread/resumeafter the thread is unloaded) → run a turn → norawResponseItem/completednotifications, and no field onThreadResumeParamsaccepts the opt-in. ❌
Minimal transcript for step 2's turn (0.144.4): the turn streams item/started / item/completed etc. normally, but zero rawResponseItem/completed, confirming the events are filtered app-server-side rather than not produced (core emits them unconditionally; see above).
Proposed fix
Mirror the thread/start opt-in on the other two thread-construction methods, keeping the experimental naming and semantics:
- Add
#[experimental("thread/resume.experimentalRawEvents")] experimental_raw_events: booltoThreadResumeParams, and the equivalentthread/fork.experimentalRawEventstoThreadForkParams. - Pass the value through the existing
ensure_conversation_listener(..., raw_events_enabled)at the resume attach site (thread_processor.rs:3245) and the fork attach site (thread_processor.rs:4179), replacing the hardcodedfalse. - For the running-thread rejoin path in
resume_running_thread, set the flag on the existingThreadStatewhen requested (same monotonic enable-only semantics astry_ensure_connection_subscribed).
Because both new fields are #[experimental], the vendored (non-experimental) schema fixtures are unchanged, and the wire behavior for clients that don't send the field is identical.
We have this implemented and verified on a branch against current main (86102db): two new integration tests, thread_resume_with_history_supports_experimental_raw_events (tests/suite/v2/thread_resume.rs) and thread_fork_supports_experimental_raw_events (tests/suite/v2/thread_fork.rs), exercise resume-with-history and fork followed by a live turn against the mock Responses server and assert a rawResponseItem/completed notification arrives. Both fail with the current attach sites (the notification never arrives) and pass with the param plumbed through; the full thread_resume/thread_fork suites (60 tests) and cargo test -p codex-app-server-protocol (including the schema-fixture checks) pass, and write_schema_fixtures produces no diff. Happy to send the PR if the team wants to invite it, per the contribution policy — or feel free to just take the outline above; the change is small.
An alternative we considered: persisting the opt-in with the thread (rollout metadata) so resume restores it automatically. That is more invasive and changes semantics for existing clients, so the per-call param felt safer and consistent with thread/start.
Activity
bmaurer commentedon Jul 20, 2026
The fix described above is now pushed to a branch on my fork for easy review: https://github.com/bmaurer/codex/tree/fix/raw-events-resume-fork (single commit on top of 86102db; compare view: main...bmaurer:codex:fix/raw-events-resume-fork).
Happy to open it as a PR if the team invites one, per the contribution policy.
bmaurer commentedon Jul 20, 2026
Follow-up after more source digging: there IS a workaround pattern that avoids the resume gap entirely, which may be how Codex Cloud consumes this —
thread/inject_items(#17703). Starting a FRESH thread withexperimentalRawEvents: true, then injecting the captured raw history viathread/inject_items, then running turns keeps raw events enabled for the thread's whole life (andrecord_conversation_itemseven echoes the injected items asrawResponseItem/completed). Verified end-to-end on 0.144.4 with a live turn.So the resume/fork param asymmetry reported above is not blocking for us anymore — though it still seems worth fixing for API coherence (resume-by-
thread_id/pathusers get silent raw-event loss with no workaround that preserves the thread id). Feel free to deprioritize accordingly.bmaurer commentedon Jul 20, 2026
Closing this out:
thread/inject_items(#17703) fully covers our use case. Starting a fresh thread withexperimentalRawEvents: trueand injecting the captured raw history keeps raw events enabled for the thread's entire life — and the injected items are even echoed back asrawResponseItem/completedand persisted to the rollout, so the reconstructed thread is re-mirrored and locally resumable on the new host. Verified end-to-end on 0.144.4 with live turns.That appears to be the intended pattern for this scenario, so the resume/fork param asymmetry is a non-issue in practice. Leaving the branch up (https://github.com/bmaurer/codex/tree/fix/raw-events-resume-fork) in case the team still wants the params for API coherence, but closing as answered/not-needed.
test: Add resumed-session tool-call grouping conformance case
cassthebandit commentedon Oct 29, 2026
We still need the same-thread resume case described here. The new-thread +
thread/inject_itemsworkaround is useful for mirroring, but it does not preserve a resumed parent's thread identity or its existing native child ownership.On October 27, I reproduced the opt-in gap with an unmodified
codex-cli 0.164.0Linux ARM64 app-server and a local mocked Responses/SSE provider. The process ran in a network-disabled container with a syntheticCODEX_HOME, no credentials, and no real model calls:experimentalRawEvents:true: normal turn completion andrawResponse/completedwith the exact providerresponseId, thread ID and turn ID.experimentalRawEvents:true: normal turn completion but no raw completion notification.experimentalRawEvents:true: normal turn completion but no raw completion notification.rawResponse/completed. These controls matter because an item event is not a successful sampling-completion acknowledgment.All seven scenarios matched those expectations. This is a real app-server protocol test against a mocked HTTP provider, not a production-model test or a deterministic native compaction/preemption test.
A fresh source check on October 29 found the same gap at pinned main
9def09af. I did not build or run this newer source:ThreadResumeParamshas noexperimentalRawEventsfield.PendingThreadResumeRequestand subscribes without enabling the existing raw-events flag. The equivalent cold-resume gap is also present in therust-v0.165.0source; I did not run that binary.Our concrete use case is openclaw/openclaw#186128: distinguish a child result that native actually consumed in a successful sampling response from one merely included in a provider request before native preemption. Transport completion and generic turn completion are not sufficient substitutes. The existing
rawResponse/completednotification supplies the matching response identifier, but the cold-resume listener filter makes it unavailable for this identity-preserving path.Could this issue be reopened for the unresolved same-thread-ID resume case? The fresh-thread +
thread/inject_itemsworkaround addressed the original mirroring use case, but cannot preserve the parent thread identity and existing child ownership required by our integration. The reproduction and current-source evidence above show this gap still applies. We are keeping that evidence here rather than opening a duplicate, per the contribution guidance.The requested behavior is the resume opt-in described in the original report, covering both cold resume and the serialized loaded-thread rejoin path. We would preserve the existing default-false, enable-only semantics and reuse the existing completion notification. We are not proposing a new acknowledgment ledger or treating the issue's closed state as evidence the gap was fixed. Following the contribution policy, this is reproduction evidence and current-source design context, not an unsolicited code PR.
Standalone reproducer: same-thread resume raw events
Adding a runnable, dependency-free reproducer for this existing report. I reran the actual Linux ARM64
codex-cli 0.164.0native executable with Node.jsv24.22.1, a fresh syntheticCODEX_HOME, and a localhost HTTP/SSE Responses fixture inside a network-disabled container. No credentials or actual model requests were used.Binary SHA-256:
8813c8d8a4cea2eeba271b72ab22f49628b184b24ab18dbef06b4ce41e9a8d39.All seven baseline assertions passed:
experimentalRawEvents:true: still no raw events.experimentalRawEvents:true: completed turn, but no raw events.“Passed” here means the current baseline, including the missing resume capability, was reproduced, not repaired. The desired change would make scenarios 6 and 7 emit raw events and require updating their assertions. The fixture waits for the exact synthetic assistant output item before interrupting; user/developer input items cannot satisfy that condition.
Please consider reopening this report. New-thread + injected-history changes thread identity and therefore is not an equivalent workaround for integrations retaining existing parent/child ownership. The requested API capability is opt-in raw events on same-thread
thread/resume, including cold resume and a loaded but previously-disabled thread.Run
On Linux ARM64, with the above already-available binary and Node.js >=22, save the code below as
probe.mjsand run in a disposable network-disabled environment with loopback available:The output directory must not exist. The fixture pins checksum/version, creates only synthetic state there, writes result/event/request logs, and exits nonzero on assertion failure. It does not install dependencies. The network boundary is provided by the caller/container, not by JavaScript.
Evidence limits: runtime proof is pinned to 0.164.0, not a claim to have built or executed latest main. The pinned October 29 source inspection linked above remains separate evidence; this rerun does not build or execute that source. Failure/interruption controls do not prove the harder buffered-provider-completion/native-preemption race. This fixture does not test compaction, websocket routing, OpenClaw end-to-end delivery, or a patched binary.
Complete standalone probe.mjs
budzation commentedon Nov 16, 2026
Independent same-thread resume verification — 16 November 2026
I independently reran the standalone probe from this issue against the unmodified Linux ARM64 Codex 0.164.0 executable, SHA-256
8813c8d8a4cea2eeba271b72ab22f49628b184b24ab18dbef06b4ce41e9a8d39.The probe ran in a new user/network namespace with only loopback and no external route, a fresh synthetic CODEX_HOME and a local synthetic HTTP/SSE Responses provider. No credentials, real inference, user conversations or production Gateway state were used.
All seven baseline/control assertions matched:
experimentalRawEvents:true: completed turn, still no raw items/completion.experimentalRawEvents:true: completed turn, still no raw items/completion.This reproduces the missing capability, not a fix or a production delivery test.
I also inspected, but did not build or run,
rust-v0.169.0:ThreadResumeParamsstill has no raw-event opt-in, and the cold-resume listener attachment still passesfalse. Upgrading the native executable alone is therefore not a qualified solution on this evidence.The unresolved requirement remains identity-preserving resume opt-in, including cold resume and an initially-disabled loaded rejoin, with existing experimental/default-false/enable-only semantics. Fresh-thread history injection changes identity and is not equivalent for retained parent/child ownership.
Could maintainers reopen this issue for that remaining case? OpenClaw's consumption-receipt integration still needs positive native sampling acknowledgment; generic turn completion must not retire an unseen child result. Related: openclaw/openclaw#156070 and the explicitly blocked draft openclaw/openclaw#186128.
No claim is made that every historical OpenClaw handoff failure shares this cause. This probe does not exercise child spawning, native preemption/compaction, WebSocket inference, a patched executable or end-to-end external delivery.
budzation commentedon Nov 16, 2026
Same-ID resume: isolated candidate verification and proposed approach
Following up on the unmodified 0.164.0 probe with new producer-side evidence, not a production-deployment claim.
A source-built candidate based on
openai/codex@6aaac694803004a63c6f393d153c96d22521a6b9(0.164.0) preserves the thread ID and enables the missing notifications on both cold resume and an initially-disabled loaded rejoin. The proposed change is to add experimentalthread/resume.experimentalRawEvents, pass it to cold listener creation, and use the existing enable-only subscription operation when rejoining a loaded thread. Omitted/false retains the ordinary cold default and does not turn off an already-enabled loaded subscription. No fork/history identity substitution is involved.Reference diff: budzation@66183e5
This is a reference for the issue's root-cause/design discussion, not an external PR submission. The repository's issue-first/no-external-PR contribution policy is respected.
New isolated evidence
rawResponse/completedsampling acknowledgment on provider failure or interruption. These are standalone app-server probes, not the entire repository's integration suite.codex-app-server-protocol: 320 tests passed, 0 failed, 1 generation fixture intentionally ignored. Three new protocol tests cover default wire/experimental behavior, true opt-in, and explicit false.Limits and remaining need
This candidate covers
thread/resume, notthread/fork, and was tested at the pinned 0.164.0 source base, not current main. It does not prove OpenClaw custody recovery, native child/preemption behavior, WebSocket inference, scheduler retry reconciliation, crash recovery, external delivery, or exactly-once publication. The companion OpenClaw consumer remains draft-only and cannot pass its full strict build in the available incomplete SDK environment.Could the same-ID cold-resume and initially-disabled loaded-rejoin requirement be reconsidered on this evidence? Successful native sampling acknowledgment is necessary for consumers that must not mark an unseen child result consumed merely because a turn ended.