fix(cli): ensure agent stops when all declinable tools are cancelled (#24479)

This commit is contained in:
N. Taylor Mullen
2026-04-01 16:16:34 -07:00
committed by GitHub
parent cb7f7d6c72
commit ca78a0f177
2 changed files with 134 additions and 7 deletions
+12 -3
View File
@@ -1968,11 +1968,20 @@ export const useGeminiStream = (
}
// If all the tools were cancelled, don't submit a response to Gemini.
const allToolsCancelled = geminiTools.every(
(tc) => tc.status === CoreToolCallStatus.Cancelled,
// Note: we ignore the topic tool because the user doesn't have a chance to decline it.
const declinableTools = geminiTools.filter(
(tc) => !isTopicTool(tc.request.name),
);
const allDeclinableToolsCancelled =
declinableTools.length > 0 &&
declinableTools.every(
(tc) => tc.status === CoreToolCallStatus.Cancelled,
);
const allToolsCancelled =
geminiTools.length > 0 &&
geminiTools.every((tc) => tc.status === CoreToolCallStatus.Cancelled);
if (allToolsCancelled) {
if (allDeclinableToolsCancelled || allToolsCancelled) {
// If the turn was cancelled via the imperative escape key flow,
// the cancellation message is added there. We check the ref to avoid duplication.
if (!turnCancelledRef.current) {