Skip to content

fix(provider-runtime): retry transient socket failures - #122535

Merged
vincentkoc merged 2 commits into
mainfrom
fix/retry-und-err-socket-91675
Aug 12, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/retry-und-err-socket-91675

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #91675

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where provider reads and recoverable gateway waits would fail immediately when Undici reported a transient socket failure as UND_ERR_SOCKET.

Why This Change Was Made

The shared connection-error matcher now recognizes Undici's socket error code, so existing bounded provider-read retries and gateway-wait recovery use the same classification. This does not add provider-specific logic, change retry counts, replay creates, or alter config, environment, dispatcher, guarded transport, or fallback behavior.

User Impact

Users are less likely to lose an agent turn or enter provider fallback/cooldown after a transient Undici socket close. Non-retryable failures and create operations remain fail-fast.

Production LOC: +1/-1 (net 0) | Tests: +2/-0

Evidence

  • Before the matcher change, the new nested cause.code = "UND_ERR_SOCKET" provider case and shared gateway-wait recovery case both failed.
  • node scripts/run-vitest.mjs src/provider-runtime/operation-retry.test.ts src/agents/run-wait.test.ts - 70 passed.
  • Targeted oxfmt --check and git diff --check passed.
  • Blacksmith Testbox tbx_01kzte7np01v8v7cvbjhmenpvz ran the focused tests and full pnpm check:changed successfully on exact head bb16d2ec0d76485cebbe9a1ad0a09eb66641d4c0: https://github.com/openclaw/openclaw/actions/runs/31574465715
  • Max-P1 autoreview: clean, no accepted/actionable findings, patch correct at 0.98 confidence.
  • Offline local ClawSweeper review: nothing_found, high confidence; best fix confirmed at the shared matcher owner.

No changelog entry: this is a narrow regression repair with no new public surface.

Punchcard-Session: golden-cedar-brook-4q

Punchcard-Session: golden-cedar-brook-4q
Punchcard-Session: golden-cedar-brook-4q
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Aug 12, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 12, 2026 07:44
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

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

Re-review progress:

@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 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 4:11 AM ET / 08:11 UTC.

ClawSweeper review

What this changes

The PR adds Undici’s UND_ERR_SOCKET to the shared connection-error matcher so provider reads retry it and interrupted gateway waits recover.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this active maintainer PR open for normal review. The shared narrow retry matcher currently omits a code that the broader network policy, Plugin SDK classification, and linked provider report already treat as transient; the patch fixes that mismatch at the common owner without changing retry limits or create-operation behavior.

Priority: P1
Reviewed head: bb16d2ec0d76485cebbe9a1ad0a09eb66641d4c0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-neutral repair with direct coverage of the two consumers and no supported correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The contributor is a repository MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless reports exact-head focused tests and a successful changed-file check.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor is a repository MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless reports exact-head focused tests and a successful changed-file check.
Evidence reviewed 9 items Current-main mismatch: Current main already classifies UND_ERR_SOCKET in the broad transient-network set, but the narrower shared matcher used by provider retries and agent waits omits it.
Shared owner fix: The PR changes only the shared narrow matcher, preserving its intentionally limited policy while allowing both existing consumers to recognize the socket code.
Provider retry caller: Provider operation retry checks the shared matcher against both the outer error and its nested cause, and default retries exclude create operations.
Findings None None.
Security None None.

How this fits together

Provider reads and agent-run waits use a shared network-error classifier to decide whether a transient transport failure should be retried. A positive classification continues the bounded recovery path; a negative one surfaces the failure or triggers provider fallback/cooldown.

flowchart LR
  A[Provider read or agent wait error] --> B[Shared connection-error matcher]
  B --> C{Transient code?}
  C -->|yes| D[Existing bounded recovery]
  C -->|no| E[Surface failure]
  D --> F[Continue agent work]
  E --> G[Fallback or agent error]
Loading

Before merge

  • Complete next step (P2) - This active maintainer PR is already the focused repair; it should proceed through ordinary maintainer review rather than a separate repair lane.
Agent review details

Security

None.

PR surface

Source 0, Tests +2. Total +2 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 2 2 0 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 3 1 +2

Review metrics

Metric Value Why it matters
Production vs test LOC production +1/-1 (net 0); tests +2/-0 The fix changes one shared policy expression and adds coverage for both existing recovery consumers without expanding production structure.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #91675
Summary: This PR is the focused candidate fix for the linked report’s provider socket-error behavior.

Members:

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

Technical review

Best possible solution:

Merge the focused common-matcher update with its two consumer-level regression cases, preserving the existing bounded retry policy and fail-fast create operations.

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

Yes, source-reproducible: current main omits UND_ERR_SOCKET from the exact shared matcher reached by provider retries and recoverable waits, while the focused tests exercise both affected paths. This read-only review did not execute the tests.

Is this the best way to solve the issue?

Yes. Updating the shared narrow matcher is the best fix because it repairs both established consumers without widening individual caller policies, retry counts, or create-operation behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The patch addresses provider socket failures that can end an agent turn and place an auth profile into cooldown.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The contributor is a repository MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless reports exact-head focused tests and a successful changed-file check.

Label justifications:

  • P1: The patch addresses provider socket failures that can end an agent turn and place an auth profile into cooldown.
  • 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 contributor is a repository MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless reports exact-head focused tests and a successful changed-file check.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Commit e30df72 introduced the shared matcher and the provider and agent-wait consumers that now need to remain aligned. (role: introduced shared retry-classification path; confidence: high; commits: e30df720459b; files: src/infra/retryable-network-errors.ts, src/provider-runtime/operation-retry.ts, src/agents/run-wait.ts)

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.

@vincentkoc
vincentkoc merged commit dfbdbf2 into main Aug 12, 2026
194 checks passed
@vincentkoc
vincentkoc deleted the fix/retry-und-err-socket-91675 branch August 12, 2026 08:16
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
* test: cover UND_ERR_SOCKET retry recovery

Punchcard-Session: golden-cedar-brook-4q

* fix(provider-runtime): retry UND_ERR_SOCKET failures

Punchcard-Session: golden-cedar-brook-4q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. size: XS 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.

fetch failed / UND_ERR_SOCKET on Windows WSL when connecting to Google Gemini

1 participant