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