mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com> Co-authored-by: Sandy Tao <sandytao520@icloud.com>
This commit is contained in:
@@ -923,21 +923,36 @@ export class CoreToolScheduler {
|
|||||||
this._cancelAllQueuedCalls();
|
this._cancelAllQueuedCalls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we are already finalizing, another concurrent call to
|
||||||
|
// checkAndNotifyCompletion will just return. The ongoing finalized loop
|
||||||
|
// will pick up any new tools added to completedToolCallsForBatch.
|
||||||
|
if (this.isFinalizingToolCalls) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If there's nothing to report and we weren't cancelled, we can stop.
|
// If there's nothing to report and we weren't cancelled, we can stop.
|
||||||
// But if we were cancelled, we must proceed to potentially start the next queued request.
|
// But if we were cancelled, we must proceed to potentially start the next queued request.
|
||||||
if (this.completedToolCallsForBatch.length === 0 && !signal.aborted) {
|
if (this.completedToolCallsForBatch.length === 0 && !signal.aborted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.onAllToolCallsComplete) {
|
this.isFinalizingToolCalls = true;
|
||||||
this.isFinalizingToolCalls = true;
|
try {
|
||||||
// Use the batch array, not the (now empty) active array.
|
// We use a while loop here to ensure that if new tools are added to the
|
||||||
await this.onAllToolCallsComplete(this.completedToolCallsForBatch);
|
// batch (e.g., via cancellation) while we are awaiting
|
||||||
this.completedToolCallsForBatch = []; // Clear after reporting.
|
// onAllToolCallsComplete, they are also reported before we finish.
|
||||||
|
while (this.completedToolCallsForBatch.length > 0) {
|
||||||
|
const batchToReport = [...this.completedToolCallsForBatch];
|
||||||
|
this.completedToolCallsForBatch = [];
|
||||||
|
if (this.onAllToolCallsComplete) {
|
||||||
|
await this.onAllToolCallsComplete(batchToReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
this.isFinalizingToolCalls = false;
|
this.isFinalizingToolCalls = false;
|
||||||
|
this.isCancelling = false;
|
||||||
|
this.notifyToolCallsUpdate();
|
||||||
}
|
}
|
||||||
this.isCancelling = false;
|
|
||||||
this.notifyToolCallsUpdate();
|
|
||||||
|
|
||||||
// After completion of the entire batch, process the next item in the main request queue.
|
// After completion of the entire batch, process the next item in the main request queue.
|
||||||
if (this.requestQueue.length > 0) {
|
if (this.requestQueue.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user