mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 16:34:31 -07:00
Fix bug where tool scheduler was repeatedly created. (#11767)
This commit is contained in:
@@ -10,7 +10,6 @@ import type {
|
||||
ToolCallConfirmationDetails,
|
||||
ToolResult,
|
||||
ToolResultDisplay,
|
||||
ToolRegistry,
|
||||
EditorType,
|
||||
Config,
|
||||
ToolConfirmationPayload,
|
||||
@@ -332,7 +331,6 @@ interface CoreToolSchedulerOptions {
|
||||
}
|
||||
|
||||
export class CoreToolScheduler {
|
||||
private toolRegistry: ToolRegistry;
|
||||
private toolCalls: ToolCall[] = [];
|
||||
private outputUpdateHandler?: OutputUpdateHandler;
|
||||
private onAllToolCallsComplete?: AllToolCallsCompleteHandler;
|
||||
@@ -351,7 +349,6 @@ export class CoreToolScheduler {
|
||||
|
||||
constructor(options: CoreToolSchedulerOptions) {
|
||||
this.config = options.config;
|
||||
this.toolRegistry = options.config.getToolRegistry();
|
||||
this.outputUpdateHandler = options.outputUpdateHandler;
|
||||
this.onAllToolCallsComplete = options.onAllToolCallsComplete;
|
||||
this.onToolCallsUpdate = options.onToolCallsUpdate;
|
||||
@@ -603,7 +600,7 @@ export class CoreToolScheduler {
|
||||
* @returns A suggestion string like " Did you mean 'tool'?" or " Did you mean one of: 'tool1', 'tool2'?", or an empty string if no suggestions are found.
|
||||
*/
|
||||
private getToolSuggestion(unknownToolName: string, topN = 3): string {
|
||||
const allToolNames = this.toolRegistry.getAllToolNames();
|
||||
const allToolNames = this.config.getToolRegistry().getAllToolNames();
|
||||
|
||||
const matches = allToolNames.map((toolName) => ({
|
||||
name: toolName,
|
||||
@@ -680,7 +677,9 @@ export class CoreToolScheduler {
|
||||
|
||||
const newToolCalls: ToolCall[] = requestsToProcess.map(
|
||||
(reqInfo): ToolCall => {
|
||||
const toolInstance = this.toolRegistry.getTool(reqInfo.name);
|
||||
const toolInstance = this.config
|
||||
.getToolRegistry()
|
||||
.getTool(reqInfo.name);
|
||||
if (!toolInstance) {
|
||||
const suggestion = this.getToolSuggestion(reqInfo.name);
|
||||
const errorMessage = `Tool "${reqInfo.name}" not found in registry. Tools must use the exact names that are registered.${suggestion}`;
|
||||
|
||||
Reference in New Issue
Block a user