mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 02:54:31 -07:00
fix(cli): ensure agent stops when all declinable tools are cancelled (#24479)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user