Repository navigation
fix(inference): harden Codex streaming, cancellation, and live QA - #116012
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 12:29 AM ET / 04:29 UTC. ClawSweeper reviewWhat this changesThis PR changes Codex/OpenAI inference lifecycle handling so interrupted turns await a truthful terminal outcome, restricted completion turns retain only source-delivery authority, and goal completion prompts the model to send a visible final reply. Merge readiness⛔ Blocked by patch quality or review findings - 8 items remain Keep this protected PR open for manual review. The supplied terminal proof is meaningful, but this checkout cannot read the exact PR head and the required sibling Codex source is absent, so a source-backed Codex contract verdict or merge recommendation would not be valid. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw runs agent turns through an embedded runtime and, for Codex, an app-server adapter. The adapter receives turn notifications and cancellation results, then terminal state drives channel delivery, transcripts, and durable goal/session state. flowchart LR
Inbound[Inbound conversation] --> Runtime[Embedded agent runtime]
Runtime --> Codex[Codex app-server adapter]
Codex --> Terminal[Terminal turn outcome]
Terminal --> Delivery[Visible reply delivery]
Terminal --> Session[Goal and session state]
Delivery --> User[Conversation result]
Decision needed
Why: Repository policy forbids a Codex protocol/runtime verdict without direct upstream-source inspection, and the local partial clone cannot retrieve the submitted revision. Before merge
Agent review detailsSecurityNone. Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Restore access to the exact PR revision and compatible sibling Codex source, then review the terminal-notification, shared-client, source-delivery, and goal-state changes against the resulting merge head before a maintainer decides whether to land it. Do we have a high-confidence way to reproduce the issue? No direct reproduction was run in this read-only checkout. The supplied PR comment contains a concrete exact-head live Testbox reproduction-and-fix transcript, but the branch itself was unavailable for independent execution or source tracing. Is this the best way to solve the issue? Unclear. The stated owner-boundary repair is plausible and the supplied proof is substantial, but the exact patch and upstream Codex interruption contract must be inspected before concluding it is the best fix rather than a compatibility-changing alternative. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9099520ae23e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
ac06490 to
c816d4a
Compare
1e42472 to
6261932
Compare
|
Maintainer real-behavior proof for exact head The live failure was independently reproduced before repair and its retained SQLite transcript proved the exact user-visible root cause: The fix keeps goal accounting at the goal owner: active-goal context, the Exact-head focused Codex terminal/shared-client proof: Additional focused proof: 107 goal/context/QA assertions, 105 CLI execution-lifecycle assertions after the current-main rebase, targeted lint clean, and fresh Codex autoreview ( Direct upstream Codex source personally inspected:
ClawSweeper rank-up moves addressed: exact-head real-provider output and runner URL attached; delayed/missing terminal notification and sibling-client lease ownership covered by focused Codex tests and upstream source; current exact-head hosted CI gates verified before repository-native prepare/merge. Keep this as one lifecycle repair because streaming, terminal confirmation, shared-client retirement, scoped completion authority, and final channel visibility all enforce the same no-silent-outcome invariant. |
|
Merged via squash.
|
…enclaw#116012) * fix(inference): harden Codex turns, streams, and live QA * fix(inference): dispatch open CR-delimited response frames * fix(inference): finish live goal and split streaming regressions * fix(codex): wait for interrupted turn completion * fix(codex): narrow terminal collector notification ownership * fix(inference): harden completion authority and lifecycle * fix(inference): use canonical source delivery contract * test(inference): align lifecycle probes with current main * style(inference): format source delivery verification * fix(goals): prevent premature completion across staged work * fix(qa): settle streamed goal turns before continuation * fix(goals): require visible replies after goal completion * test(qa): keep goal flow regressions within lint limits
What Problem This Solves
Fixes an issue where users running Codex/OpenAI agent turns could see interrupted or incomplete inference reported as successful, lose streamed responses or audio transcripts, interrupt a different shared conversation, route a model to the wrong backend, lose scoped delivery authority, or have an unfinished active goal silently close or fail to continue.
Why This Change Was Made
One cross-cutting inference invariant owns this change: every authorized turn must reach exactly one truthful, visible terminal outcome across streaming, cancellation, provider/harness selection, scoped tool authority, delegated completion, and active-goal continuation. The implementation follows the actual upstream Codex app-server contract, keeps a timed-out turn and its client lease alive through the matching terminal notification, safely retires an unconfirmed shared client, preserves failure/cancellation precedence and SSE boundaries, and keeps unfinished goal guidance visible to models even when Code Mode only advertises tool identifiers. QA now waits for the gateway's authoritative settled-run state before continuing a streamed goal turn.
This intentionally stays one lifecycle repair: splitting transport, terminal confirmation, client ownership, delivery projection, and real-harness regressions would remove the sibling-surface proof for the same invariant. No new public config/environment surface, protocol version, SQLite schema version, or plugin SDK contract is introduced.
User Impact
Codex and OpenAI conversations now complete, stream, cancel, retry, switch models, and deliver results predictably without affecting a sibling conversation. Operators receive visible terminal failures instead of silent success or disappearance. An unfinished active goal remains active until its objective is actually complete, and a bare
continuecan finish a real workspace task.Evidence
29786ddae572004be49d2083ae7868974968caa7; rebased onto currentmainat995a3e20a4dafter preserving both the newer live-tool-result limit and this branch's completion-authority checks.blacksmith-testbox, leasetbx_01kyxrr50gs8g24hhx9xyrj7rh; existing runner credentials hydrated without printing secrets).openai/gpt-5.6-lunaconcurrent live scenario matrix exercisesstreaming-final-integrity,goal-followthrough-live,luna-thinking-visibility-switch,codex-harness-no-meta-leak,medium-game-plan-codex-harness,medium-game-plan-openclaw-harness, andlong-context-progress-watchdog; both runtimes create real playable game artifacts, Codex processes a 2,000-line long-context fixture, and the staged goal performs a real workspace write only after the barecontinueturn.openai/gpt-5.4runtime-pair proof passed five real scenarios through both OpenClaw and Codex: streaming integrity, legacy read-tool vocabulary, approval/tool followthrough, live goal continuation, and the 20-turn first-hour soak (10 runtime cells; 40 consecutive live soak turns).goal-context-next-turn,goal-context-survives-compaction,empty-response-retry-budget-exhausted,subagent-fanout-synthesis). Additional regression proof covers missing/delayedturn/completed, shared-client retirement and sibling-lease isolation, timeout/cancel precedence, SSE LF/CRLF/CR and split chunks, dynamic tools, and fallback delivery receipts; prior broad Codex sweep passed 147 files / 3,213 tests, and the frozen rebased sweep passed 1,033 assertions across 18 focused files.node scripts/run-vitest.mjs src/agents/tools/goal-tools.test.ts src/auto-reply/reply/inbound-meta.test.ts extensions/qa-lab/src/scenario-flow-runner.test.ts extensions/qa-lab/src/scenario-catalog.inference.test.ts-> 4 files / 107 tests passed. Adversarial fixtures prove active-to-idle settlement, premature goal completion, early workspace writes, and per-inbound final-reply provenance. The actual goal tool regression verifies both durable completion and its model-visible next-action contract.node scripts/run-vitest.mjs src/agents/command/attempt-execution.cli.test.ts src/agents/tools/goal-tools.test.ts-> 112 tests passed, including the complete 105-case CLI/execution lifecycle shard.pnpm test extensions/codex/src/app-server/attempt-client-cleanup.test.ts extensions/codex/src/app-server/attempt-turn-watches.test.ts extensions/codex/src/app-server/run-attempt.turn-watches.test.ts extensions/codex/src/app-server/shared-client.test.ts-> 4 files / 188 tests passed (94 turn-watch, 57 shared-client, 29 watchdog, 8 cleanup assertions).write -> successful file result -> update_goal(complete) -> NO_REPLY, leaving the direct conversation silent despite the finished artifact. The owner-boundary repair adds explicit requested-final guidance to the active-goal context,update_goaldescription, and model-visible result. Authenticatedopenai/gpt-5.6-lunathen passed the realwrite -> complete -> visible requested finalpath on the pushed fix.autoreview clean: no accepted/actionable findings reported(gpt-5.6-sol, high reasoning, 0.99 confidence).LLM request failedoccurs on unrelated main runs 30681494813 and 30681782606; same-head retry passed all 16 PTY cases, including Esc cancellation in 3.394 seconds. No unrelated TUI code was changed.Direct upstream Codex contract inspection
The acting maintainer personally inspected the sibling upstream checkout before making the protocol/runtime judgment:
../codex/codex-rs/app-server/src/bespoke_event_handling.rs:1090-1107— emitted terminal notification.../codex/codex-rs/app-server/src/request_processors/turn_processor.rs:1425-1444and:873-898— interruption acknowledgment versus actual terminal completion.../codex/codex-rs/core/src/client.rs:857-883and../codex/codex-rs/protocol/src/models.rs:809-823— model routing and provider/model wire contract.../codex/codex-rs/protocol/src/dynamic_tools.rs:21-55,../codex/codex-rs/core/src/tools/handlers/dynamic.rs:119-160, and../codex/codex-rs/core/src/tools/spec_plan.rs:607-907— dynamic-tool calls, permitted payloads, and model-visible tool descriptions.../codex/codex-rs/app-server/src/request_processors/thread_processor.rs:3505-3562— thread/request lifecycle ownership.ClawSweeper rank-up moves
turn/interruptversusturn/completedcontract evidence is listed above; the acting agent personally read the source.