File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
worker/src/lib/ai-gateway Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -403,7 +403,22 @@ export class AttemptExecutor {
403403 : null ;
404404
405405 const providerStartTime = Date . now ( ) ;
406- const response = await forwarder ( urlResult . data , escrowInfo ) ;
406+
407+ // Retry logic for PTB Helicone provider 502 errors
408+ let response ! : Response ;
409+ const maxRetries =
410+ endpoint . provider === "helicone" && endpoint . ptbEnabled ? 2 : 0 ;
411+
412+ for ( let attempt = 0 ; attempt <= maxRetries ; attempt ++ ) {
413+ response = await forwarder ( urlResult . data , escrowInfo ) ;
414+
415+ // Only retry on 502 for Helicone PTB requests (no delay between retries)
416+ if ( response . status === 502 && attempt < maxRetries ) {
417+ continue ;
418+ }
419+ break ;
420+ }
421+
407422 const providerLatency = Date . now ( ) - providerStartTime ;
408423
409424 metrics . markProviderEnd ( response . status ) ;
You can’t perform that action at this time.
0 commit comments