Repository navigation
Description
What is missing
The Kenari handler never sees caller cancellation or the configured request timeout. Evidence at main 75a93a9d9acc:
$ git grep -c -F abortSignal upstream/main -- src/api/providers/kenari.ts
(no hits)
$ git grep -n -F signal upstream/main -- src/api/providers/kenari.ts
src/api/providers/kenari.ts:61: async fetchModels(options: GetModelsOptions, signal?: AbortSignal): Promise<ModelRecord> {
src/api/providers/kenari.ts:62: const fetchOpts: [] | [{ signal: AbortSignal }] = signal ? [{ signal }] : []
createMessage(kenari.ts:70-134) awaitsthis.fetchModel()andawait this.client.chat.completions.create(body)(:96) with no request options, no race and no try/catch, sometadata.abortSignalis dropped on the floor.completePrompt(prompt, _options?)(kenari.ts:143) discards the wholeCompletePromptOptions(src/api/index.ts:61-63:abortSignal+timeoutMs); the request at:159is sent without options, and every failure - including a cancellation - is rewrapped asKenari completion error: <message>(:163), so a cancel surfaces as a plainErrorinstead ofname === "AbortError".fetchModelsdoes accept an optional signal (:61-64), but nothing in the handler ever passes one, andfetchers/kenari.tshas noabortSignalhandling either.
Why it matters
- Stop / cancel in a Kenari session does not stop the in-flight HTTP request: the stream keeps streaming until the provider answers.
- Task-level abort classification keys on
name === "AbortError"; a Kenari cancel arrives asError, so it is reported as a provider failure instead of a cancellation. - The request-timeout setting is inert for this provider, and the OpenAI SDK only attaches its own abort listener when it is handed a signal, so nothing is listening today.
- Kenari is listed under feat(api): abort signal pass-through for simple providers #616 (abort pass-through) and is the only OpenAI-SDK provider in that set with zero wiring: its siblings all use the shared helpers (
utils/abort-signal.ts,utils/request-timeout.ts) since feat(api): abort signal support for anthropic, anthropic-vertex, xai, minimax #1293 / feat(api): abort signal support for requesty (completePrompt + shared helpers) #1537 / feat(api): abort signal support for Zoo Gateway completePrompt #2430.
Planned fix
One PR, mirroring the merged contract in requesty.ts:265-346 and zoo-gateway.ts:309-397 - no helper API change and no new abstraction:
createMessage: resolve the model throughresolveModelWithAbort, pass the caller signal to the SDK as request options, and normalize an SDK abort intocreateAbortError("Kenari"); ordinary failures keep propagating unchanged.completePrompt:bridgeExternalAbortSignal(options?.abortSignal)so the SDK listener never lands on the caller's long-lived signal,mergeAbortSignalAndTimeoutto fold the timeout into that same per-request signal,resolveModelWithAbortfor the lookup,rejectOnAbortaround the completion (the SDK does not observe the signal while it sleeps between retries), drop a response that lands after the cancel, forwardhasUsableTimeout/toSdkTimeoutMsas the SDKtimeout, keep theKenari completion error:wrapping for non-abort failures, anddispose()the bridge infinally.- Keep the one-argument
create(...)call shape when neither cancellation nor a usable timeout is configured, so the existing request-shape assertions inkenari.spec.tsstay valid.
Budget (per the split discipline posted in #2486): a single unit at <= 400 a+d against its own base - the patch measures 398 a+d (provider 152+/37-, spec 246+), well inside the 500 changed-executable-line and 400-valid-mutant ceilings. The new cancellation branches are covered by 19 tests, each pinned by a negative control.
Out of scope: threading a signal through RouterProvider.fetchModel() (#2202), and the helper / createTimeoutError consolidation tracked as U0a/U0b in #2486.
Related: #616 (abort pass-through), #2202 (signal-aware model discovery), #2486 (abort-signal refactor umbrella).
Activity
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers
feat(api): cancel Kenari requests through the shared abort helpers