Skip to content

fix(codex): show the delivered answer, not a trailing NO_REPLY, in Activity - #116604

Closed
harjothkhara wants to merge 3 commits into
openclaw:mainfrom
harjothkhara:fix/codex-projector-trailing-no-reply
Closed

harjothkhara wants to merge 3 commits into
openclaw:mainfrom
harjothkhara:fix/codex-projector-trailing-no-reply

Conversation

@harjothkhara

@harjothkhara harjothkhara commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Closes #112468
Related: #123993

What Problem This Solves

Completes the last user-visible piece of #112468. The delivery half — a trailing NO_REPLY coda swallowing the turn's real answer in the channel reply — was fixed on main by #123993 (thanks @obviyus), whose persistable-assistant barrier now correctly ships the audible answer. This PR was originally the broader fix for that issue; it has been narrowed to the one vector #123993 does not cover:

Control UI Activity still shows NO_REPLY as the "Selected answer." turn/completed.items is a last-wins last_agent_message summary, so when the trailing silent token is the last completed agent message, finalizeAnswerCandidate selects the silent item. The operator sees NO_REPLY in Activity while the channel receives the real reply — the two surfaces disagree about what the turn said.

Why This Change Was Made

Verified against the pinned @openai/codex 0.147.0 source (extensions/codex/package.json:11), per the Codex dependency gate:

  • codex-rs/app-server/src/bespoke_event_handling.rs:1276-1285 — the only production constructor of turn/completed builds items as [last_agent_message] or []: never more than one item, never a tool item.
  • codex-rs/app-server/src/thread_state.rs:158-169 — last_agent_message is overwritten by every completed AgentMessage final (last-wins, no silence awareness), so a trailing NO_REPLY always shadows the real answer in the snapshot.

The fix re-derives the selected item when the snapshot-authoritative item is a silent payload: resolveDeliveredAnswerItemId() is an item-id mirror of collectAssistantTexts()'s merged precedence (audible post-barrier → any post-barrier persistable → pre-barrier audible → final text item), so Activity names exactly the item whose text delivery chose. It reuses the existing persistableAssistantBarrier — no parallel delivery path is introduced, and collectAssistantTexts() remains the single owner of delivered text.

Dropped from the original scope, with reasons:

  • The delivered-text override and its tests (~8 scenarios: JSON-envelope/quoted/reasoning-prefixed silent tokens, pre-tool answer revival, raw synthetic-id items) — redundant; traced to pass on current main via fix(codex): keep the real answer when a trailing coda follows #123993's barrier.
  • A cross-turn snapshot filter for finalizeAnswerCandidate — dead code by construction; turn.items cannot carry a cross-turn or tool item (citation above), and no ThreadItem variant carries a turnId field (codex-rs/app-server-protocol/src/protocol/v2/item.rs:226-397).
  • A silence-aware timeout-recovery gate (hasCompletedTerminalAssistantText) — would actively break legitimate silent-turn recovery; every real tool call produces live item notifications that already drive the supersession path, so the "tool appears only in the snapshot" premise is unreachable.

User Impact

Operators watching a run in Control UI Activity see the actual answer the user received, instead of NO_REPLY, whenever a late-injected event (typically a duplicate subagent completion notice) draws a contract-mandated silent coda after the real answer. Channel delivery is unchanged (already correct on main).

Evidence

Regression test: extensions/codex/src/app-server/event-projector.assistant.test.ts — "selects the delivered answer, not a trailing silent token, as the Activity answer (#116604)". Real answer completes, trailing NO_REPLY final completes, turn/completed carries only the silent item (matching the Rust summary semantics).

Red on unmodified main — the selected Activity event names the silent item:

AssertionError: expected [ { itemId: 'answer-2', …(7) } ] to deeply equal [ ObjectContaining{…} ]
- "itemId": "answer-1",
- "progressText": "The real review summary the operator should see.",
+ "itemId": "answer-2",
+ "progressText": "NO_REPLY",
+ "status": "selected",

Green with the fix:

node scripts/run-vitest.mjs extensions/codex/src/app-server/event-projector.assistant.test.ts
 Test Files  1 passed (1)
      Tests  22 passed (22)

Sibling suites (event-projector.commentary, .native-finalization, .native-audit, run-attempt.turn-watches): 172/172 pass. oxfmt --check and oxlint clean on touched files; git diff --check clean.

Production LOC: +40/−1 (one private helper + silent-payload branch in finalizeAnswerCandidate); tests +51. Cross-model review: default Codex pass clean; gpt-5.6-sol max-effort pass run before publication.

Proof gap (unchanged from prior reviews, stated honestly): no real Codex app-server session trace — that requires live credentials against a pinned server. The projector-level red/green above drives the same notification sequence the server emits per the cited codex-rs source.


🤖 This PR was prepared with AI assistance (Claude); the analysis, narrowing decision, and final diff were reviewed end-to-end.

@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. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 27, 2026, 1:06 PM ET / 17:06 UTC.

ClawSweeper review

What this changes

The PR makes Codex Activity select the audible delivered answer when a trailing silent reply is the completion snapshot.

Merge readiness

⛔ Blocked before merge - 11 items remain

Keep open: the Activity fix remains necessary on current main, but the new selector can choose an async message that delivery deliberately excludes, including a restricted update.

Priority: P1
Reviewed head: 6d87f3207c0c18016327322ebdb776c353f36a1e

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The PR has a focused intent and regression test, but an introduced async-boundary bug and missing real behavior proof block readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The supplied projector-level test output is useful supplemental evidence, but no after-fix Codex app-server-to-Control-UI trace or capture is provided; add redacted real proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The supplied projector-level test output is useful supplemental evidence, but no after-fix Codex app-server-to-Control-UI trace or capture is provided; add redacted real proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Historical verification Needs maintainer review A historical verification receipt failed or is malformed. A maintainer must resolve that verification blocker before merge; independently assessed contributor proof remains valid.
Evidence reviewed 6 items Current-main gap: Current main still selects the completion snapshot item directly; it has no delivered-answer item resolver, so the requested Activity mismatch remains distinct from the earlier delivery repair.
Introduced async-selection defect: The new resolver skips commentary but does not receive or check delivery=async, whereas the existing selection path treats async messages as nonterminal.
Existing async contract: Current-main tests require async delivery not to become an answer candidate; they also cover a restricted async update that must not reach a user.
Findings 1 actionable finding [P1] Exclude async messages from delivered-answer selection
Security Needs attention Async update can bypass Activity presentation exclusion: The resolver may emit an answer-candidate event for async text even where existing code and tests require that update not to reach a user as a final answer.

How this fits together

The Codex app-server projector turns Codex item notifications into channel-delivered text and Control UI Activity events. The completion snapshot finalizes the selected Activity answer after the turn's notifications have been processed.

flowchart LR
A[Codex item notifications] --> B[Assistant projector]
B --> C[Delivered text selection]
B --> D[Activity answer selection]
C --> E[Channel delivery]
D --> F[Control UI Activity]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The supplied projector-level test output is useful supplemental evidence, but no after-fix Codex app-server-to-Control-UI trace or capture is provided; add redacted real proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve historical verification - A historical verification receipt failed or is malformed. A maintainer must resolve that verification blocker before merge; independently assessed contributor proof remains valid.
  • Exclude async messages from delivered-answer selection (P1) - The new lookup skips only commentary, so after an audible final followed by an async assistant message and a silent completion snapshot, it selects the async text. Delivery excludes async messages through the nonterminal predicate, and the existing async suite requires them not to produce answer candidates; pass that predicate or delivery state into this lookup and add the combined regression.
  • Resolve security concern: Async update can bypass Activity presentation exclusion - The resolver may emit an answer-candidate event for async text even where existing code and tests require that update not to reach a user as a final answer.
  • Resolve merge risk (P1) - A trailing silent snapshot after an async assistant update can select that async text in Activity even though delivery excludes it; restricted async content can thereby bypass its intended presentation boundary.
  • Resolve merge risk (P1) - The PR supplies projector-level test output only; it lacks after-fix Codex app-server and Control UI behavior proof.
  • Resolve merge risk (P1) - Production code grows by 64 net lines for a selector that currently diverges from its delivery owner.
  • Complete next step (P2) - A narrow mechanical repair is clear, though contributor real-behavior proof remains required after it.
  • Improve patch quality - Exclude async/nonterminal messages from the resolver and add the combined regression.
  • Improve patch quality - Add redacted after-fix app-server and Control UI Activity proof; updating the PR body should trigger re-review.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.

Findings

  • [P1] Exclude async messages from delivered-answer selection — extensions/codex/src/app-server/event-projector-assistant-delivered-answer.ts:23
  • [medium] Async update can bypass Activity presentation exclusion — extensions/codex/src/app-server/event-projector-assistant-delivered-answer.ts:23
Agent review details

Security

Needs attention: The async-selection divergence can expose a restricted async update in Activity.

PR surface

Source +64, Tests +51. Total +115 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 65 1 +64
Tests 1 51 0 +51
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 116 1 +115

Review metrics

Metric Value Why it matters
Production versus test LOC production +65/-1 (net +64), tests +51/-0 The new selector is substantial for a bug fix and should remain an exact shared-equivalence implementation after the async repair.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #112468
Summary: This PR remains a candidate repair for the Activity portion of the canonical silent-coda report; the merged related PR repaired delivery only.

Members:

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

Merge-risk options

Maintainer options:

  1. Align async exclusion before merge (recommended)
    Pass the delivery/nonterminal decision into the resolver, exclude async items, and cover an audible final followed by async output and a silent completion snapshot.

Technical review

Best possible solution:

Make Activity selection use the same nonterminal predicate as delivered-text selection, add the async-plus-silent regression, then provide a redacted real app-server-to-Activity proof.

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

Yes at source level: an audible final, then an async assistant message, then a trailing silent completion snapshot makes the new reverse scan select async text while the delivery collector excludes it. This review did not execute the contributor branch.

Is this the best way to solve the issue?

No. The intended Activity fix is sound, but its resolver must share delivery's exclusion of async/nonterminal items rather than only filtering commentary.

Full review comments:

  • [P1] Exclude async messages from delivered-answer selection — extensions/codex/src/app-server/event-projector-assistant-delivered-answer.ts:23
    The new lookup skips only commentary, so after an audible final followed by an async assistant message and a silent completion snapshot, it selects the async text. Delivery excludes async messages through the nonterminal predicate, and the existing async suite requires them not to produce answer candidates; pass that predicate or delivery state into this lookup and add the combined regression.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The introduced path can present a restricted async update as the selected Activity answer.
  • merge-risk: 🚨 security-boundary: Async messages intentionally excluded from user-facing answer selection can become an Activity event through the new resolver.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The supplied projector-level test output is useful supplemental evidence, but no after-fix Codex app-server-to-Control-UI trace or capture is provided; add redacted real proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review. A historical verification receipt failed or is malformed. A maintainer must resolve that verification blocker before merge; independently assessed contributor proof remains valid.

Evidence

Security concerns:

  • [medium] Async update can bypass Activity presentation exclusion — extensions/codex/src/app-server/event-projector-assistant-delivered-answer.ts:23
    The resolver may emit an answer-candidate event for async text even where existing code and tests require that update not to reach a user as a final answer.
    Confidence: 0.94

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/codex/src/app-server/event-projector.assistant.test.ts extensions/codex/src/app-server/event-projector.async-delivery.test.ts.
  • [P1] node scripts/check-changed.mjs -- extensions/codex/src/app-server/event-projector-assistant.ts extensions/codex/src/app-server/event-projector-assistant-delivered-answer.ts extensions/codex/src/app-server/event-projector.assistant.test.ts.

What I checked:

Likely related people:

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

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 (21 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-14T01:27:55.511Z sha 2c91cd93074c819016eeb73496e897394cc51bb9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-14T14:36:48.704Z sha 2c91cd93074c819016eeb73496e897394cc51bb9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T05:28:58.553Z sha 6ae9b003d12216c88d4ae7cd277ff65fb510258b :: needs real behavior proof before merge. :: [P1] Filter stale assistant snapshot items before delivery selection
  • reviewed 2026-08-15T17:27:32.047Z sha e6a36c0ee9b7994e55bc530ccea68baa8f977162 :: needs real behavior proof before merge. :: none
  • reviewed August 18, 2026, 11:43 PM ET / August 19, 2026, 03:43 UTC sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-19T03:43:57.141Z sha e6a36c0ee9b7994e55bc530ccea68baa8f977162 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-21T17:35:34.944Z sha dc75e21ea284c4cd2e441460223e4ff42f397dd2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-27T16:31:10.874Z sha 8ad74f3 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 2, 2026
@harjothkhara
harjothkhara force-pushed the fix/codex-projector-trailing-no-reply branch from f3970cf to 675666e Compare August 3, 2026 23:47
@harjothkhara

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The last review was against head f3970cf4; current head is 675666ed. Two things have changed since.

Direct Codex source inspection is now in the body. The review noted it could not fetch the sibling openai/codex checkout in a read-only environment, so the protocol contract was left unproven. Evidence now has a "Codex app-server contract, inspected directly at the pinned version" subsection citing openai/codex at tag rust-v0.146.0 (e363b08c9175), matching the @openai/codex 0.146.0 pin in extensions/codex/package.json:11. The chain it establishes: steering requires and reuses the active turn (v2/turn.rs:194-196, core/src/session/mod.rs:3937,3941,3948, returning that same id at :3999), the steered input is drained by the same turn loop before the next model request (mod.rs:3993-3997, core/src/session/turn.rs:246,255-257), and each response completes its own agentMessage item under the same turnId (turn.rs:1876, v2/item.rs:1310-1313) in an ordered Turn.items: Vec<ThreadItem> (v2/thread_data.rs:238-242).

That makes the answer-then-NO_REPLY pair the specified behavior for a steer landing after the answer, not a malformed state — so "newest completed assistant item is the deliverable answer" is an identity the contract never offered.

Real-behavior proof was already in the body at the reviewed head and remains: a separate app-server process over a real stdio pipe, four scenarios, with the DELIVERED to the channel: payload from buildEmbeddedRunPayloads() shown before and after. If that artifact still does not clear the proof ask, saying which part is short would help more than the generic line.

Still open, and deliberately so: the P2 timeout-recovery finding is answered by measurement rather than by code. The body's "timeout-recovery interaction, measured" section shows the gate is not reached — the 10s assistant-completion-idle watch fires before the 60s completion-idle watch, and the one sequence that does reach it is independently blocked by hasQuiescentCompletedAssistant requiring zero active items. It is stated there as a reachability result, not a proof of impossibility. If you would rather see the classified silent-token case in code than the argument, say so and I will add it.

@clawsweeper

clawsweeper Bot commented Aug 4, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@harjothkhara
harjothkhara force-pushed the fix/codex-projector-trailing-no-reply branch from 675666e to 99a8d38 Compare August 4, 2026 04:04
@harjothkhara

Copy link
Copy Markdown
Contributor Author

Pushed 99a8d38 — this revision goes well beyond the original one-line resolver fix, so a summary of what changed and why.

Three further defects, all found by review and all fixed with red-first regressions. The silent-token predicate was narrower than the one delivery actually applies, so a late event answered with {"action":"NO_REPLY"} was selected as the answer and then suppressed downstream — the same zero-output bug in a different encoding. Activity's "selected answer" was chosen independently of the delivered one, so it marked the silent token as selected while the real answer went out. And an answer superseded by later native tool work was being revived, which changed answer → tool → NO_REPLY from silent (current main) to delivering a stale pre-tool answer.

The P2 timeout-recovery finding is now fixed in code rather than argued around. hasCompletedTerminalAssistantText() treats a trailing silent token as the turn's own terminal output so recovery survives, while a newer empty completion still blocks it — the existing safeguard at run-attempt.turn-watches.test.ts:672 is unchanged and still green. A side effect worth noting: the harness's stalled-open-item scenario now reports the recovery gate as true, matching main, so the divergence the previous revision had to argue was unreachable no longer exists.

Direct sibling Codex inspection is in the body, cited at tag rust-v0.146.0 (e363b08c9175) to match the @openai/codex pin, covering the steer/turn/item contract the fix rests on.

Two follow-ups and two product questions are named rather than quietly skipped, per the one-sided-fix rule: raw-echo synthetic ids fall outside native-tool invalidation; two parallel invalidation computations should eventually be one; whether a wholly silent turn should ever show as Activity's selected answer; and whether the fallback should distinguish internal steers from user steers, given both share the steering queue. That last one changes user-visible behavior and I did not want to decide it for you.

Scope grew from +13 to roughly +90 production lines. That is a real increase and I would rather flag it than bury it — it buys four consumers of the same fact agreeing instead of one, but if you would prefer this split into a minimal delivery fix plus a separate consistency PR, say so and I will split it.

@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 Aug 6, 2026
@harjothkhara
harjothkhara force-pushed the fix/codex-projector-trailing-no-reply branch from 99a8d38 to 2c91cd9 Compare August 14, 2026 01:23
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 14, 2026
@harjothkhara
harjothkhara force-pushed the fix/codex-projector-trailing-no-reply branch from 2c91cd9 to 6ae9b00 Compare August 15, 2026 05:22
@harjothkhara
harjothkhara force-pushed the fix/codex-projector-trailing-no-reply branch from 6ae9b00 to e6a36c0 Compare August 15, 2026 17:21
@harjothkhara harjothkhara changed the title fix(codex): keep the real answer when a trailing NO_REPLY answers a late event fix(codex): show the delivered answer, not a trailing NO_REPLY, in Activity Aug 15, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. and removed P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 15, 2026
… in Activity

Narrowed from the original openclaw#116604 scope after openclaw#123993 landed the
delivery-side fix: collectAssistantTexts() now correctly ships the real
answer via the persistable-assistant barrier, so the delivered-text hunk
and its tests are dropped as redundant (credit: openclaw#123993).

What still breaks on main: turn/completed.items is a last-wins
last_agent_message summary (codex-rs thread_state.rs
track_current_turn_event overwrites it on every completed AgentMessage
final), so when a trailing NO_REPLY is the last agent message,
finalizeAnswerCandidate selects the silent item and Control UI Activity
shows "NO_REPLY" as the operator-visible selected answer while the
channel receives the real reply.

Fix: when the snapshot-authoritative item is a silent payload, re-derive
the selected item through resolveDeliveredAnswerItemId(), an item-id
mirror of collectAssistantTexts()'s precedence (audible post-barrier,
then any post-barrier persistable, then pre-barrier audible, then the
final text item), so Activity names the item delivery actually chose.

Two earlier candidate vectors were dropped after inspecting the pinned
codex-rs 0.147.0 source: turn.items can never carry more than one item
and never a tool item (bespoke_event_handling.rs:1276-1285 is the only
production constructor), so a cross-turn snapshot filter would be dead
code, and a silence-aware recovery gate would break legitimate
silent-turn recovery.

Regression test fails on unmodified main with the selected event naming
the silent item (progressText "NO_REPLY") and passes with the fix.
@harjothkhara
harjothkhara force-pushed the fix/codex-projector-trailing-no-reply branch from dc75e21 to 8ad74f3 Compare August 27, 2026 16:24
event-projector-assistant.ts crossed the 700-line cap once this fix's
lookup landed on top of main's growth. The lookup is self-contained --
it only reads assistant item order, phase, text, the persistable
barrier, and two projector predicates -- so it moves out cleanly behind
an explicit lookup type instead of trimming the fix.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 27, 2026
@harjothkhara

Copy link
Copy Markdown
Contributor Author

Re-checked this against current main after #123993 ("fix(codex): keep the real answer when a trailing coda follows") merged, since that PR references this one. It supersedes half of this PR, but not the half this PR is now scoped to. Vector-by-vector:

Case Handled on current main? Evidence
Delivered text — trailing NO_REPLY swallowing the real answer in the channel reply Yes — superseded by #123993 extensions/codex/src/app-server/event-projector-assistant.ts:313-331, collectAssistantTexts() filters isSilentReplyPayloadText over the post-barrier segment; covered by event-projector.assistant.test.ts:456, :502, :658
Activity “Selected answer” — turn/completed.items names the trailing silent item, so the operator sees NO_REPLY while the channel gets the real reply No — still reproduces event-projector-assistant.ts:384: const itemId = authoritative?.id ?? this.visibleAnswerCandidateItemId; then :392 emitAnswerCandidate(itemId, "selected"). finalizeAnswerCandidate (:355-393) has no silence awareness at all — isSilentReplyPayloadText appears only at :3, :317, :327, :588, every one inside the text path, never the candidate path

So the two fixes sit at different owner boundaries: #123993 repaired the text/delivery path; the answer_candidate selection path it never touched is what remains, and it is what this PR is scoped to.

Codex protocol check (per the repo's hard gate — inspected the pinned sibling source directly, not the PR text). Sibling checkout at tag rust-v0.147.0, matching the pin in extensions/codex/package.json:11:

  • codex-rs/app-server/src/bespoke_event_handling.rs:1276-1285 — emit_turn_completed_with_status builds (items, items_view) as Some(item) => (vec![item], TurnItemsView::Summary), so turn.items carries at most one last_agent_message.
  • codex-rs/app-server/src/thread_state.rs:158-170 — track_current_turn_event assigns turn_summary.last_agent_message on every ItemCompleted with phase ∈ {FinalAnswer, None} and non-blank text, last-wins and with no silence awareness. A trailing NO_REPLY is non-blank and final_answer, so it always overwrites the real answer in the summary.

That is exactly the premise this PR depends on, and it holds at the pinned version.

One forward-looking caveat worth flagging: at the sibling repo's HEAD (well ahead of the pin), bespoke_event_handling.rs:1249-1266 builds items: vec![] unconditionally and drops last_agent_message from TurnCompletionMetadata. If OpenClaw bumps @openai/codex past 0.147.0, turn.items goes empty and this vector may become moot. Worth knowing before investing further review here.

Existing coverage does not pin the residual gap: event-projector.assistant.test.ts contains no assertion that a selected answer_candidate names the audible item — the four silent tests assert assistantTexts/messagesSnapshot only, and answer_candidate appears just four times, all negative-style. This PR's test filters onAgentEvent for kind === "answer_candidate" + status === "selected" and asserts itemId: "answer-1"; on main that emits answer-2 (the NO_REPLY item) from line 384.

Not claiming credit for the delivery half — #123993 owns that, and I've narrowed this PR accordingly. Leaving it open for the Activity-selection defect unless a maintainer reads that as also-covered, in which case I'm happy to close it.

🤖 AI-assisted (Claude Code): analysis prepared with an AI agent; a human reviews and owns the result.

@fuller-stack-dev fuller-stack-dev self-assigned this Sep 17, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

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

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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

Development

Successfully merging this pull request may close these issues.

Codex app-server: trailing NO_REPLY to a late-injected completion event swallows the turn's already-emitted final answer (silent success)

2 participants