Skip to content

fix: handle wrapped x402 premium payment failures with safer fallback#34

Closed
tsubasakong wants to merge 1 commit into
BlockRunAI:mainfrom
tsubasakong:split/premium-payment-fallback
Closed

fix: handle wrapped x402 premium payment failures with safer fallback#34
tsubasakong wants to merge 1 commit into
BlockRunAI:mainfrom
tsubasakong:split/premium-payment-fallback

Conversation

@tsubasakong

Copy link
Copy Markdown

Summary

  • treat wrapped x402 merchant-proxy payment failures as provider errors that can fallback
  • improve session/profile fallback routing to avoid sticky premium routing after paid-model failure
  • add regression tests for wrapped x402 error fallback and profile re-routing

Test Plan

  • bun run test/premium-compat.ts
  • npm run typecheck

@VickyXAI

Copy link
Copy Markdown
Contributor

Thanks — closing the diff, but the underlying question is worth keeping.

Stale: main's setSession() 4th param is now userExplicit: boolean, not routingProfile, so this would pass a profile string into the explicit-pin slot. SessionEntry has since grown three-strike escalation and sessionCostMicros.

Also, one part I'd push back on regardless of age: adding /payment required/i and /merchant_status\"?\\s*:\\s*402/i to PROVIDER_ERROR_PATTERNS reclassifies "your wallet is out of money" as "the provider is flaky", and /payment required/i is broad enough to match model output text. Main deliberately separates these — it has dedicated invalid_payload and insufficient_funds branches with specific guidance — so this would mask real payment failures behind a silent reroute.

The bug you found may well still be live though: if a premium → eco profile switch still leaves a session pinned to the paid model, please open an issue with a repro and we'll fix it against the current session code.

@VickyXAI VickyXAI closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants