fix: synchronization between executed tools and turn loops (#488)

This commit is contained in:
Brandon Keiji
2025-05-22 09:51:07 +00:00
committed by GitHub
parent 174fdce7d8
commit a8bfdf2d56
4 changed files with 53 additions and 93 deletions

View File

@@ -383,6 +383,7 @@ export const useGeminiStream = (
toolCallRequests.push(event.value);
} else if (event.type === ServerGeminiEventType.UserCancelled) {
handleUserCancelledEvent(userMessageTimestamp);
cancel();
return StreamProcessingStatus.UserCancelled;
} else if (event.type === ServerGeminiEventType.Error) {
handleErrorEvent(event.value, userMessageTimestamp);
@@ -393,12 +394,9 @@ export const useGeminiStream = (
return StreamProcessingStatus.Completed;
};
const streamingState: StreamingState = isResponding
? StreamingState.Responding
: pendingToolCalls?.tools.some(
(t) => t.status === ToolCallStatus.Confirming,
)
? StreamingState.WaitingForConfirmation
const streamingState: StreamingState =
isResponding || toolCalls.some((t) => t.status === 'awaiting_approval')
? StreamingState.Responding
: StreamingState.Idle;
const submitQuery = useCallback(