mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 14:32:03 +00:00
fix(insights): cancel the Coach upstream provider call on client disconnect
The Coach SSE turn ran the provider call to completion before the stream existed and never wired it to the request's abort signal, so a mid-generation client disconnect still paid the full upstream token cost. Thread an optional `signal` through CompletionParams and singleUserTurn into each client's safeFetch (composed with the per-call timeout via AbortSignal.any), and pass `request.signal` from the chat route's no-tools path. An early disconnect now tears the upstream request down instead of generating into a closed connection. Omitting the signal leaves behaviour unchanged (timeout-only).
This commit is contained in:
1 parent
e1e1b0e985
commit
4c571b0e04
6 files changed
+32
-4
No files matched your search
@@ -567,6 +567,10 @@ Reply now as the assistant, in ${locale === "de" ? "German" : "English"}. Fetch
|
||||
user: userPrompt,
|
||||
temperature: AI_BUDGETS.coach.temperature,
|
||||
maxTokens: AI_BUDGETS.coach.maxTokens,
|
||||
// v1.20.1 — thread the request's abort signal so a mid-generation
|
||||
// client disconnect tears the upstream provider call down instead of
|
||||
// paying the full token cost into a closed connection.
|
||||
signal: request.signal,
|
||||
}),
|
||||
});
|
||||
result = fallback.result;
|
||||
|
||||
Reference in new issue
Block a user