feat: add x402 payment retry logic and extend retryable status codes

Add retry loop (up to 3 attempts with exponential backoff) for 5xx
server errors on payment-signed x402 requests, reusing the same
payment signature to avoid double-charges. Also add 502/503/520/524
to the retryable error patterns in the MCP client.
This commit is contained in:
tinkle-community
2026-03-11 17:33:54 +08:00
parent 94ef009bb5
commit 6a30e11ee5
2 changed files with 67 additions and 22 deletions

View File

@@ -32,6 +32,10 @@ var (
"no such host",
"stream error", // HTTP/2 stream error
"INTERNAL_ERROR", // Server internal error
"status 502", // Bad Gateway
"status 503", // Service Unavailable
"status 520", // Cloudflare origin error
"status 524", // Cloudflare timeout
}
// TokenUsageCallback is called after each AI request with token usage info