tray crash-loops on startup — bundled vc++ runtime older than onnxruntime needs
0xe0434352 dialog on launch, autostart relaunches → crash loop. real error's in the app event log:
.NET Runtime (1026): System.DllNotFoundException: Unable to load DLL 'sherpa-onnx-c-api' or one of
its dependencies: A dynamic link library (DLL) initialization routine failed. (0x8007045A)
at SherpaOnnx.OfflineTts.SherpaOnnxDestroyOfflineTts(IntPtr handle)
at SherpaOnnx.OfflineTts.Cleanup() / Finalize() -> GC.RunFinalizers()
Application Error: faulting module MSVCP140.dll 14.29.30142.1, 0xc0000005
tldr: bundled msvcp140/vcruntime140 are 14.29 and sit next to onnxruntime 1.26, so they win over the system runtime. 1.26 wants newer → sherpa-onnx-c-api fails its init (0x8007045A) → the OfflineTts finalizer calls into the dead dll → AV.
repros on signed 0.6.3 + a clean build of main. dropping the current vcruntime (14.51) in the app dir fixes it.
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/54443
- https://github.com/anthropics/claude-code/issues/48996
- https://github.com/anthropics/claude-code/issues/47754
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
Live capture: token unexpired, 401 returned mid-Cloudflare-502-window
Caught one in the act with instrumentation watchers. The captured timeline contradicts my original "OAuth refresh fails" theory — the access token was fresh and unexpired at the moment of failure:
00:16:49 Request 1 → 401 creds.json untouched, TTL = 24064s (6.6h remaining)
00:16:50 Request 2 → 502 (Cloudflare upstream blip)
00:16:51 Request 3 → 502
00:16:54 Request 4 → 502
00:16:59 Request 5 → 401 x-should-retry: false → client gives up
00:18:29 /login → new token written to disk
Throughout the cascade:
~/.claude/.credentials.jsonaccess-token fingerprint stayed atsha=c208e21c(unchanged for 79 minutes prior — last touched by previous/login)- File mtime didn't move during the 401 cascade
- Token TTL was 24064 seconds at the time of failure (token doesn't expire until 06:57:54 — over 6.5 hours away)
So the access token sent was definitely the same valid one being accepted minutes earlier. The 401s straddle a Cloudflare 502 storm (responses include server: cloudflare + cf-ray header on the 502s).
What this changes
This is not a client OAuth bug. It's the origin (Anthropic API behind Cloudflare) returning 401 authentication_error for valid tokens during edge instability. The client correctly retries, but x-should-retry: false on the 401 makes it give up. /login doesn't fix the auth — it just buys ~90 seconds while Cloudflare recovers, then the new token starts working because the transient is over.
Why next-session 401-at-boot still happens
Because the bad state persists in a different way:
- Long session crosses a 502 window → 401 → "Please run /login" displayed
- User exits without /login, restarts later → first request hits a still-degraded upstream → 401 again at session boot
When the user finally /logins after 1-2 min, the upstream has recovered and it "works." The credentials.json content was never the issue.
Suggested triage
- Anthropic infrastructure team to investigate why valid tokens get rejected with
authentication_errorwhen fronted by misbehaving Cloudflare edge nodes (cf-rayIDs available in our captures). - Claude Code client could distinguish this case: on
401 authentication_errorwhere the most recent request 5xx'd againstcloudflareserver header, treat as transient and retry with backoff instead of surfacing "Please run /login."
Evidence collection: 2 background watchers continuing to run in /root/.claude-401-debug/. Happy to share sanitized snapshots, request-ids, and cf-ray headers from past incidents.
Definitive: same token, same instant — api.anthropic.com/v1/messages rejects, console.anthropic.com/v1/oauth/hello accepts
Captured 4 more 401 events in the last hour. The watcher now probes console.anthropic.com/v1/oauth/hello against the exact same access token, in the exact same second the /v1/messages call fails:
2026-05-24 00:57:10 /messages → 401 Invalid authentication credentials
2026-05-24 00:57:10 /oauth/hello (same token) → HTTP 200 {"message":"hello"}
2026-05-24 00:57:44 /messages → 401
2026-05-24 00:57:44 /oauth/hello (same token) → HTTP 200
2026-05-24 00:59:39 /messages → 401
2026-05-24 00:59:39 /oauth/hello (same token) → HTTP 200
2026-05-24 00:59:41 /messages → 401
2026-05-24 00:59:41 /oauth/hello (same token) → HTTP 200
Token state at every event:
- TTL: 26478s+ remaining (token doesn't expire for ~7.4 hours)
- File mtime: 38+ minutes old (no recent rotation)
- Fingerprint:
sha=0ab4bdda— unchanged across all 4 events
What this eliminates
This rules out every client-side theory:
- Not OAuth refresh: token unchanged
- Not Cloudflare-wide:
console.anthropic.com(also Cloudflare-fronted) works - Not token expiry: 7+ hours TTL
- Not token corruption: same token works on a different endpoint at the same instant
The bug is specifically api.anthropic.com/v1/messages rejecting valid OAuth tokens that the auth system itself acknowledges as valid (since /oauth/hello succeeds).
Most likely cause
This pattern fits a per-user or per-session rate-limit / quota state that:
- Lives on
api.anthropic.com(not the auth gateway) - Stays "stuck" in a reject state until cleared by
/login - Returns
401 authentication_errorinstead of the more accurate429 - Cleared either by minting a new token chain or by some session-state reset that happens during /login
This would explain why:
- Long active sessions hit it (more tokens burned → quota state triggers)
- /login always fixes it (state reset, not the new credentials per se)
- Waiting doesn't always fix it (the stuck state persists indefinitely on the existing token)
- Multiple Anthropic accounts hit it (it's a per-session-state issue, not account-specific)
Suggested fix
- Anthropic backend: investigate why
/v1/messagesreturns401 authentication_errorfor tokens that/v1/oauth/helloaccepts. Whatever sub-system is rejecting these requests should:- Return a more accurate status (429 / 503 / etc.) so clients can retry
- Not be cleared only by full re-auth — should self-heal or expose a recovery mechanism
- Claude Code client: when a 401 hits with
authentication_error, optionally probe/oauth/hellobefore showing "Please run /login" — if hello works, retry instead of forcing user re-auth
Evidence files
Available on request:
session-events.log— full timeline of 8+ captured 401 events with probe resultsevents.log— credentials.json mutation log (proves token unchanged across failures)- Multiple
req_011*request-ids if Anthropic infra wants to grep specific requests
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 6, 2026, 9:08 AM ET / 13:08 UTC.
Summary Keep open; current main still appears to ship the same x64 app-local VC runtime path while ONNX/Sherpa remains in the tray and the native dependency verifier does not cover the reported load failure.
Reproducibility: yes. for a source-level path: publish or run the Windows tray with the current win-x64 app-local VC runtime package and exercise the Piper/Sherpa TTS path. I did not run the live Windows crash in this read-only review.
Next step This is a focused packaging and validation repair with clear likely files and a high-impact crash-loop failure mode.
Review details
Best possible solution:
Update packaging so app-local VC runtime DLLs are new enough for the bundled ONNX/Sherpa stack, then extend native dependency validation to catch Sherpa/ONNX loading or minimum runtime-version failures.
Do we have a high-confidence way to reproduce the issue?
Yes for a source-level path: publish or run the Windows tray with the current win-x64 app-local VC runtime package and exercise the Piper/Sherpa TTS path. I did not run the live Windows crash in this read-only review.
Is this the best way to solve the issue?
Yes; the narrow maintainable fix is release packaging plus native dependency validation, not a TTS workaround that leaves stale app-local runtime DLLs shadowing newer system runtimes.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
- This read-only Linux review did not execute a live Windows tray launch or native Sherpa/ONNX load probe; the fix should include Windows publish proof for the packaged runtime.
Codex review notes: model gpt-5.5, reasoning high; reviewed against 4be005707f44.
Label changes
Label changes:
- add
P0: The report is a startup crash loop that can make the tray unusable on affected installs. - add
impact:crash-loop: The issue specifically reports autostart relaunching the tray into repeated startup crashes. - add
issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label. - add
clawsweeper:source-repro: Current issue advisory state selects this label. - add
clawsweeper:queueable-fix: Current issue advisory state selects this label. - add
clawsweeper:fix-shape-clear: Current issue advisory state selects this label.
Label justifications:
P0: The report is a startup crash loop that can make the tray unusable on affected installs.impact:crash-loop: The issue specifically reports autostart relaunching the tray into repeated startup crashes.
Evidence reviewed
Acceptance criteria:
- ./build.ps1
- dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
- dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
- dotnet publish ./src/OpenClaw.Tray.WinUI/OpenClaw.Tray.WinUI.csproj -c Release -r win-x64 --self-contained --no-restore -o publish
- pwsh ./scripts/Test-ReleaseNativeDependencies.ps1 -PayloadPath publish -RequireAppLocalVCRuntime
What I checked:
- Current x64 runtime package pin: Current main still references VCRuntime.CefSharp.140 1.0.5 as the product build source for loose VC runtime DLLs. (
src/Directory.Build.props:17, 4be005707f44) - Current x64 app-local copy path: The x64 target copies every DLL from the pinned VCRuntime.CefSharp.140 package into build and publish output, matching the reported app-local shadowing mechanism. (
src/Directory.Build.targets:24, 4be005707f44) - ONNX and Sherpa native dependencies remain present: The shared project references Microsoft.ML.OnnxRuntime 1.26.0 and the tray references org.k2fsa.sherpa.onnx 1.13.0, with PiperTextToSpeechClient constructing SherpaOnnx.OfflineTts. (
src/OpenClaw.Shared/OpenClaw.Shared.csproj:22, 4be005707f44) - Verifier gap: Test-ReleaseNativeDependencies.ps1 searches for libsodium.dll and probes LoadLibrary("libsodium.dll"), but it does not probe sherpa-onnx-c-api, ONNX Runtime, or minimum VC runtime file versions. (
scripts/Test-ReleaseNativeDependencies.ps1:93, 4be005707f44) - Release workflow relies on that verifier: CI and release packaging run Test-ReleaseNativeDependencies.ps1 with RequireAppLocalVCRuntime, so the current release gate can pass while missing the reported Sherpa/ONNX runtime-version mismatch. (
.github/workflows/ci.yml:394, 4be005707f44) - Latest release has the same core packaging shape: The v0.6.3 tag contains VCRuntime.CefSharp.140 1.0.5, the x64 copy glob, and Microsoft.ML.OnnxRuntime 1.26.0, consistent with the reporter's signed-release repro. (
src/Directory.Build.targets:24, 85445c78066b)
Likely related people:
- vincentkoc: PR 596 added the VC runtime package, release verifier, workflow checks, and release docs for native runtime bundling. (role: introduced release runtime bundling; confidence: high; commits: 7485ce2af9da; files:
src/Directory.Build.props,src/Directory.Build.targets,scripts/Test-ReleaseNativeDependencies.ps1) - kmahone: PR 656 recently changed adjacent VC runtime publish logic and tests for ARM64 while leaving the x64 NuGet-sourced runtime path intact. (role: recent release-runtime contributor; confidence: medium; commits: f839cf53aa0c; files:
src/Directory.Build.targets,tests/OpenClaw.Tray.Tests/ReleaseSigningWorkflowTests.cs,docs/RELEASING.md) - RBrid: PR 288 added the Sherpa package reference and OfflineTts wrapper involved in the reported native initialization failure. (role: introduced Sherpa/Piper TTS native dependency; confidence: medium; commits: b0ba9affa25d; files:
src/OpenClaw.Tray.WinUI/OpenClaw.Tray.WinUI.csproj,src/OpenClaw.Tray.WinUI/Services/TextToSpeech/PiperTextToSpeechClient.cs,src/OpenClaw.Shared/Audio/PiperVoiceManager.cs)
How this review workflow works
- 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-reviewcomments, 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-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto 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 explainto ask for more context, or@clawsweeper stopto stop active automation.
Adding a data point from a long-duration variant of this stale-credentials → persistent 401 problem (filing #65761, which I'm closing as a duplicate in favor of this issue).
In my case there was no transient 5xx involved and the failure was not on a 4–8h cycle. Instead:
- Interactive
/loginhappened once, ~2 months earlier (Claude Code 2.1.104). After that the access token was only ever silently refreshed —expiresAtkept advancing, but no full re-grant ever occurred. - After ~55 days, every request began returning
401 Invalid authentication credentials. This is consistent with the underlyingrefreshTokenreaching its max lifetime / being rotated server-side, rather than a transient upstream error. - Running
/loginreported "Login successful" but requests kept returning 401 — i.e./logindid not recover the session (same user-facing symptom as the closed #15007). - The only fix was
rm ~/.claude/.credentials.jsonfollowed by/login, which forced a clean browser OAuth grant.
So whether the credentials get poisoned by a transient 5xx (this issue) or simply age out after a long refresh-only period (my case), the end state and the broken recovery path are identical: a stale token persists in ~/.claude/.credentials.json and /login fails to overwrite it.
Reinforcing the fixes already requested here:
/loginshould always perform a clean grant and fully overwrite the existing token, never reuse/refresh a possibly-stale entry.- On a refresh that fails with 401, Claude Code should discard the stale credentials automatically and fall back to full re-authorization (i.e. do internally what manual deletion does today).
- A persistent 401 should surface an actionable message ("saved credentials are no longer valid — run
/login") instead of the confusing "Login successful but still 401" state.
Environment: Claude Code 2.1.165, Linux (WSL2), OAuth / Claude Max subscription.
🤖 This is an automated response from Repo Assist.
Root cause confirmed: VCRuntime.CefSharp.140 1.0.5 ships vcruntime140.dll version 14.29 (VS 2019 16.11). Both org.k2fsa.sherpa.onnx 1.13 and Microsoft.ML.OnnxRuntime 1.26 are compiled with VS 2022 and require VC++ runtime ≥ 14.40. When the app-local 14.29 DLL wins the loader search over the system runtime, sherpa-onnx-c-api fails DLL initialisation (0x8007045A) during GC finalisation of OfflineTts, crash-looping the tray.
Validation fix submitted this run: I opened a PR adding a minimum file-version check (≥ 14.40.0.0) to Test-ReleaseNativeDependencies.ps1 so future releases that bundle an under-version VC runtime will fail CI on the Windows x64/arm64 build leg before reaching users. A regression test is included to prevent the gate from being silently removed.
Follow-up packaging work needed (not in this PR): VCRuntime.CefSharp.140 must be updated to a version that ships 14.40+ DLLs — or the x64 VC runtime resolution changed to source from the local VS install (matching the ARM64 path in Directory.Build.targets). Either path requires Windows + NuGet connectivity to verify.
Generated by 🌈 Repo Assist, see workflow run. Learn more.
Add this agentic workflows to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a