Skip to content

fix(billing): tailor billing error message for OAuth vs API key auth (#80877) - #81011

Closed
alexuser wants to merge 3 commits into
openclaw:mainfrom
alexuser:fix/80877-formatBillingErrorMessage-oauth
Closed

alexuser wants to merge 3 commits into
openclaw:mainfrom
alexuser:fix/80877-formatBillingErrorMessage-oauth

Conversation

@alexuser

Copy link
Copy Markdown
Contributor

Summary

formatBillingErrorMessage was misfiring for Anthropic Max OAuth: it broadcast "top up your API key" even when there was no API key.

Changes

  • formatBillingErrorMessage now accepts an optional authMode parameter.
  • When authMode === \"oauth\", the message refers to the account limit instead of the API key balance.
  • For example, an Anthropic Max OAuth billing error now returns:

    "Anthropic (claude-3-5-sonnet) returned a billing error — your Anthropic account limit has been reached. Check your Anthropic billing dashboard or switch to a different account."

  • authMode is plumbed through assistant-failover.ts so the fallback branch uses the correct wording.

Verification

  • pnpm test src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts — 60 tests passed (includes new OAuth-specific assertion).
  • pnpm test src/agents/pi-embedded-runner/run/assistant-failover.test.ts — 11 tests passed.
  • pnpm test src/agents/pi-embedded-runner/run/payloads.errors.test.ts — 39 tests passed.
  • pnpm test src/agents/pi-embedded-helpers/errors.test.ts — 11 tests passed.

Closes #80877

alexuser added 2 commits May 12, 2026 02:11
…OS Big Sur

On macOS Big Sur, net.createServer().listen(0, '::1') never fires
'listening' or 'error' events, causing the gateway to hang indefinitely
at startup while resolving bind hosts.

This fix adds a 2-second timeout with proper resolve-once guards so
that if the OS never confirms bindability, we fall back to false
instead of hanging forever.

Fixes openclaw#80920
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 12, 2026
@clawsweeper

clawsweeper Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: the same linked billing-copy bug is already covered by #80895, which is narrower, has sufficient real-behavior proof, and threads active auth profile mode through more of the affected runtime path. This branch also still has a correctness gap from using only runtime auth state and carries unrelated config/gateway commits.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Use the narrower canonical fix in #80895 or a maintainer replacement that carries the active auth profile mode through all user-facing billing-error formatting paths, and keep unrelated config/gateway work split.

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

Yes at source level: current main formats billing-shaped assistant errors with API-key-only copy, while the runner/auth controller already has credential-mode information that is not passed to the formatter. I did not run a live Anthropic Max OAuth or Telegram path in this read-only review.

Is this the best way to solve the issue?

No: the direction is right, but this branch uses only runtimeAuthState and misses normal OAuth/token paths where runtimeAuthState is null. The better solution is the narrower canonical PR that uses the active auth profile mode across formatter, failover, payload, attempt, and lifecycle surfaces.

Security review:

Security review cleared: No concrete security or supply-chain regression was found in the diff.

What I checked:

Likely related people:

  • steipete: Recent GitHub commit history and local blame show substantial work on user-facing assistant error formatting, sanitizer code, and runner helper areas involved in this bug path. (role: recent area contributor; confidence: medium; commits: 250e16d3c937, 9180173f9a79, 0ecda680c8ca; files: src/agents/pi-embedded-helpers/sanitize-user-facing-text.ts, src/agents/pi-embedded-helpers/errors.ts, src/agents/pi-embedded-runner/run.ts)
  • vincentkoc: Commit history includes sanitizer and user-facing model-capacity error work near the formatter behavior this PR changes. (role: adjacent area contributor; confidence: medium; commits: 35664d5447a4, f1ad5e27e035; files: src/agents/pi-embedded-helpers/sanitize-user-facing-text.ts)
  • wirjo: Auth-controller history includes the no-explicit-key runtime auth fallback path that explains why runtimeAuthState is not a complete source for OAuth/token mode. (role: auth runtime contributor; confidence: medium; commits: c7e5289fd20d; files: src/agents/pi-embedded-runner/run/auth-controller.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 4272ce15978d.

-  now accepts an optional  parameter.
- When , messages refer to "account limit" instead
  of "API key has run out of credits".
- Pipe  through  (fallback branch) to
  .
- Adds a targeted test verifying OAuth wording.

Closes openclaw#80877
@alexuser
alexuser force-pushed the fix/80877-formatBillingErrorMessage-oauth branch from dbe6845 to 561360f Compare May 12, 2026 15:40
@alexuser
alexuser marked this pull request as draft May 12, 2026 15:48
@alexuser
alexuser marked this pull request as ready for review May 12, 2026 15:49
@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 12, 2026
@clawsweeper clawsweeper Bot closed this May 12, 2026
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 mantis: telegram-visible-proof Mantis should capture Telegram visible proof. size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatBillingErrorMessage misfires for Anthropic Max OAuth — broadcasts "top up your API key" when there is no API key

1 participant