Skip to content

fix(codex): retain failed conversations for guarded continuation - #139246

Merged
obviyus merged 3 commits into
mainfrom
codex/repair-pr-138846
Sep 5, 2026
Merged

obviyus merged 3 commits into
mainfrom
codex/repair-pr-138846

Conversation

@obviyus

@obviyus obviyus commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

After a completed native failure, the next message could falsely report that the persistent thread was active elsewhere. A typed policy refusal also lost its classification.

Why This Change Was Made

Retain fully settled failed ordinary threads under the existing subscription, configuration, generation, and tool checks. Map the typed policy outcome to the existing refusal diagnostic, preserving no-retry/no-fallback behavior. Configuration changes still require confirmed native unloading.

User Impact

Users can continue the same failed conversation without losing its thread. Terminal refusals stop the current request; later input does not override policy. No public API or schema is added.

Evidence

Real Gateway/native-runtime checks reproduced a controlled HTTP 401 followed by false activity, then verified recovery on the same thread. Registered refusal scenarios delivered one refusal without retry, and an ordinary retryable error still retried. Focused retention, settlement, and cleanup tests passed. Synthetic protocol events tested delivery rather than real policy refusals.

Closes #138835. Supersedes #138846; the original contribution is retained. Thanks @Colton-Harris for the report and original repair. AI-assisted.

@clawsweeper

clawsweeper Bot commented Sep 5, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: L maintainer Maintainer-authored PR labels Sep 5, 2026
@obviyus obviyus self-assigned this Sep 5, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 1:58 PM ET / 17:58 UTC.

ClawSweeper review

What this changes

Preserves failed Codex conversations for guarded later messages and classifies misalignment refusals through the existing terminal-error path, with regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

This repair remains necessary on current main. The revised head resolves the previous settlement-integration concern, and no blocking patch defect was found.

Priority: P1
Reviewed head: dda04893deb433098864bc65a6fdf5208c0f4f3e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with credible native integration evidence, useful regression coverage, and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Captured exact-head evidence reports real Gateway/native Codex recovery after injected HTTP401 failures, same-thread authenticated resume, and rejected cross-conversation takeover; protocol fixtures separately cover refusal delivery without retry or fallback.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): Captured exact-head evidence reports real Gateway/native Codex recovery after injected HTTP401 failures, same-thread authenticated resume, and rejected cross-conversation takeover; protocol fixtures separately cover refusal delivery without retry or fallback.
Evidence reviewed 13 items Current main still contains the defect: Fetched main retains the idle/notLoaded-only adoption checks. Its cleanup still retains ordinary threads only after success, and its refusal classifier lacks misalignmentPolicyViolation.
Settled failure excludes interrupted outcomes: Finalization records failed settlement only after native failure completion and excludes cancellation, timeout, client closure, and execution disconnect.
Existing retention owner is reused: Cleanup retains the existing configuration receipt under the binding lease and physical-client identity check. Incognito failure, one-shot cleanup, supervision, native-model preservation, and ring-zero exclusions remain.
Findings None None.
Security None None.

How this fits together

The Codex plugin connects OpenClaw chat turns to native Codex conversations. Its lifecycle owner retains reusable threads, validates later requests, and returns terminal outcomes for chat delivery.

flowchart TD
  A[Chat message] --> B[Codex conversation owner]
  B --> C[Ownership and configuration checks]
  C --> D[Native Codex turn]
  D --> E[Terminal outcome]
  E --> F[Visible reply or refusal]
  E --> G[Retain safely settled thread]
  G --> C
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +21, Tests +118, Docs +13. Total +152 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 38 17 +21
Tests 5 308 190 +118
Docs 1 13 0 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 359 207 +152

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +21 lines; tests/support +118; docs +13 Production growth extends existing settlement and refusal contracts without adding a configuration option, public error API, or parallel lifecycle.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #138835
Summary: This PR is the replacement implementation candidate for the open failed-conversation report.

Members:

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

Technical review

Best possible solution:

Retain settled failures through the existing subscription owner while preserving configuration attestation and terminal refusals; distinguishing safe failure from success and interrupted teardown justifies the small state expansion.

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

Yes—the native HTTP401 → completed failure → later message sequence is supported by current-main source and supplied before/after results; this review did not execute it.

Is this the best way to solve the issue?

Yes. Repairing retention at its lifecycle owner avoids unnecessary reconfiguration, while extending the existing refusal diagnostic avoids a competing core error contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The linked report establishes blocked Codex conversations after completed failures and lost terminal-refusal classification.
  • 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): Captured exact-head evidence reports real Gateway/native Codex recovery after injected HTTP401 failures, same-thread authenticated resume, and rejected cross-conversation takeover; protocol fixtures separately cover refusal delivery without retry or fallback.
  • proof: sufficient: Contributor real behavior proof is sufficient. Captured exact-head evidence reports real Gateway/native Codex recovery after injected HTTP401 failures, same-thread authenticated resume, and rejected cross-conversation takeover; protocol fixtures separately cover refusal delivery without retry or fallback.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • lei_lei: 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 (1 earlier review cycle)
  • reviewed 2026-09-05T17:37:56.754Z sha 937c2b7 :: blocked before merge. :: none

@obviyus
obviyus marked this pull request as ready for review September 5, 2026 17:50
@obviyus

obviyus commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

Ready to land at dda04893deb433098864bc65a6fdf5208c0f4f3e.

  • Root cause: completed native failures lost the retained configuration owner, and typed misalignment errors missed the existing refusal diagnostic.
  • Fix: retain settled failed ordinary conversations through the existing owner; reuse the established refusal delivery and no-replay path. No new SDK error, configuration option, schema or protocol change.
  • Independent native/Gateway proof: baseline HTTP401 → systemError → false runner rejection; repaired ordinary and authenticated manual continuation completes on the same thread. Cross-conversation takeover is rejected for active and stopped threads. Terminal requests do not replay; ordinary retry succeeds.
  • CI: run 33982203491 passed on this exact head. Local exact-head review has no findings or security concerns and accepts the product proof. The latest public review has no blockers or rank-up actions.

Validation commands:

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/codex/src/app-server/run-attempt-thread-cleanup.test.ts extensions/codex/src/app-server/event-projector.terminal-errors.test.ts extensions/codex/src/app-server/run-attempt.settlement.test.ts
OPENCLAW_E2E_USE_PREBUILT_DIST=1 OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/gateway-codex-refusal-product-proof.e2e.test.ts
GOMEMLIMIT=4GiB GOMAXPROCS=1 node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/codex/src/app-server/run-attempt-finalize.ts
OPENCLAW_BUILD_PRIVATE_QA=1 OPENCLAW_BUNDLED_PLUGIN_BUILD_IDS=codex,openai,qa-lab,qa-channel NODE_OPTIONS=--max-old-space-size=6144 node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime

Results: 54 affected focused tests, four Gateway scenarios, lint and build pass. Formatting and contribution ratchets pass. Production +21 lines; tests/support +118; docs +13.

The independent runtime pass did not fault-inject every hidden lifecycle/configuration or direct-input/confirmation guard; those remain covered by source and focused regression evidence. First-time adoption or changed generic configuration of a loaded failed thread still requires native unloading. No real policy refusal was requested or overridden.

@obviyus
obviyus merged commit 64c543a into main Sep 5, 2026
210 of 211 checks passed
@obviyus
obviyus deleted the codex/repair-pr-138846 branch September 5, 2026 18:17
@obviyus

obviyus commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @Colton-Harris! Landed in 64c543a78b7fe2497bb40e5b73c47483e900ff06, with your contributor credit retained.

Proof: Real Gateway and pinned native Codex HTTP401 recovery, independent ordinary/manual continuation and ownership rejection, plus harmless terminal/retry protocol controls. Exact-head CI, 54 affected focused tests, four Gateway scenarios and both reviews passed for dda04893deb433098864bc65a6fdf5208c0f4f3e.

Before After
A completed native failure could block the next message as another active runner. The same configured conversation continues on its original native thread.
Misalignment lost its refusal classification. One visible refusal stops recovery and model fallback; normal retryable errors still recover.

The existing configuration, ownership and native confirmation guards remain. No public SDK error, schema or configuration option was added. Issue #138835 is closed; the original #138846 is superseded by this verified replacement.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* commit '911d7d5b0c107f7274f2415ca9655dcc6105f0e8': (867 commits)
  fix(skills): deliver pending Workshop approval controls (#139248)
  fix(gateway): deliver loopback ask_user prompts to the originating channel (#138831)
  docs: keep root agent instructions focused on repository policy (#139258)
  fix(matrix): exclude archived state roots from scans and selection (#112329)
  perf(agents): prepare exact tool names once per catalog batch (#139267)
  fix: preserve Swarm progress and simplify owner plumbing (#139269)
  fix(tailscale): release claims after gateway process-group exit (#139261)
  refactor(cli): simplify lazy command registration (#139108)
  test(ui): retain synthetic widget failure evidence (#139229)
  fix(buzz): keep implicit replies at thread root (#138879)
  test(diagnostics): await graceful Gateway shutdown before cleanup (#139247)
  fix(ci): unblock releases with different tooling package managers (#139259)
  feat(ui): add social preview links for private sessions (#139250)
  fix(codex): retain failed conversations for guarded continuation (#139246)
  chore(ui): refresh control ui locales (#139200)
  fix(ci): run browser checks for real-gateway inputs (#139256)
  fix(llama-cpp): reconcile managed router state before requests (#136363)
  chore(i18n): refresh native locales (#139237)
  refactor(worker): unify inference payload handling (#139245)
  refactor(terminal): replay wrapped prefixes in one pass (#139240)
  ...
steipete added a commit that referenced this pull request Sep 5, 2026
Require a named reasoning parameter before retrying with a different thinking level, preserving model/account failures and configured fallback decisions. Consolidate supported-value parsing. Related: #139246.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…nclaw#139246)

Retain fully settled failed native conversations through the existing configuration owner so later user turns can continue on the same thread. Preserve typed misalignment decisions through the established refusal diagnostic, without recovery or model fallback replay.

Keep active-owner, generation, configuration, catalog, unload and direct-input boundaries intact. No new public SDK error, schema, protocol or configuration option.

Verified with real Gateway/pinned-native HTTP401 recovery, independent ordinary/manual continuation and cross-conversation rejection, terminal/retry protocol controls, 54 affected focused tests and four Gateway scenarios.

Fixes openclaw#138835. Supersedes openclaw#138846. Thanks @Colton-Harris for the report and original repair. AI-assisted.

Co-authored-by: Colton Harris <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…#139295)

Require a named reasoning parameter before retrying with a different thinking level, preserving model/account failures and configured fallback decisions. Consolidate supported-value parsing. Related: openclaw#139246.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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]: completed Codex failures are reported as active in another runner

2 participants