Skip to content

fix(codex): report safe history rejection reasons - #139933

Merged
obviyus merged 2 commits into
openclaw:mainfrom
be-student:codex/139838-preserve-history-errors
Sep 6, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
be-student:codex/139838-preserve-history-errors

Conversation

@be-student

@be-student be-student commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #139838.

What Problem This Solves

Fixes an issue where operators could not see why Codex final-answer recovery rejected history. Known rejection reasons disappeared into a generic “context unavailable” diagnostic.

Why This Change Was Made

The history owner now carries a typed, allowlisted reason through the worker and capture boundary. Unknown failures produce a generic safe code. This changes diagnostic reporting only; it does not explain why the original model omitted its final answer.

User Impact

Operators can distinguish size, image, pairing, provenance, and access rejections without exposing transcript content or exception text. Missing files and foreign or absent headers still yield empty history. Cancellation and snapshot invalidation keep their precedence, and completed actions are never replayed.

Evidence

  • Native reproduction on main at 4a42c4ea5dfe337ee8def9056e23b30255a615f7: an oversized history field produced only context_unavailable. The repaired flow reports field_limit, rejects the same history, and delivers one fallback after one completed action.
  • Nine native candidate flows cover valid recovery, rejection, cancellation, and snapshot changes. Independent acceptance passes all 14 original behavior clauses.
  • Real reader controls preserve missing/foreign/malformed-header behavior and access denial. Baseline and candidate accept exactly 200 projected items or 512 KiB, then reject one-over inputs. A real filesystem exception containing a synthetic private marker reaches diagnostics only as history_read_failed.
  • 81 focused tests pass; the 59 history/capture tests also pass through the normal compiled-subprocess runner.
  • Changed-source formatting, type-aware lint, production/test typechecks, SDK boundary checks, export scans, and source guards pass. The normal CI runtime/UI/asset build passes on ff3d1cd5e6ace1b3a6eba4cb36d6d6f7580701b1 (staging run).
  • The broader staging run also reports locale-artifact drift and package-tool/model-discovery timeouts. Those results are retained for investigation; exact-head PR CI remains required before merge.

Sanitized excerpt from the native field-rejection run; the logging envelope and storage/run identifiers are omitted:

{"1":{"reason":"field_limit"},"message":"codex settled-turn finalization context capture failed"}

The terminal reply remained: “The tool run finished, but no final summary was produced. I did not repeat any completed actions.” The action marker and native command events both recorded one completed action.

Preserves @be-student's contribution in this existing PR.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 9:40 AM ET / 13:40 UTC.

ClawSweeper review

What this changes

The Codex plugin carries safe history-rejection codes through its reader and worker into operator warnings, with regression coverage and documentation.

Merge readiness

⛔ Blocked before merge - 3 items remain

The diagnostic defect remains on main, and the updated native evidence resolves the previous proof blocker. No introduced correctness defect was found; acceptance of the new public SDK export remains a maintainer decision.

Priority: P2
Reviewed head: ff3d1cd5e6ace1b3a6eba4cb36d6d6f7580701b1
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent repair with relevant native proof and regression coverage; the remaining concern is the public SDK compatibility contract.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The supplied native oversized-field run exercises transcript projection through worker and capture, records the real field_limit warning, and observes one fallback after one completed action; this satisfies the prior runtime-output request.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The supplied native oversized-field run exercises transcript projection through worker and capture, records the real field_limit warning, and observes one fallback after one completed action; this satisfies the prior runtime-output request.
Evidence reviewed 11 items Current main still loses rejection reasons: At fetched main, readCodexNativeHistory catches projection errors and returns undefined. The relevant reader and capture files are unchanged between the pinned merge base and fetched main.
Released behavior also lacks safe rejection propagation: The v2026.9.2 capture implementation returns undefined when its worker supplies no data; its catch cannot recover an error already swallowed by the reader.
Safe rejection ownership: The reader converts consumer failures into typed rejected outcomes, keeps missing-file handling outside that consumer catch, and maps unknown exceptions to history_read_failed. Capture logs only the reason and returns no finalization context.
Findings None None.
Security None None.

How this fits together

After Codex completes tools without a final answer, OpenClaw reads and verifies the session transcript for a restricted summarization turn. Rejected history prevents that recovery and produces an operator diagnostic while preserving the existing fallback.

flowchart TD
  A[Completed tools without final answer] --> B[Read session transcript]
  B --> C[Verify history and projection limits]
  C --> D[Recheck snapshot and cancellation]
  D --> E{History accepted?}
  E -->|Yes| F[Restricted final answer]
  E -->|No| G[Safe diagnostic and existing fallback]
Loading

Decision needed

Question Recommendation
Should SessionTranscriptReadFenceError become a supported export of the Codex transcript SDK, with a host-version floor that includes it? Accept the narrow error export: Document the existing error class as supported and retain the coordinated release API floor for the plugin.

Why: The additive export is a narrow diagnostic solution, but accepting a permanent plugin API contract belongs to its owners.

Before merge

  • Resolve merge risk (P1) - The plugin now statically requires a newly exported SDK error class. Publishing it independently with an older compatible-host floor could prevent loading on those hosts; coordinated release synchronization covers the normal release path.
  • Complete next step (P2) - Confirm and document the SDK error export's supported contract and matching host/plugin release requirement.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +75, Tests +144, Docs +2. Total +221 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 9 169 94 +75
Tests 3 198 54 +144
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 369 148 +221

Review metrics

Metric Value Why it matters
SDK contract 1 error-class export added; existing signatures unchanged The new static plugin import introduces a host API requirement despite leaving existing callers source-compatible.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139838
Summary: This PR is the explicit candidate repair for the open diagnostic-loss issue.

Members:

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

Merge-risk options

Maintainer options:

  1. Accept and document the narrow SDK contract (recommended)
    Approve the error export and ensure any standalone plugin release requires a host that supplies it.
  2. Keep rejection classification host-owned
    Adjust the existing transcript seam if maintainers do not want the error class to become public API.

Technical review

Best possible solution:

Keep the typed diagnostic flow and existing rejection rules, with a documented SDK error contract and matching host/plugin release compatibility.

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

Yes: an oversized historical field throws during projection, and current main converts that failure to undefined before capture can report it. Source inspection confirms the path; the PR also supplies native before/after observations.

Is this the best way to solve the issue?

Yes: carrying owner-typed rejection outcomes across the worker is a focused repair that avoids parsing exception text or weakening rejection checks; the SDK export needs explicit contract acceptance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 21294bfa428b.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The new public SDK export requires a matching host API floor for separately installed plugin packages.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied native oversized-field run exercises transcript projection through worker and capture, records the real field_limit warning, and observes one fallback after one completed action; this satisfies the prior runtime-output request.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The supplied native oversized-field run exercises transcript projection through worker and capture, records the real field_limit warning, and observes one fallback after one completed action; this satisfies the prior runtime-output request.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs operator diagnostics for rejected final-answer recovery without changing the underlying recovery limits.
  • merge-risk: 🚨 compatibility: The new public SDK export requires a matching host API floor for separately installed plugin packages.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The supplied native oversized-field run exercises transcript projection through worker and capture, records the real field_limit warning, and observes one fallback after one completed action; this satisfies the prior runtime-output request.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied native oversized-field run exercises transcript projection through worker and capture, records the real field_limit warning, and observes one fallback after one completed action; this satisfies the prior runtime-output request.

Evidence

What I checked:

  • Current main still loses rejection reasons: At fetched main, readCodexNativeHistory catches projection errors and returns undefined. The relevant reader and capture files are unchanged between the pinned merge base and fetched main. (extensions/codex/src/app-server/session-history-read.ts:86, 21294bfa428b)
  • Released behavior also lacks safe rejection propagation: The v2026.9.2 capture implementation returns undefined when its worker supplies no data; its catch cannot recover an error already swallowed by the reader. (extensions/codex/src/app-server/settled-turn-context.ts:54, 3928bad9badf)
  • Safe rejection ownership: The reader converts consumer failures into typed rejected outcomes, keeps missing-file handling outside that consumer catch, and maps unknown exceptions to history_read_failed. Capture logs only the reason and returns no finalization context. (extensions/codex/src/app-server/session-history-read.ts:69, ff3d1cd5e6ac)
  • Cancellation and snapshot checks remain authoritative: Worker results still undergo cancellation and transcript-admission or snapshot validation before use. Capture rechecks cancellation and active ownership after awaiting the worker; rejection never creates an accepted context. (extensions/codex/session-history-worker-runtime.ts:58, ff3d1cd5e6ac)
  • Updated real runtime proof: The supplied PR body, captured under context sourceRevision be5c19ec98489847597f0e69cdfef28420a2c38788ad937c6b13be37434ea0f6, records a native oversized-field run producing the actual capture warning with reason field_limit, one terminal fallback, and one completed action. This directly addresses the previous request for runtime rejection output. The additional nine-flow and test results are reported evidence, not reviewer-executed checks. (ff3d1cd5e6ac)
  • Focused regression coverage: Tests exercise persistent and incognito SQLite rejection diagnostics, snapshot mutation precedence, cancellation and owner closure, malformed headers, foreign admissions, and consumer exceptions impersonating ENOENT. Projection limits and pairing requirements remain intact. (extensions/codex/src/app-server/session-history.test.ts:186, ff3d1cd5e6ac)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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.

  • Document the accepted SDK error export and confirm the standalone plugin's host API floor includes it.

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 (1 earlier review cycle)
  • reviewed 2026-09-06T08:25:57.153Z sha 48dfd29 :: needs real behavior proof before merge. :: none

@obviyus obviyus self-assigned this Sep 6, 2026
Carry owner-typed rejection reasons through the reader, worker, and capture boundary. Preserve empty-history behavior, cancellation and snapshot precedence, and no replay of completed actions.

Refs #139838.
@obviyus obviyus changed the title fix(codex): preserve history projection failures fix(codex): report safe history rejection reasons Sep 6, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed 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. labels Sep 6, 2026
@obviyus

obviyus commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

landpr-approve-unrelated-red
pr: 139933
head: ff3d1cd
run: 34036480186 attempt: 1
failed: checks-node-compact-small-43 job=101495479585 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit 13cb0ba into openclaw:main Sep 6, 2026
216 of 220 checks passed
@obviyus

obviyus commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks @be-student!

Proof: Native Gateway recovery now reports field_limit for the same oversized history that previously lost its diagnostic. It still rejects that history, delivers one fallback, and repeats no completed action. Valid history still produces a final summary. All 14 behavior clauses pass; 81 focused tests, normal compiled history/capture tests, type-aware lint, typechecks, source guards, and the normal CI build pass. Fresh exact-head review found no findings.

  • Bug: Rejected history lost its safe reason before the operator warning.
  • Fix: The history owner carries a typed, allowlisted reason through the reader, worker, and capture boundary.
Before After
Oversized history became generic unavailable context. The operator warning reports field_limit; rejection and no-replay behavior stay intact.

The merge used an unrelated-failure exception based on source separation. A subsequent audit found that cause attribution was not established: timeout responsibility remains unknown, and no matching main failure was proved. This was an exception-policy failure, not evidence of a product regression or retrospective approval.

The affected run is CI run 34036480186, job 101495479585: test/openai-model-discovery-auth-order.test.ts → uses subscription discovery for configured literal oauth credentials without a profile timed out after 120 seconds. The aggregate failed because of this single child. The same case also timed out in staging job 101492645798.

This catalog-only fixture does not run history recovery. Its source and catalog/authentication inputs are unchanged from tested main parent 48307ec958b04d3356aece1dc8d3ff120168dc1e to CI merge 5ff8aac1b3774b3200d657545bf1200c2cbcc555. No matching main failure was found in the current comparison window. The precise timing cause and introducing commit remain unassigned; no unrelated test or timeout was changed to land this repair.

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

Labels

extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex settled-turn recovery swallows history projection errors as context_unavailable

2 participants