diff options
| author | Brandon Keiji <[email protected]> | 2025-05-22 10:02:45 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-22 03:02:45 -0700 |
| commit | fb1d13d600645e51db493644e63736e18872b0e4 (patch) | |
| tree | e897c9f6aeb2c98359dddc384ecdb476d62074e0 /packages/cli/src/ui/hooks/useToolScheduler.ts | |
| parent | a8bfdf2d5603e9e2fb01e12d6c5499662dccaa85 (diff) | |
fix: cancel parallel tool calls mid-execution (#489)
Diffstat (limited to 'packages/cli/src/ui/hooks/useToolScheduler.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useToolScheduler.ts | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/packages/cli/src/ui/hooks/useToolScheduler.ts b/packages/cli/src/ui/hooks/useToolScheduler.ts index e14241b6..8bcc0ae9 100644 --- a/packages/cli/src/ui/hooks/useToolScheduler.ts +++ b/packages/cli/src/ui/hooks/useToolScheduler.ts @@ -185,12 +185,19 @@ export function useToolScheduler( useEffect(() => { // effect for executing scheduled tool calls if (toolCalls.every((t) => t.status === 'scheduled')) { + const signal = abortController.signal; toolCalls.forEach((c) => { const callId = c.request.callId; setToolCalls(setStatus(c.request.callId, 'executing')); c.tool - .execute(c.request.args, abortController.signal) + .execute(c.request.args, signal) .then((result) => { + if (signal.aborted) { + setToolCalls( + setStatus(callId, 'cancelled', 'Cancelled during execution'), + ); + return; + } const functionResponse: Part = { functionResponse: { name: c.request.name, |
