Skip to content

fix(errors): preserve diagnostics and successful tool results - #140362

Merged
steipete merged 3 commits into
mainfrom
codex/error-formatting-realms-disposal
Sep 6, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/error-formatting-realms-disposal

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

VM-created errors could lose their messages and causes, async disposal could hide both failures, and throwing diagnostic getters could interrupt error reporting. In the Codex tool bridge, an observer’s unreadable error could also escape logging after a tool succeeded, discard the response, and notify the observer again.

Recognize cross-realm errors and suppressed disposal failures in the shared formatter, retaining its existing graph traversal, deduplication and caller-owned redaction. Route the two Codex observer diagnostics through the existing safe formatter so successful results and execution evidence survive reporting failure. Native response fields, retry and authority rules stay unchanged. Restart and Codex consumer tests distinguish safe getter handling from actual reporting failures and verify exact observer, completion and protocol facts.

Validation: all 12 formatter regressions failed before repair, then 81 formatter/adapter tests passed. The restart follow-up passed 91 tests; the Codex follow-up passed 243 tests. Independent P0–P2 reviews, changed-code gates, typed lint and the existing line-limit ratchet passed. CI exposed the obsolete consumer expectations; those are repaired without weakening cleanup or failure assertions.

Four direct Node 24.19 VM/native-disposal scenarios passed with the fix. A separate plain Node source probe drove the actual bridge and watchdog with an exclusive temporary-file write: all four current ordinary/hostile-observer cases kept one write, one notification and the successful response. The baseline direct bridge wrote once but notified twice and rejected; the baseline combined watchdog remained a passing sibling control. Processes exited naturally with no unhandled rejection, and loaded source hashes differed only in the two baseline producer substitutions. This is source-level tool-host proof, without a native Codex app-server or external provider/authentication run. The unchanged wire contract was checked in the pinned official Codex response schema and dynamic tool handler.

Extracted from #135599. Production +43 lines for the demonstrated error-formatting contracts; the two observer repairs are net zero. Tests +224. No plugin lifecycle implementation dependency, new public API, configuration or storage schema.

@steipete steipete self-assigned this Sep 6, 2026
@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.

@steipete
steipete marked this pull request as ready for review September 6, 2026 18:21
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 3:31 PM ET / 19:31 UTC.

ClawSweeper review

What this changes

Preserves cross-realm and disposal error details, prevents unreadable observer errors from discarding successful Codex tool results, and strengthens consumer regression coverage.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, focused repair absent from the reviewed main revision. No blocking correctness finding remains, and the maintainer-owned PR is not a cleanup candidate.

Priority: P2
Reviewed head: eab3e1c98b6fc394ef70df6eaf44e7f7ce4e8312

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful regression coverage, documented boundary observations, and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-author exemption applies, and this patch does not materially change authority. The body records Node VM/disposal runs and actual bridge/watchdog filesystem probes preserving one write, one notification, and success; native app-server execution is explicitly unclaimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-author exemption applies, and this patch does not materially change authority. The body records Node VM/disposal runs and actual bridge/watchdog filesystem probes preserving one write, one notification, and success; native app-server execution is explicitly unclaimed.
Evidence reviewed 10 items Introduced scope and review continuity: The complete host-pinned introduction delta contains the formatter repair, two observer diagnostics, and associated tests. Comparing the previously reviewed head identifies only the four Codex follow-up files; the previous review retained no findings.
Shared formatter preserves diagnostics: Safe message/name reads and cross-realm recognition retain diagnostic graph traversal, deduplication, structured codes, and the final caller-owned redactor; suppressed disposal failures enter the same graph.
Observer repair uses the existing safe boundary: The bridge notifies its observer after execution; the changed catch uses formatToolExecutionErrorMessage, whose existing implementation catches formatting failures and preserves redaction. The watchdog uses the same helper. Execution and replay decisions are unchanged.
Findings None None.
Security None None.

How this fits together

OpenClaw’s shared error formatter turns thrown values into caller-redacted diagnostics. The Codex tool bridge executes OpenClaw tools and returns their results to Codex while separately notifying internal observers.

flowchart TD
  A[Codex tool request] --> B[OpenClaw tool execution]
  B --> C[Successful tool result]
  C --> D[Result observer]
  D -->|Observer throws| E[Safe error formatter]
  F[Cross-realm and disposal errors] --> E
  E --> G[Redacted diagnostics]
  C --> H[Codex response]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +43, Tests +224. Total +267 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 56 13 +43
Tests 4 265 41 +224
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 321 54 +267

Review metrics

Metric Value Why it matters
Production versus regression coverage production +43 net lines; tests +224 net lines Production growth implements cross-realm and disposal diagnostics; the two observer repairs are net zero and reuse the existing safe formatter.

Technical review

Best possible solution:

Keep error normalization centralized and make observer diagnostics preserve completed tool outcomes without changing execution authority or the wire contract.

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

Yes, from source: a successful tool followed by an observer throwing an Error with an unreadable message can escape main’s String(error) catch and enter failure handling. This review did not execute the reproduction.

Is this the best way to solve the issue?

Yes. Reusing the existing safe formatter at both observer catches and extending its shared diagnostic traversal repairs the owning boundaries without introducing a parallel API.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2d8cff593dcb.

Labels

Label justifications:

  • P2: This focused repair prevents diagnostic loss and successful tool-result loss under unusual error objects.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-author exemption applies, and this patch does not materially change authority. The body records Node VM/disposal runs and actual bridge/watchdog filesystem probes preserving one write, one notification, and success; native app-server execution is explicitly unclaimed.

Evidence

What I checked:

  • Introduced scope and review continuity: The complete host-pinned introduction delta contains the formatter repair, two observer diagnostics, and associated tests. Comparing the previously reviewed head identifies only the four Codex follow-up files; the previous review retained no findings. (eab3e1c98b6f)
  • Shared formatter preserves diagnostics: Safe message/name reads and cross-realm recognition retain diagnostic graph traversal, deduplication, structured codes, and the final caller-owned redactor; suppressed disposal failures enter the same graph. (packages/normalization-core/src/error-coercion.ts:113, eab3e1c98b6f)
  • Observer repair uses the existing safe boundary: The bridge notifies its observer after execution; the changed catch uses formatToolExecutionErrorMessage, whose existing implementation catches formatting failures and preserves redaction. The watchdog uses the same helper. Execution and replay decisions are unchanged. (extensions/codex/src/app-server/dynamic-tools.ts:1088, eab3e1c98b6f)
  • Still necessary on main: The fetched main formatter still uses realm-local instanceof checks, directly reads message/name, and omits suppressed failures. Its Codex observer catch still calls String(error), which can throw while reporting an already-successful tool. (extensions/codex/src/app-server/dynamic-tools.ts:1089, 2d8cff593dcb)
  • Latest-release check: The supplied latest release, v2026.9.2, also retains the formatter’s realm-local checks and lacks suppressed-error traversal; this repair is not already present there. (packages/normalization-core/src/error-coercion.ts:76, 3928bad9badf)
  • Regression coverage preserves meaningful invariants: Tests exercise actual async disposal, VM errors, inaccessible getters, successful bridge/watchdog results, exact observer counts, and protocol projection. Restart coverage separately injects getter, formatter, and logger failures and verifies admission reopens. Tests were inspected, not executed. (src/infra/infra-runtime.test.ts:841, eab3e1c98b6f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ruel225: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Markus Hartung: 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 (2 earlier review cycles)
  • reviewed 2026-09-06T18:27:43.394Z sha 6363296 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-06T18:46:50.894Z sha d2198da :: needs maintainer review before merge. :: none

@steipete steipete changed the title fix(errors): preserve cross-realm and async disposal failures fix(errors): preserve diagnostics and successful tool results Sep 6, 2026
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The final follow-up fixes two observer diagnostics that could discard a successful tool result when formatting an unreadable error. Both consumers use the existing safe formatter; protocol and execution facts are preserved. Causal tests, 243 affected tests, changed-code checks, and a plain Node probe with real temporary-file writes passed. The PR body records the precise baseline and sibling-control results.

@clawsweeper

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

@steipete
steipete merged commit 62fca0d into main Sep 6, 2026
184 checks passed
@steipete
steipete deleted the codex/error-formatting-realms-disposal branch September 6, 2026 19:35
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…aw#140362)

* fix(errors): preserve cross-realm and async disposal failures

* test(restart): preserve cleanup across diagnostic failures

* fix(codex): preserve tool results when observer diagnostics fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant