Skip to content

fix: recognize Poe 402 'used up your points' as billing for fallback#42278

Merged
altaywtf merged 2 commits intoopenclaw:mainfrom
CryUshio:fix/poe-402-billing-fallback
Mar 10, 2026
Merged

fix: recognize Poe 402 'used up your points' as billing for fallback#42278
altaywtf merged 2 commits intoopenclaw:mainfrom
CryUshio:fix/poe-402-billing-fallback

Conversation

@CryUshio
Copy link
Copy Markdown
Contributor

Poe API returns '402 You've used up your points! Visit https://poe.com/api/keys to get more.' which was not matched by RAW_402_MARKER_RE (requires 'payment required'). Add Poe-specific pattern to RAW_402_MARKER_RE so fallback triggers.

Ref: https://poe.com/api/keys
Made-with: Cursor

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: Poe API returns 402 You've used up your points! Visit https://poe.com/api/keys to get more. when credits are exhausted. RAW_402_MARKER_RE only matches 402 payment required and similar patterns, so this error is not recognized as billing.
  • Why it matters: Without recognition, classifyFailoverReason returns null, fallback is not triggered, and the user sees a generic failure instead of automatic failover to another model.
  • What changed: Added |^\s*402\s+.*used up your points\b to RAW_402_MARKER_RE so Poe's 402 message is treated as billing and triggers fallback.
  • What did NOT change (scope boundary): Other 402 formats, classifyFailoverReasonFromHttpStatus, and non-Poe providers are unchanged. Only Poe's specific "used up your points" text is matched.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

List user-visible changes (including defaults/config).
If none, write None.

  • When Poe returns 402 You've used up your points!, model fallback now triggers instead of failing with an unclassified error.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS / Linux
  • Runtime/container: Node ≥22
  • Model/provider: Poe (poe.com)
  • Integration/channel (if any): Any channel using Poe as LLM provider
  • Relevant config (redacted): agents.defaults.models with Poe + fallback model (e.g. OpenRouter)

Steps

  1. Configure Poe as primary model and another provider (e.g. OpenRouter) as fallback.
  2. Exhaust Poe API points (or simulate 402 response).
  3. Send a message that triggers an LLM call.

Expected

  • Error is classified as billing; fallback to secondary model is triggered.

Actual

  • Before fix: classifyFailoverReason returns null, no fallback, generic error shown.
  • After fix: Error classified as billing, fallback triggers.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Added pi-embedded-helpers.isbillingerrormessage.test.ts case for Poe 402 message; regex logic verified via standalone Node script.

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: Regex matches 402 You've used up your points! Visit https://poe.com/api/keys to get more.; existing 402 patterns (e.g. 402 Payment Required) still match.
  • Edge cases checked: Pattern is narrow (used up your points); does not match arbitrary 402 xxx text.
1 截屏2026-03-10 23 16 11

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert the commit.
  • Files/config to restore: src/agents/pi-embedded-helpers/errors.ts, src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts
  • Known bad symptoms reviewers should watch for: Poe 402 no longer triggering fallback; false positives on other 402 messages containing "used up your points".

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: Another provider returns a 402 message containing "used up your points" with different semantics.
    • Mitigation: Pattern is specific to Poe's known wording; classify402Message still distinguishes billing vs rate_limit via existing hints.

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Mar 10, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR makes a single, targeted fix: it extends RAW_402_MARKER_RE in errors.ts to recognize Poe's non-standard 402 You've used up your points! message, so classifyFailoverReason correctly returns "billing" and triggers model fallback instead of returning null.

  • The regex alternative ^\s*402\s+.*used up your points\b is anchor-bounded (^) and phrase-specific, keeping the risk of false positives from other providers low.
  • classify402Message already defaults to "billing" when no rate-limit hint is found, so no further logic changes are needed — Poe's message correctly falls through to that default.
  • A regression test is added for the exact Poe error string; existing billing/rate-limit tests are unmodified.
  • The change is backward-compatible and limited to the Poe-specific wording, as stated in scope.

Confidence Score: 5/5

  • This PR is safe to merge — the change is a minimal, well-tested regex addition with no behavioral impact outside the targeted Poe 402 message.
  • The diff is two lines (one production, one test). The new regex alternative is anchor-bounded and phrase-specific. The downstream classification logic already handles this case correctly through the default return "billing" path. A targeted test is included, and no existing tests were altered.
  • No files require special attention.

Last reviewed commit: 893e276

@altaywtf altaywtf self-assigned this Mar 10, 2026
@altaywtf altaywtf force-pushed the fix/poe-402-billing-fallback branch from 893e276 to bf7d145 Compare March 10, 2026 17:08
CryUshio and others added 2 commits March 10, 2026 20:08
Poe API returns '402 You've used up your points! Visit https://poe.com/api/keys
to get more.' which was not matched by RAW_402_MARKER_RE (requires 'payment
required'). Add Poe-specific pattern to RAW_402_MARKER_RE so fallback triggers.

Ref: https://poe.com/api/keys
Made-with: Cursor
@altaywtf altaywtf force-pushed the fix/poe-402-billing-fallback branch from bf7d145 to f3cdfa7 Compare March 10, 2026 17:16
@altaywtf altaywtf merged commit 8bf64f2 into openclaw:main Mar 10, 2026
9 checks passed
@altaywtf
Copy link
Copy Markdown
Member

Merged via squash.

Thanks @CryUshio!

frankekn pushed a commit to MoerAI/openclaw that referenced this pull request Mar 11, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
frankekn pushed a commit to Effet/openclaw that referenced this pull request Mar 11, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
frankekn pushed a commit to ImLukeF/openclaw that referenced this pull request Mar 11, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
Treedy2020 pushed a commit to Treedy2020/openclaw that referenced this pull request Mar 11, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
ahelpercn pushed a commit to ahelpercn/openclaw that referenced this pull request Mar 12, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
Ruijie-Ysp pushed a commit to Ruijie-Ysp/clawdbot that referenced this pull request Mar 12, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
leozhengliu-pixel pushed a commit to leozhengliu-pixel/openclaw that referenced this pull request Mar 13, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
Interstellar-code pushed a commit to Interstellar-code/operator1 that referenced this pull request Mar 16, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf

(cherry picked from commit 8bf64f2)
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
…penclaw#42278)

Merged via squash.

Prepared head SHA: f3cdfa7
Co-authored-by: CryUshio <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 402 "You've used up your points!" from Poe API not recognized as billing — model fallback does not trigger

2 participants