Skip to content

fix(agents): preserve provider ownership in error diagnostics - #134029

Merged
steipete merged 5 commits into
mainfrom
codex/upgrade-provider-diagnostics-20260831
Aug 31, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/upgrade-provider-diagnostics-20260831

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where assistant error messages could use another loaded provider's policy after losing the active provider's prepared owner. Schema and context errors could consequently receive incorrect copy. Diagnostic rendering without an owner could also consult provider hooks that did not own that error.

Closes #134012.

Why This Change Was Made

Carry the existing prepared-owner/explicit-absence contract through assistant formatting, embedded lifecycle diagnostics, TUI auth hints, and Gateway error-history projection. This complements the loaded-only resolver repair already on main in #133970: the resolver limits runtime loading, while this patch keeps diagnostic policy attached to the correct owner and avoids consulting loaded hooks when presentation has no owner.

The raw-message schema check remains separate because generic HTTP 400 classification is insufficient evidence of a schema failure. Both classification passes now carry the same owner. Runtime callers retain their existing undefined-owner behavior and can consult loaded provider hooks.

User Impact

Prepared provider schema/context policy remains authoritative for assistant error copy. Diagnostic consumers without a provider owner use shared classifications. Existing auth redaction, billing copy, context recovery hints, and terminal lifecycle behavior remain covered.

Evidence

  • Current-main regression proof on pinned 4feff037baaf786d967fbbb6335ad6b97835cbd6: all five assistant ownership cases and the Gateway case fail, while the runtime-lookup control passes. The same seven cases all pass on rebased commit 324e97bcb5d0c562871e8a4803f2aa68ee2c71de. Candidate source bytes were restored and verified after the baseline run.
  • Presentation proof: 336 tests across eight files, including unchanged formatter, lifecycle error delivery, observation redaction, TUI error handling, and WebSocket/SSE history projection. Runtime sibling proof: 117 tests in the existing formatter/runtime-failure suites.
  • Rebased exact commit 324e97bcb5d0c562871e8a4803f2aa68ee2c71de: affected runtime suites passed 117/117. Main's broad resolver mock was replaced with the already-reviewed prepared-generation fixture; real registered hooks return no override, core decisions and assertions remain unchanged.
  • Historical investigation before perf(agents): reuse loaded provider hooks during error handling #133970 landed: an unchanged Linux formatter case took 71.956 seconds, and the production-only ownership patch reduced it to 19 ms. This is historical evidence of the original failure path, not an incremental benchmark against current main. Both Linux runs used Node 24.19.0 and verified identical baseline source blobs; candidate source/test hashes were verified. Runs: https://github.com/openclaw/openclaw/actions/runs/33376318287 and https://github.com/openclaw/openclaw/actions/runs/33378374717.
  • Original candidate full build and changed checks passed, including core/test typechecks, lint, unused-export scans, storage guards, and zero runtime import cycles. Its production patch is unchanged by the rebase. Fresh isolated Codex review of the rebased commit completed clean at the requested P0 threshold with current loaded-only resolver source included; no accepted, priority-filtered, or scope-rejected findings were returned.

Production LOC: +19 net across seven existing modules, carrying the existing owner/absence contract through two helpers and five diagnostic consumers. The distinct raw-message schema check preserves the existing HTTP 400 contract. Tests/support: +180 net against the rebased main, including removal of its newer broad resolver mock. No configuration, storage schema, or protocol change.

CI follow-up: after the initial checkout failures, the unchanged-head retry completed most tests but a lint runner was shut down and an unchanged system-prompt fixture exceeded120seconds. The fixture supplied a prepared provider handle without its model ID. Direct before/after tracing of the real helper observed four redundant preparations and two provider discoveries before, zero of each after supplying the existing matching model ID. The original12cases pass uninstrumented; focused typecheck, lint, formatting, and fresh isolated review pass. This one-line test-only correction changes no assertions or timeouts. The local trace proves unnecessary discovery, not that it accounts for the full hosted timeout. All temporary trace code was removed.

The source/compiled subprocess integration fixture also required its existing owner handoff to be completed. Stable2026.8.1 and current production already pass the prepared owner into terminal payload rendering; the newer integration fixture left its scoped case ownerless. The corrected fixture prepares through the matching source or compiled resolver inside the original registry scope and asserts exact hook identity before rendering. The original failure reproduced locally, then all four source/compiled × scoped/prepared flows passed with every existing hook, visible-error, no-discovery, and no-global-activation assertion intact. The compiled resolver is a test-only build entry, preserving the cross-runtime registry identity proof. Scripts/root-test types, type-aware lint, formatting, and fresh isolated review pass. This follow-up changes only tests/support (+23/-3).

CI exposed a second fixture ownership problem: the real Anthropic preparation child interpreted the full source plugin graph through Jiti on every fresh process. Windows hit the unchanged 120-second test deadline twice. A local phase probe reproduced 127.48 seconds, including 114.83 seconds in plugin module loading and 1.2 milliseconds in registration. The fixture now compiles both the child and real Anthropic public entry through the existing invocation-owned artifact builder, then runs plain Node. It retains every original failover and no-global-registry assertion and additionally verifies native artifact loading without source transforms.

The repaired case passed locally in 6.46 seconds, including 4.11 seconds of artifact preparation; the real plugin load took 279 milliseconds. Four shared artifact-owner cases also passed, including native writes, source/compiled provider hooks, cross-project lazy build, and generation retention until borrowers finish. Targeted checks and isolated review passed. On final commit cf1733620381f04f03783871fec6f51b4a831b75, both Windows jobs passed. The real Anthropic case completed in 15.556 seconds, including 10.012 seconds of artifact preparation and 726 ms of native plugin loading, with one native hit and zero source transforms. All four source/compiled payload flows passed in 37.139 seconds. The containing Windows job completed successfully in 27m58s. Lint and dependency checks also passed. Final exact-head CI run 33390661313 completed successfully: 193 passing jobs, including the aggregate gate, and 17 intentionally skipped jobs.

Follow-up: investigate source-checkout Anthropic/Jiti cold-load latency. This test fixture repair does not fix the observed source transformation cost or claim faster product startup.

Updated whole-PR LOC: production 42 added / 23 deleted (+19); tests/support 237 added / 57 deleted (+180), including an extracted 32-line native child probe.

Knip integration: the compiled child is launched by path, so its existing executable test entry must be declared in the unused-code configuration. The two-line declaration uses the canonical root-test entry mechanism, without an ignore or weakened gate. Production and full-tree unused-file scans report zero findings; targeted types, lint, formatting, and P3 review pass.

@steipete steipete self-assigned this Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 9:24 AM ET / 13:24 UTC.

ClawSweeper review

What this changes

The PR keeps prepared provider ownership, or explicit no-owner state, through agent error formatting and diagnostic displays, and updates compiled-worker test fixtures for the same boundary.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No introduced correctness or security defect was found. Keep this maintainer-authored, maintainer-labelled PR open for human merge handling after its exact-head CI completes.

Priority: P1
Reviewed head: cf1733620381f04f03783871fec6f51b4a831b75

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused extension of the existing no-discovery ownership contract with targeted boundary coverage and no identified correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied hosted Windows and compiled-worker traces are supplemental evidence for the changed test boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied hosted Windows and compiled-worker traces are supplemental evidence for the changed test boundary.
Evidence reviewed 6 items Existing owner contract: The merged loaded-hook resolver already defines explicit null as presentation-only no-owner state and returns without provider discovery.
Current-main gap: Current main still calls the runtime failure classifier without passing the prepared owner, and its classifier repeats provider-sensitive classification without that context.
Introduced repair: The branch derives one providerPlugin value from the prepared owner or null and passes it to both runtime-failure and context classification.
Findings None None.
Security None None.

How this fits together

Agent runs prepare provider-specific failure policy before model execution; formatter, lifecycle, TUI, and Gateway history paths later turn failures into recovery copy. The change prevents those presentation-only consumers from borrowing another loaded provider’s policy when no owner was prepared.

flowchart LR
  A[Provider preparation] --> B[Prepared owner or no owner]
  B --> C[Assistant error classifier]
  C --> D[Agent reply formatting]
  C --> E[Lifecycle and TUI diagnostics]
  C --> F[Gateway history display]
  D --> G[Recovery copy]
  E --> G
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - The repair adds 19 production lines across diagnostic consumers; any simplification must preserve the explicit prepared-owner/null path rather than reintroducing provider-hook lookup from a presentation-only path.
  • Complete next step (P2) - The author association and maintainer label require human merge handling; remaining queued exact-head checks are a normal landing gate, not a repair task.
Agent review details

Security

None.

PR surface

Source +49, Tests +142, Other +8. Total +199 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 8 72 23 +49
Tests 7 199 57 +142
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 8 0 +8
Total 17 279 80 +199

Review metrics

Metric Value Why it matters
Production versus test delta production +19; tests/support +180 The production increase carries the existing owner/null contract through diagnostic consumers, while most change volume is focused regression and compiled-worker support.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge the consistent prepared-owner/null propagation after exact-head CI is green; separate presentation consumers need the explicit value because they do not own runtime provider discovery.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge the consistent prepared-owner/null propagation after exact-head CI is green; separate presentation consumers need the explicit value because they do not own runtime provider discovery.

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

Yes, source-reproducible. Current main omits the prepared owner at the formatter and repeated schema/context classification points; the branch adds focused conflicting-owner and no-discovery cases, though this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. The existing provider-pattern contract makes explicit null the correct presentation-only no-discovery state, and forwarding the already-prepared owner is narrower than creating a second resolver or policy path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The repaired path can produce incorrect provider-specific error recovery copy and delay failure handling in active agent runs.
  • 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: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied hosted Windows and compiled-worker traces are supplemental evidence for the changed test boundary.

Evidence

What I checked:

Likely related people:

  • steipete: 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 (5 earlier review cycles)
  • reviewed 2026-08-31T10:09:23.150Z sha 324e97b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T10:18:48.950Z sha 324e97b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T10:49:11.249Z sha 2cd25f3 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T11:57:57.595Z sha 78b9e6e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T12:24:11.613Z sha cf17336 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review August 31, 2026 10:10
@steipete

Copy link
Copy Markdown
Contributor Author

The first exact-head CI run failed primarily before code execution: 102 jobs failed, with the inspected build/type/test jobs exhausting checkout attempts because Git could not authenticate to github.com. The build job partially fetched the correct PR merge on one attempt, then failed fetching the separate CI harness with the same error. This does not indicate a missing PR ref or a test assertion failure. The underlying HTTP response was not logged, so no outage or credential-expiry cause is claimed.

Failed jobs have been rerun on unchanged head 324e97bcb5d0c562871e8a4803f2aa68ee2c71de. No source, assertions, or timeouts changed. Fresh review and current-main ownership regression evidence are recorded in the PR body; green required CI remains a landing gate.

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Aug 31, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The current head's formatter, prepared model-handle fixture, and source/compiled owner handoff all passed in hosted CI. The remaining failed jobs encountered GitHub checkout errors, npm tarball timeouts, or the same GitHub fetch error while retrieving a pinned historical reader before its compatibility assertion. No new code failure was identified in those jobs. Windows also hit the existing 120-second timeout in the separate fresh-process Anthropic preparation case; the changed four-flow payload proof passed there. That timeout has occurred in another lane and then passed unchanged, so this retry keeps the test and its limit intact.

I am retrying only failed jobs on the unchanged head. The latest ClawSweeper review covers this exact commit and reports no correctness or security findings. The prepared-owner/null contract and its production growth remain justified by the separate diagnostic consumers; final merge still waits for the required CI result.

@steipete

Copy link
Copy Markdown
Contributor Author

Final maintainer review: the prepared-provider/null boundary is accepted as the canonical owner contract. The +19 production lines carry that existing fact through diagnostics; runtime callers retain their existing loaded-provider behavior, while presentation without an owner cannot borrow another provider's policy. No actionable correctness or security findings remain in the current-head ClawSweeper review. Its owner-review Rank-up is addressed by this maintainer review.

Final commit: cf1733620381f04f03783871fec6f51b4a831b75.

CI: https://github.com/openclaw/openclaw/actions/runs/33390661313

Both final-head Windows jobs passed. The real Anthropic compiled-child case took 15.556 seconds, including 10.012 seconds of artifact preparation and 726 ms native plugin loading, with one native hit and zero source transforms. All four source/compiled payload flows passed. Linux lint and both unused-code checks passed. Current-main owner regressions, existing runtime siblings, source/compiled owner identity, and real Linux error-rendering evidence are recorded in the PR body; historical timing is explicitly distinguished from the ownership defect remaining after the complementary main fix.

Source-checkout Anthropic/Jiti cold loading remains a named follow-up. This patch does not claim faster product startup or an external provider API round trip.

Final verification: the exact-head run completed successfully with193passing jobs, including the required aggregate gate, and17intentionally skipped jobs. The latest13:24UTC ClawSweeper review was read in full and has no actionable findings.

@steipete
steipete merged commit 6100a68 into main Aug 31, 2026
274 of 275 checks passed
@steipete
steipete deleted the codex/upgrade-provider-diagnostics-20260831 branch August 31, 2026 13:42
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit to vladimirkrdzic/openclaw that referenced this pull request Aug 31, 2026
Reuse the prepared-provider error handling fixes from openclaw#133970 and openclaw#134029 while preserving the original plugin drift repair ancestry.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
…aw#134029)

* fix(agents): preserve provider ownership in error diagnostics

* test(agents): complete the prepared provider handle fixture

* test(agents): prepare scoped owners in compiled payload proofs

* test: prepare native Anthropic artifacts for failover proof

* test: declare compiled Anthropic probe as an executable root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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.

[Bug]: Error presentation drops prepared provider ownership and cold-loads plugins

1 participant