Fix race condition by awaiting scheduleToolCalls (#16759)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
christine betts
2026-01-16 11:55:15 -05:00
committed by GitHub
parent a15978593a
commit cfdc4cfca8
3 changed files with 86 additions and 52 deletions
@@ -32,7 +32,7 @@ import { ToolCallStatus } from '../types.js';
export type ScheduleFn = (
request: ToolCallRequestInfo | ToolCallRequestInfo[],
signal: AbortSignal,
) => void;
) => Promise<void>;
export type MarkToolsAsSubmittedFn = (callIds: string[]) => void;
export type TrackedScheduledToolCall = ScheduledToolCall & {
@@ -181,7 +181,7 @@ export function useReactToolScheduler(
signal: AbortSignal,
) => {
setToolCallsForDisplay([]);
void scheduler.schedule(request, signal);
return scheduler.schedule(request, signal);
},
[scheduler, setToolCallsForDisplay],
);