33 classifyHTTPError ,
44 classifyNetworkError ,
55 classifyProtocolMismatch ,
6- createDefaultRetryPolicy ,
76 type BuiltRequest ,
87 type Dependencies ,
98} from "@intx/inference" ;
@@ -43,28 +42,26 @@ export class EmbeddingRequestError extends Error {
4342export type RetryAfterExtractor = ( headers : Headers ) => number | undefined ;
4443
4544type RunRequestOptions = {
46- /** Defaults to Interchange's policy: back off retryables, abort the rest. */
47- retryPolicy : RetryPolicy | undefined ;
45+ retryPolicy : RetryPolicy ;
4846 /**
4947 * Per-attempt ceiling, enforced alongside any caller `signal` rather than
5048 * instead of it. A cold local model can take a while to page in.
5149 */
52- timeoutMs : number | undefined ;
50+ timeoutMs : number ;
5351 /**
5452 * Reads `Retry-After` off a failed response. Mirrors `ProviderAdapter`'s
5553 * member of the same name, so a provider that signals pacing its own way can
56- * override without touching the transport. Defaults to
57- * {@link extractRetryAfterMs}.
54+ * override without touching the transport.
5855 */
59- extractRetryAfterMs : RetryAfterExtractor | undefined ;
56+ extractRetryAfterMs : RetryAfterExtractor ;
6057 signal : AbortSignal | undefined ;
6158} ;
6259
6360type Attempt =
6461 | { ok : true ; body : unknown }
6562 | { ok : false ; error : InferenceError } ;
6663
67- const DEFAULT_TIMEOUT_MS = 30_000 ;
64+ export const DEFAULT_TIMEOUT_MS = 30_000 ;
6865
6966/**
7067 * `Retry-After` in seconds or as an HTTP date; undefined when absent.
@@ -77,7 +74,7 @@ const DEFAULT_TIMEOUT_MS = 30_000;
7774 * absolute instant, so it cannot be resolved against the harness scheduler's
7875 * virtual clock. Upstream's extractor has the same constraint.
7976 */
80- const extractRetryAfterMs : RetryAfterExtractor = ( headers ) => {
77+ export const extractRetryAfterMs : RetryAfterExtractor = ( headers ) => {
8178 const header = headers . get ( "retry-after" ) ?. trim ( ) ;
8279 if ( header === undefined || header === "" ) return undefined ;
8380
@@ -194,10 +191,8 @@ export async function runJSONRequest(
194191 deps : RequestDependencies ,
195192 options : RunRequestOptions ,
196193) : Promise < unknown > {
197- const { signal } = options ;
198- const policy = options . retryPolicy ?? createDefaultRetryPolicy ( ) ;
199- const timeoutMs = options . timeoutMs ?? DEFAULT_TIMEOUT_MS ;
200- const extractRetryAfter = options . extractRetryAfterMs ?? extractRetryAfterMs ;
194+ const { retryPolicy : policy , timeoutMs, signal } = options ;
195+ const extractRetryAfter = options . extractRetryAfterMs ;
201196
202197 // Time comes from the harness scheduler, not globals, so a virtual-clock
203198 // test scheduler drives the retry loop deterministically.
0 commit comments