Repository navigation
fix(agents): use neutral billing copy for subscription auth - #93763
Conversation
Fixes openclaw#80877 AI-assisted (Claude Code).
|
Codex review: needs real behavior proof before merge. Reviewed June 16, 2026, 7:12 PM ET / 23:12 UTC. Summary PR surface: Source +153, Tests +198. Total +351 across 19 files. Reproducibility: yes. at source level: current main and the latest release format all billing-shaped errors with API-key/top-up copy and lack credential-mode input. I did not run a live Anthropic Max OAuth or Telegram reproduction in this read-only review. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Carry the selected auth profile mode through every user-facing billing-error surface, including lifecycle terminal events, while preserving API-key copy for API-key callers and adding non-Vitest proof from an actual OpenClaw runtime path. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main and the latest release format all billing-shaped errors with API-key/top-up copy and lack credential-mode input. I did not run a live Anthropic Max OAuth or Telegram reproduction in this read-only review. Is this the best way to solve the issue? No, not yet: passing the active credential type into the central formatter is the right fix shape, but the PR must also cover lifecycle terminal error events and provide real behavior proof outside Vitest before merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8db66b416bb8. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +153, Tests +198. Total +351 across 19 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
Maintainer review and repair complete. Subscription/OAuth auth mode now survives profile cooldown, prompt and assistant failover, structured failover coercion, model fallback summaries, and final user-facing delivery, so billing failures no longer tell subscription users to top up an API key. Verification:
Known proof gap: the linked local worktree could not execute the overflow-compaction file because its shared install lacks |
|
Thanks for the review and merge, @vincentkoc! 🙏 |
…#93763) * fix(agents): neutral billing-error copy for OAuth/subscription auth Fixes openclaw#80877 AI-assisted (Claude Code). * fix(agents): preserve subscription billing guidance * test(agents): use active auth store in prompt failover --------- Co-authored-by: Vincent Koc <[email protected]>
What and why
Anthropic Max (and other OAuth/token-subscription users) hit a billing limit and see:
Max users authenticate via OAuth — they have no API key to top up. The copy is misleading and
creates support confusion. The recommended Anthropic onboarding path (
/api-key→ Max plan) makesthis a common case.
This PR adds an optional
authModeparameter toformatBillingErrorMessageand threads it fromcredential.type(already computed at the call sites) throughformatAssistantErrorTextopts.When
authModeis"oauth"or"token", the message becomes:API-key and aws-sdk modes are unchanged (regression-guarded by test).
The diff is intentionally minimal to avoid conflicting with the string rewording in the open i18n
PR #90611 — only the new auth-mode branch is added; no existing api-key strings are reworded.
Fixes #80877
Changes
src/agents/embedded-agent-helpers/sanitize-user-facing-text.tsauthMode?param toformatBillingErrorMessage; emit neutral copy for"oauth"/"token"src/agents/embedded-agent-helpers/errors.tsauthMode?toformatAssistantErrorText+formatUserFacingAssistantErrorTextopts; thread to all 3formatBillingErrorMessagecall sitessrc/agents/embedded-agent-runner/run/assistant-failover.tsauthMode?tohandleAssistantFailoverparams +resolveAssistantFailoverErrorMessageparams; pass to both formatter callssrc/agents/embedded-agent-runner/run/payloads.tsauthMode?tobuildEmbeddedRunPayloadsparams; pass to both error-text formatterssrc/agents/embedded-agent-runner/run.tsattemptAuthProfileStore.profiles?.[lastProfileId]?.typeasauthModeat both formatter call sitessrc/agents/embedded-agent-helpers.formatassistanterrortext.test.tsReal behavior proof
Behavior or issue addressed:
formatBillingErrorMessage("Anthropic", "claude-sonnet-4-5", "oauth")must NOTcontain "API key" or "top up" language. API-key mode must still emit the original copy.
Real environment tested: main
3d05da9a, Node 24, pnpm 11.2.2, macOS; real formatter module — notmocked. Tests import and call the actual
formatBillingErrorMessagefunction fromembedded-agent-helpers.js.Exact steps or command run after this patch:
Before evidence (RED — 2 failures):
Evidence after fix (GREEN — all 86 pass):
Observed result: OAuth users see neutral copy ("check your account for subscription or usage
limits, then try again") — no "API key" or "top up" language. API-key mode is unchanged (regression
guards pass).
What was not tested: A live Anthropic Max OAuth account hitting a real 402/429 billing limit
is the gold reproduction — that path is not available in CI. The formatter branch (
authMode === "oauth") is the testable proof, and the credential threading (run.ts → handleAssistantFailover →resolveAssistantFailoverErrorMessage / buildEmbeddedRunPayloads) is statically verifiable. The 5
new tests cover the formatter contract exhaustively.