Skip to content

feat(codex): record why settled-turn finalization context is unavailable - #124454

Closed
karmafeast wants to merge 1 commit into
openclaw:mainfrom
karmaterminal:codeagent/ward-1256-m2-context-reason
Closed

karmafeast wants to merge 1 commit into
openclaw:mainfrom
karmaterminal:codeagent/ward-1256-m2-context-reason

Conversation

@karmafeast

@karmafeast karmafeast commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: karmaterminal#1256
Coordinates with #124176 (does not absorb its sessions_yield skip).

What Problem This Solves

Fixes an issue where operators would see an undifferentiated
codex settled-turn finalization context is unavailable warning when a Codex
turn had a tool result and no assistant text. The specific attestation failure
was erased, so the same warning covered missing history, duplicate identities,
boundary-order drift, and capture errors.

This is instrumentation only. It does not repair zero-payload delivery.

Why This Change Was Made

The capture owner now returns a private closed-reason result instead of
collapsing every rejection to undefined. Valid frozen transcript context is
unchanged. Invalid branches stay fail-closed: no synthesized history and no
Codex turn/completed summary substitute.

The existing warning may add only the reason plus existing thread/turn/run
identities. Yield-specific capture skipping remains #124176's job.

User Impact

When settled-turn context capture fails, the existing warning now includes a
closed reason code. Successful turns are unchanged. No Plugin SDK, queue, or
delivery behavior change.

Evidence

Base: acbbff19bad0a5539cd4725e6a6c8ae8e53f6694. Head: d74c71c0a3e585f5411c6ea1fac236ee30445299.

  • Fossil table in extensions/codex/src/app-server/settled-turn-context.test.ts
    requires one exact reason per rejection branch.
  • Causal closure: unpatched prod is semantically RED (undefined); patch GREEN
    (21/21); patch-only revert RED; reapply GREEN.
  • Valid context remains JSON-byte-equivalent and frozen.
  • Warning receipt keys are only reason, threadId, turnId, optional runId.
  • Owner/sibling tests passed. Autoreview on HEAD: clean. Independent Grok
    review: no significant issues.
  • Codex 0.147.0 (rust-v0.147.0 / 3ed6f04f6bf8b7c46299d1cb1ff99c74ce21a51d):
    turn/completed is last-agent-message summary only; OpenClaw still owns
    mirror attestation.
  • Copied-store replay is required before any C2 behavioral repair; not claimed
    here. No live fleet DB access.

Production LOC: +83/-22 (net +61) | Tests: +155/-69.

Return a private closed-reason capture result instead of collapsing
every attestation failure to undefined. Valid context stays
byte-equivalent; invalid branches stay fail-closed.

Refs #1256

Co-authored-by: Copilot <[email protected]>
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@karmafeast
karmafeast marked this pull request as ready for review August 16, 2026 06:35
@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 20, 2026, 2:53 AM ET / 06:53 UTC.

ClawSweeper review

What this changes

The PR changes Codex settled-turn context capture to return closed rejection codes and logs the code with existing turn identifiers when finalization context is unavailable.

Merge readiness

⛔ Blocked until real behavior proof is added - 8 items remain

Keep open: the proposed diagnostic still collapses genuine session-history failures and several host-prompt attestation failures into broad codes, so it does not yet preserve the promised cause. It also needs an after-fix warning from the unavailable-context path before merge.

Priority: P3
Reviewed head: d74c71c0a3e585f5411c6ea1fac236ee30445299

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch has a coherent diagnostic direction but misses two claimed attribution boundaries and lacks real after-fix warning proof.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body describes tests and causal checks but does not show a redacted after-fix unavailable-context warning carrying one of the new reason codes; add that real output and redact private identifiers. 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 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body describes tests and causal checks but does not show a redacted after-fix unavailable-context warning carrying one of the new reason codes; add that real output and redact private identifiers. 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.
Evidence reviewed 5 items Current-main behavior: Current main still returns undefined for every rejected capture and logs the unavailable-context warning with only threadId and turnId, so this PR's central diagnostic behavior is not already implemented.
Session-history contract: The session-history owner reserves undefined for genuine read, parse, and malformed-header failures, while [] means an empty or non-Codex history. The patch maps undefined to missing-history, losing that distinction.
Host-prompt collapse: Failed host-prompt adoption returns the unmodified inputs; the subsequent attestation therefore emits mirror-boundary-order. The changed table explicitly expects that same code for six distinct adoption failures.
Findings 2 actionable findings [P2] Classify session-history failure separately
[P2] Preserve rejected host-prompt adoption reasons
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

runner@runnervmzvulz:/tmp/clawsweeper-live-proof-124454-IfaAIv/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.88 kB
[log]
[success] rolldown v1.2.0 Finished in 33.86 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.6s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 10.7s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 3628ms (slowest: built plugin control-plane loads 2675ms)

OpenClaw 2026.8.1 (d74c71c) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|warn|info|debug|trace)
  --no-color           Disable ANSI
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

The Codex app-server extension mirrors turn events into OpenClaw transcript state before an embedded attempt can finalize a tool-only turn. The finalizer accepts only an attested frozen transcript; otherwise it emits an operator warning and leaves the attempt fail-closed.

flowchart LR
A[Codex app-server turn] --> B[Attempt finalizer]
B --> C{Context capture needed}
C -->|yes| D[Transcript attestation]
D -->|valid| E[Frozen finalization context]
D -->|rejected| F[Unavailable-context warning]
C -->|no| G[Normal attempt completion]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body describes tests and causal checks but does not show a redacted after-fix unavailable-context warning carrying one of the new reason codes; add that real output and redact private identifiers. 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.
  • Classify session-history failure separately (P2) - readCodexMirroredSessionHistoryMessages reserves undefined for genuine read, parse, and malformed-header failures, but this maps all of them to missing-history. Return a distinct closed reason from that owner so the warning does not erase the actual failure.
  • Preserve rejected host-prompt adoption reasons (P2) - A failed host-prompt adoption returns the original inputs, which later collapse into mirror-boundary-order; the changed test intentionally assigns that one code to six distinct key, content, identity, and attestation failures. Carry the adoption rejection through the closed result instead.
  • Resolve merge risk (P1) - Merging now would report genuine transcript read or parse failures as missing-history, weakening the new operator diagnosis.
  • Resolve merge risk (P1) - Distinct rejected host-prompt adoption states still become mirror-boundary-order, leaving the central diagnostic gap unresolved.
  • Resolve merge risk (P1) - The PR has no after-fix warning output from the unavailable-context path, and its Codex app-server ordering claim could not be independently checked against the required sibling source.
  • Resolve merge risk (P1) - Production grows by net 61 lines for diagnostic-only behavior; the added closed-result model may be warranted, but it should be consolidated while completing attribution.
  • Complete next step (P2) - The contributor must correct two source-proven attribution gaps and supply real after-fix warning evidence before a merge decision.

Findings

  • [P2] Classify session-history failure separately — extensions/codex/src/app-server/settled-turn-context.ts:238-240
  • [P2] Preserve rejected host-prompt adoption reasons — extensions/codex/src/app-server/settled-turn-context.ts:147
Agent review details

Security

None.

PR surface

Source +61, Tests +86. Total +147 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 83 22 +61
Tests 1 155 69 +86
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 238 91 +147

Review metrics

Metric Value Why it matters
Production versus test LOC production +61, tests +86 The diagnostic capability adds meaningful production surface, so its closed-result model should cover every claimed rejection boundary.

Stored data model

Persistent data-model change detected: serialized state: extensions/codex/src/app-server/settled-turn-context.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete rejection attribution before merge (recommended)
    Carry distinct session-history and host-prompt adoption reasons to the warning, add focused regression coverage, and provide redacted after-fix warning output.
  2. Pause this diagnostic change
    Do not merge a partial diagnostic taxonomy if maintainers do not want the additional reason surface maintained.

Technical review

Best possible solution:

Return closed failure information from both the session-history reader and host-prompt adoption path, preserve the existing fail-closed finalizer behavior, then attach redacted output of an actual unavailable-context warning containing the resulting reason.

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

Yes, from source: make the session-history reader return undefined or reject host-prompt adoption, then the changed capture path emits the broad codes identified above. No real unavailable-context warning was supplied.

Is this the best way to solve the issue?

No: the closed result is the right owner boundary, but it must include rejection information from session-history and host-prompt adoption rather than reclassifying both downstream.

Full review comments:

  • [P2] Classify session-history failure separately — extensions/codex/src/app-server/settled-turn-context.ts:238-240
    readCodexMirroredSessionHistoryMessages reserves undefined for genuine read, parse, and malformed-header failures, but this maps all of them to missing-history. Return a distinct closed reason from that owner so the warning does not erase the actual failure.
    Confidence: 0.98
  • [P2] Preserve rejected host-prompt adoption reasons — extensions/codex/src/app-server/settled-turn-context.ts:147
    A failed host-prompt adoption returns the original inputs, which later collapse into mirror-boundary-order; the changed test intentionally assigns that one code to six distinct key, content, identity, and attestation failures. Carry the adoption rejection through the closed result instead.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P3: This is low-blast-radius diagnostic instrumentation rather than a delivery or execution repair.
  • merge-risk: 🚨 other: The new warning can misclassify real transcript and host-prompt failures, creating misleading operator diagnostics despite preserving fail-closed execution.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body describes tests and causal checks but does not show a redacted after-fix unavailable-context warning carrying one of the new reason codes; add that real output and redact private identifiers. 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.

Evidence

What I checked:

Likely related people:

  • frond-scribe: Authored the current PR-head commit that introduces the closed capture-result and warning receipt path. (role: proposed diagnostic implementation author; confidence: high; commits: d74c71c0a3e5; files: extensions/codex/src/app-server/settled-turn-context.ts, extensions/codex/src/app-server/run-attempt-finalize.ts)
  • Peter Steinberger: Current-main blame attributes the reviewed app-server lines to a recent main commit, though the partial local history makes deeper feature provenance ambiguous. (role: recent current-main contributor; confidence: low; commits: 13fd88828162; files: extensions/codex/src/app-server/settled-turn-context.ts, extensions/codex/src/app-server/run-attempt-finalize.ts)

Rank-up moves

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

  • Return distinct closed reasons for session-history failures and rejected host-prompt adoption.
  • Add redacted terminal or log output showing an unavailable-context warning with a new reason code.

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-08-16T06:45:37.192Z sha d74c71c :: needs real behavior proof before merge. :: [P2] Preserve host-prompt adoption failure reasons
  • reviewed 2026-08-16T07:21:13.105Z sha d74c71c :: needs real behavior proof before merge. :: [P2] Distinguish session-history failures from absent history | [P2] Preserve host-prompt adoption failure reasons

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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 16, 2026
@karmafeast

Copy link
Copy Markdown
Contributor Author

withdrawn. diagnostics scatter and no real fix. #121204 will see refinement from causal graph back walk. current sickness seems to surround amplification of stale messages in multi-openclaw open-listen / 'always' activation, where we see stale message accumulation, reply to them as if new, and in a fashion that implies return of cached infer (almost identical text), pressure on sqlite, symptomatically. #124337 remains active and needs proof generation.

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

Labels

extensions: codex merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M 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.

2 participants