33 classifyHTTPError ,
44 classifyNetworkError ,
55 classifyProtocolMismatch ,
6- createDefaultRetryPolicy ,
76 type BuiltRequest ,
87 type Dependencies ,
98} from "@intx/inference" ;
@@ -54,28 +53,26 @@ export class EmbeddingRequestError extends Error {
5453export type RetryAfterExtractor = ( headers : Headers ) => number | undefined ;
5554
5655type RunRequestOptions = {
57- /** Defaults to Interchange's policy: back off retryables, abort the rest. */
58- retryPolicy : RetryPolicy | undefined ;
56+ retryPolicy : RetryPolicy ;
5957 /**
6058 * Per-attempt ceiling, enforced alongside any caller `signal` rather than
6159 * instead of it. A cold local model can take a while to page in.
6260 */
63- timeoutMs : number | undefined ;
61+ timeoutMs : number ;
6462 /**
6563 * Reads `Retry-After` off a failed response. Mirrors `ProviderAdapter`'s
6664 * member of the same name, so a provider that signals pacing its own way can
67- * override without touching the transport. Defaults to
68- * {@link extractRetryAfterMs}.
65+ * override without touching the transport.
6966 */
70- extractRetryAfterMs : RetryAfterExtractor | undefined ;
67+ extractRetryAfterMs : RetryAfterExtractor ;
7168 signal : AbortSignal | undefined ;
7269} ;
7370
7471type Attempt =
7572 | { ok : true ; body : unknown }
7673 | { ok : false ; error : InferenceError } ;
7774
78- const DEFAULT_TIMEOUT_MS = 30_000 ;
75+ export const DEFAULT_TIMEOUT_MS = 30_000 ;
7976
8077/**
8178 * `Retry-After` in seconds or as an HTTP date; undefined when absent.
@@ -88,7 +85,7 @@ const DEFAULT_TIMEOUT_MS = 30_000;
8885 * absolute instant, so it cannot be resolved against the harness scheduler's
8986 * virtual clock. Upstream's extractor has the same constraint.
9087 */
91- const extractRetryAfterMs : RetryAfterExtractor = ( headers ) => {
88+ export const extractRetryAfterMs : RetryAfterExtractor = ( headers ) => {
9289 const header = headers . get ( "retry-after" ) ?. trim ( ) ;
9390 if ( header === undefined || header === "" ) return undefined ;
9491
@@ -195,10 +192,8 @@ export async function runJSONRequest(
195192 deps : RequestDependencies ,
196193 options : RunRequestOptions ,
197194) : Promise < unknown > {
198- const { signal } = options ;
199- const policy = options . retryPolicy ?? createDefaultRetryPolicy ( ) ;
200- const timeoutMs = options . timeoutMs ?? DEFAULT_TIMEOUT_MS ;
201- const extractRetryAfter = options . extractRetryAfterMs ?? extractRetryAfterMs ;
195+ const { retryPolicy : policy , timeoutMs, signal } = options ;
196+ const extractRetryAfter = options . extractRetryAfterMs ;
202197
203198 // Time comes from the harness scheduler, not globals, so a virtual-clock
204199 // test scheduler drives the retry loop deterministically.
0 commit comments