|
3 | 3 | classifyHTTPError, |
4 | 4 | classifyNetworkError, |
5 | 5 | classifyProtocolMismatch, |
6 | | - createDefaultRetryPolicy, |
7 | 6 | type BuiltRequest, |
8 | 7 | type Dependencies, |
9 | 8 | } from "@intx/inference"; |
@@ -59,29 +58,25 @@ export type RetryAfterExtractor = (headers: Headers) => number | undefined; |
59 | 58 |
|
60 | 59 | export type RunRequestOptions = { |
61 | 60 | deps: RequestDependencies; |
62 | | - /** Defaults to Interchange's policy: back off retryables, abort the rest. */ |
63 | | - retryPolicy: RetryPolicy | undefined; |
| 61 | + retryPolicy: RetryPolicy; |
64 | 62 | /** |
65 | 63 | * Per-attempt ceiling, enforced alongside any caller `signal` rather than |
66 | 64 | * instead of it. A cold local model can take a while to page in. |
67 | 65 | */ |
68 | | - timeoutMs: number | undefined; |
| 66 | + timeoutMs: number; |
69 | 67 | /** |
70 | 68 | * Reads `Retry-After` off a failed response. Mirrors `ProviderAdapter`'s |
71 | 69 | * member of the same name, so a provider that signals pacing its own way can |
72 | | - * override without touching the transport. Defaults to |
73 | | - * {@link extractRetryAfterMs}. |
| 70 | + * override without touching the transport. |
74 | 71 | */ |
75 | | - extractRetryAfterMs: RetryAfterExtractor | undefined; |
| 72 | + extractRetryAfterMs: RetryAfterExtractor; |
76 | 73 | signal: AbortSignal | undefined; |
77 | 74 | }; |
78 | 75 |
|
79 | 76 | type Attempt = |
80 | 77 | | { ok: true; body: unknown } |
81 | 78 | | { ok: false; error: InferenceError }; |
82 | 79 |
|
83 | | -const DEFAULT_TIMEOUT_MS = 30_000; |
84 | | - |
85 | 80 | /** |
86 | 81 | * `Retry-After` in seconds or as an HTTP date; undefined when absent. |
87 | 82 | * |
@@ -199,10 +194,13 @@ export async function runJSONRequest( |
199 | 194 | request: BuiltRequest, |
200 | 195 | options: RunRequestOptions, |
201 | 196 | ): Promise<unknown> { |
202 | | - const { deps, signal } = options; |
203 | | - const policy = options.retryPolicy ?? createDefaultRetryPolicy(); |
204 | | - const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS; |
205 | | - const extractRetryAfter = options.extractRetryAfterMs ?? extractRetryAfterMs; |
| 197 | + const { |
| 198 | + deps, |
| 199 | + signal, |
| 200 | + retryPolicy: policy, |
| 201 | + timeoutMs, |
| 202 | + extractRetryAfterMs: extractRetryAfter, |
| 203 | + } = options; |
206 | 204 |
|
207 | 205 | // Time comes from the harness scheduler, not globals, so a virtual-clock |
208 | 206 | // test scheduler drives the retry loop deterministically. |
|
0 commit comments