mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
fix(insights): cancel the Coach tool-loop provider calls on disconnect
Thread the request abort signal through runCoachToolLoop into each per-round completion so a mid-generation client disconnect tears down the upstream call instead of paying the full token cost. Completes the no-tools-path wiring to cover the tool-retrieval path as well. Regenerate the OpenAPI spec for the trimmed OCR-capability reason enum.
This commit is contained in:
1 parent
ca1cf53d2c
commit
bf29ab1e0e
3 files changed
+7
-1
No files matched your search
@@ -58,6 +58,8 @@ export async function runCoachToolLoop(args: {
|
||||
maxTokens?: number;
|
||||
fallbackWindow?: CoachScopeWindow;
|
||||
ledger?: ProviderHealthLedger;
|
||||
/** Aborts the per-round provider calls on client disconnect. */
|
||||
signal?: AbortSignal;
|
||||
}): Promise<CoachToolLoopResult> {
|
||||
const {
|
||||
userId,
|
||||
@@ -68,6 +70,7 @@ export async function runCoachToolLoop(args: {
|
||||
maxTokens,
|
||||
fallbackWindow,
|
||||
ledger,
|
||||
signal,
|
||||
} = args;
|
||||
|
||||
const messages: AiMessage[] = [...args.messages];
|
||||
@@ -92,6 +95,7 @@ export async function runCoachToolLoop(args: {
|
||||
messages,
|
||||
temperature,
|
||||
maxTokens,
|
||||
signal,
|
||||
...(offerTools
|
||||
? { tools, toolChoice: "auto" as const }
|
||||
: { toolChoice: "none" as const }),
|
||||
|
||||
Reference in new issue
Block a user