summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-08-21 16:49:12 -0700
committerGitHub <[email protected]>2025-08-21 23:49:12 +0000
commit15c62bade317495063c30248001694a743ad5159 (patch)
treea08014debf9100e86da2a1ab655e75915fe3355f /packages/cli/src
parent29699274bb0e8f70b9bedad40ca2d03739318853 (diff)
Reuse CoreToolScheduler for nonInteractiveToolExecutor (#6714)
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/nonInteractiveCli.ts28
-rw-r--r--packages/cli/src/ui/hooks/useReactToolScheduler.ts1
2 files changed, 6 insertions, 23 deletions
diff --git a/packages/cli/src/nonInteractiveCli.ts b/packages/cli/src/nonInteractiveCli.ts
index 36337c8f..d986c1eb 100644
--- a/packages/cli/src/nonInteractiveCli.ts
+++ b/packages/cli/src/nonInteractiveCli.ts
@@ -13,7 +13,7 @@ import {
GeminiEventType,
parseAndFormatApiError,
} from '@google/gemini-cli-core';
-import { Content, Part, FunctionCall } from '@google/genai';
+import { Content, Part } from '@google/genai';
import { ConsolePatcher } from './ui/utils/ConsolePatcher.js';
import { handleAtCommand } from './ui/hooks/atCommandProcessor.js';
@@ -74,7 +74,7 @@ export async function runNonInteractive(
);
return;
}
- const functionCalls: FunctionCall[] = [];
+ const toolCallRequests: ToolCallRequestInfo[] = [];
const responseStream = geminiClient.sendMessageStream(
currentMessages[0]?.parts || [],
@@ -91,29 +91,13 @@ export async function runNonInteractive(
if (event.type === GeminiEventType.Content) {
process.stdout.write(event.value);
} else if (event.type === GeminiEventType.ToolCallRequest) {
- const toolCallRequest = event.value;
- const fc: FunctionCall = {
- name: toolCallRequest.name,
- args: toolCallRequest.args,
- id: toolCallRequest.callId,
- };
- functionCalls.push(fc);
+ toolCallRequests.push(event.value);
}
}
- if (functionCalls.length > 0) {
+ if (toolCallRequests.length > 0) {
const toolResponseParts: Part[] = [];
-
- for (const fc of functionCalls) {
- const callId = fc.id ?? `${fc.name}-${Date.now()}`;
- const requestInfo: ToolCallRequestInfo = {
- callId,
- name: fc.name as string,
- args: (fc.args ?? {}) as Record<string, unknown>,
- isClientInitiated: false,
- prompt_id,
- };
-
+ for (const requestInfo of toolCallRequests) {
const toolResponse = await executeToolCall(
config,
requestInfo,
@@ -122,7 +106,7 @@ export async function runNonInteractive(
if (toolResponse.error) {
console.error(
- `Error executing tool ${fc.name}: ${toolResponse.resultDisplay || toolResponse.error.message}`,
+ `Error executing tool ${requestInfo.name}: ${toolResponse.resultDisplay || toolResponse.error.message}`,
);
}
diff --git a/packages/cli/src/ui/hooks/useReactToolScheduler.ts b/packages/cli/src/ui/hooks/useReactToolScheduler.ts
index 93e05387..e4238f99 100644
--- a/packages/cli/src/ui/hooks/useReactToolScheduler.ts
+++ b/packages/cli/src/ui/hooks/useReactToolScheduler.ts
@@ -134,7 +134,6 @@ export function useReactToolScheduler(
const scheduler = useMemo(
() =>
new CoreToolScheduler({
- toolRegistry: config.getToolRegistry(),
outputUpdateHandler,
onAllToolCallsComplete: allToolCallsCompleteHandler,
onToolCallsUpdate: toolCallsUpdateHandler,