From c7866e6a9212d622fed0712240701fe17b9534c0 Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Wed, 25 Feb 2026 13:44:16 -0800 Subject: [PATCH] feat(sdk): implement runtime hooks support in GeminiCliAgent - Introduced a new Hook type and hook() helper for strongly-typed SDK hooks. - Integrated runtime hooks into GeminiCliSession lifecycle (startup, close, and tool execution). - Added hooks option to GeminiCliAgentOptions. - Exported executeToolWithHooks from core to facilitate SDK integration. - Updated SDK_DESIGN.md to reflect implemented features and remaining tasks. - Added and re-recorded SDK integration tests for hooks. --- packages/core/src/index.ts | 1 + packages/sdk/SDK_DESIGN.md | 31 +- packages/sdk/src/hook.integration.test.ts | 322 ++++++++++++++++++ packages/sdk/src/hook.ts | 109 ++++++ packages/sdk/src/index.ts | 1 + packages/sdk/src/session.ts | 93 +++-- packages/sdk/src/types.ts | 2 + .../test-data/agent-dynamic-instructions.json | 6 - .../sdk/test-data/agent-resume-session.json | 12 +- .../test-data/agent-static-instructions.json | 10 +- packages/sdk/test-data/hook-agent-test.json | 4 + packages/sdk/test-data/hook-model-test.json | 11 + packages/sdk/test-data/hook-tool-test.json | 10 + packages/sdk/test-data/skill-dir-success.json | 8 +- .../sdk/test-data/skill-root-success.json | 6 - .../test-data/skills/pirate-skill/SKILL.md | 2 +- .../sdk/test-data/tool-catchall-error.json | 6 - .../sdk/test-data/tool-error-recovery.json | 6 - packages/sdk/test-data/tool-success.json | 6 - 19 files changed, 564 insertions(+), 82 deletions(-) create mode 100644 packages/sdk/src/hook.integration.test.ts create mode 100644 packages/sdk/src/hook.ts create mode 100644 packages/sdk/test-data/hook-agent-test.json create mode 100644 packages/sdk/test-data/hook-model-test.json create mode 100644 packages/sdk/test-data/hook-tool-test.json diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index b0f2c1d8cd..64a89961f8 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -40,6 +40,7 @@ export * from './core/tokenLimits.js'; export * from './core/turn.js'; export * from './core/geminiRequest.js'; export * from './core/coreToolScheduler.js'; +export * from './core/coreToolHookTriggers.js'; export * from './scheduler/scheduler.js'; export * from './scheduler/types.js'; export * from './scheduler/tool-executor.js'; diff --git a/packages/sdk/SDK_DESIGN.md b/packages/sdk/SDK_DESIGN.md index d3031f32b8..aac9cff870 100644 --- a/packages/sdk/SDK_DESIGN.md +++ b/packages/sdk/SDK_DESIGN.md @@ -1,8 +1,8 @@ # `Gemini CLI SDK` -> **Implementation Status:** Core agent loop, tool execution, and session -> context are implemented. Advanced features like hooks, skills, subagents, and -> ACP are currently missing. +> **Implementation Status:** Core agent loop, tool execution, session context, +> skills, and hooks are implemented. Advanced features like subagents and ACP +> are currently missing. # `Examples` @@ -91,7 +91,8 @@ Validation: ## `Custom Hooks` -> **Status:** Not Implemented. +> **Status:** Implemented. `hook()` helper and `GeminiCliAgent` support custom +> hook definitions and execution. SDK users can provide programmatic custom hooks @@ -125,6 +126,9 @@ const myHook = hook( ); ``` +> **Note:** The `runAsCommand` functionality for standalone script execution is +> currently **Not Implemented**. + SDK Hooks can also run as standalone scripts to implement userland "command" style hooks: @@ -295,7 +299,8 @@ export interface AgentShell { stdout: string; stderr: string; }>; - start(cmd: string, options?: AgentShellOptions): AgentShellProcess; + // TODO: start method is not yet implemented + // start(cmd: string, options?: AgentShellOptions): AgentShellProcess; } export interface AgentShellOptions { @@ -325,16 +330,14 @@ export interface AgentShellProcess { Based on the current implementation status, we can proceed with: -## Feature 3: Custom Hooks Support +## Feature 4: Subagents Support -Implement support for loading and registering custom hooks. This involves adding -a `hooks` option to `GeminiCliAgentOptions`. +Implement support for subagents, allowing an agent to delegate tasks to other +specialized agents. **Tasks:** -1. Define `Hook` interface and helper functions. -2. Add `hooks` option to `GeminiCliAgentOptions`. -3. Implement hook registration logic in `GeminiCliAgent`. - -IMPORTANT: Hook signatures should be strongly typed all the way through. You'll -need to create a mapping of the string event name to the request/response types. +1. Define `Subagent` interface. +2. Implement subagent registration and routing in `GeminiCliAgent`. +3. Support both simple prompt-based subagents and full `GeminiCliAgent` + instances as subagents. diff --git a/packages/sdk/src/hook.integration.test.ts b/packages/sdk/src/hook.integration.test.ts new file mode 100644 index 0000000000..640d0a90a2 --- /dev/null +++ b/packages/sdk/src/hook.integration.test.ts @@ -0,0 +1,322 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, vi } from 'vitest'; +import { GeminiCliAgent } from './agent.js'; +import { hook, type EventInputMap, type EventOutputMap } from './hook.js'; +import { HookEventName, SessionEndReason } from '@google/gemini-cli-core'; +import { tool } from './tool.js'; +import type { SessionContext } from './types.js'; +import { z } from 'zod'; +import * as path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const getGoldenPath = (name: string) => + path.resolve(__dirname, '../test-data', `${name}.json`); + +// Set this to true locally when you need to update snapshots +const RECORD_MODE = process.env['RECORD_NEW_RESPONSES'] === 'true'; + +describe('GeminiCliAgent Hook Integration', () => { + it('executes BeforeTool and AfterTool hooks', async () => { + const goldenFile = getGoldenPath('hook-tool-test'); + + const beforeAction = vi + .fn< + ( + input: EventInputMap[HookEventName.BeforeTool], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + + const afterAction = vi + .fn< + ( + input: EventInputMap[HookEventName.AfterTool], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue({ + hookSpecificOutput: { + hookEventName: 'AfterTool', + additionalContext: 'Hook added this context', + }, + }); + + const agent = new GeminiCliAgent({ + instructions: 'You are a helpful assistant.', + model: RECORD_MODE ? 'gemini-3-flash-preview' : undefined, + recordResponses: RECORD_MODE ? goldenFile : undefined, + fakeResponses: RECORD_MODE ? undefined : goldenFile, + tools: [ + tool( + { + name: 'add', + description: 'Adds two numbers', + inputSchema: z.object({ a: z.number(), b: z.number() }), + }, + async ({ a, b }) => a + b, + ), + ], + hooks: [ + hook( + { event: HookEventName.BeforeTool, name: 'before', matcher: 'add' }, + beforeAction, + ), + hook( + { event: HookEventName.AfterTool, name: 'after', matcher: 'add' }, + afterAction, + ), + ], + }); + + const stream = agent.session().sendStream('What is 5 + 3?'); + for await (const _ of stream) { + // consume stream + } + + expect(beforeAction).toHaveBeenCalled(); + expect(afterAction).toHaveBeenCalled(); + + const beforeInput = beforeAction.mock.calls[0][0]; + expect(beforeInput.tool_name).toBe('add'); + expect(beforeInput.tool_input).toEqual({ a: 5, b: 3 }); + + const afterInput = afterAction.mock.calls[0][0]; + expect(afterInput.tool_name).toBe('add'); + expect(afterInput.tool_response).toEqual({ + llmContent: '8', + returnDisplay: '8', + error: undefined, + }); + + const context = afterAction.mock.calls[0][1]; + expect(context.sessionId).toBeDefined(); + expect(context.fs).toBeDefined(); + expect(context.shell).toBeDefined(); + }, 10000); + + it('executes BeforeAgent and AfterAgent hooks', async () => { + const goldenFile = getGoldenPath('hook-agent-test'); + + const beforeAgentAction = vi + .fn< + ( + input: EventInputMap[HookEventName.BeforeAgent], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + + const afterAgentAction = vi + .fn< + ( + input: EventInputMap[HookEventName.AfterAgent], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + + const agent = new GeminiCliAgent({ + instructions: 'You are a helpful assistant.', + model: RECORD_MODE ? 'gemini-3-flash-preview' : undefined, + recordResponses: RECORD_MODE ? goldenFile : undefined, + fakeResponses: RECORD_MODE ? undefined : goldenFile, + hooks: [ + hook( + { event: HookEventName.BeforeAgent, name: 'beforeAgent' }, + beforeAgentAction, + ), + hook( + { event: HookEventName.AfterAgent, name: 'afterAgent' }, + afterAgentAction, + ), + ], + }); + + const stream = agent.session().sendStream('hi'); + for await (const _ of stream) { + /* consume */ + } + + expect(beforeAgentAction).toHaveBeenCalled(); + expect(afterAgentAction).toHaveBeenCalled(); + }); + + it('executes BeforeModel, AfterModel, and BeforeToolSelection hooks', async () => { + const goldenFile = getGoldenPath('hook-model-test'); + + const beforeModelAction = vi + .fn< + ( + input: EventInputMap[HookEventName.BeforeModel], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + + const afterModelAction = vi + .fn< + ( + input: EventInputMap[HookEventName.AfterModel], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + + const beforeToolSelectionAction = vi + .fn< + ( + input: EventInputMap[HookEventName.BeforeToolSelection], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + + const agent = new GeminiCliAgent({ + instructions: 'You are a helpful assistant.', + model: RECORD_MODE ? 'gemini-3-flash-preview' : undefined, + recordResponses: RECORD_MODE ? goldenFile : undefined, + fakeResponses: RECORD_MODE ? undefined : goldenFile, + tools: [ + tool( + { + name: 'add', + description: 'Adds two numbers', + inputSchema: z.object({ a: z.number(), b: z.number() }), + }, + async ({ a, b }) => a + b, + ), + ], + hooks: [ + hook( + { event: HookEventName.BeforeModel, name: 'beforeModel' }, + beforeModelAction, + ), + hook( + { event: HookEventName.AfterModel, name: 'afterModel' }, + afterModelAction, + ), + hook( + { + event: HookEventName.BeforeToolSelection, + name: 'beforeToolSelection', + }, + beforeToolSelectionAction, + ), + ], + }); + + const stream = agent.session().sendStream('What is 5 + 3?'); + for await (const _ of stream) { + /* consume */ + } + + expect(beforeModelAction).toHaveBeenCalled(); + expect(afterModelAction).toHaveBeenCalled(); + expect(beforeToolSelectionAction).toHaveBeenCalled(); + }); + + it('executes SessionStart and SessionEnd hooks', async () => { + const goldenFile = getGoldenPath('hook-agent-test'); + const sessionStartAction = vi + .fn< + ( + input: EventInputMap[HookEventName.SessionStart], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + const sessionEndAction = vi + .fn< + ( + input: EventInputMap[HookEventName.SessionEnd], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + + const agent = new GeminiCliAgent({ + instructions: 'You are a helpful assistant.', + fakeResponses: goldenFile, + hooks: [ + hook( + { event: HookEventName.SessionStart, name: 'sessionStart' }, + sessionStartAction, + ), + hook( + { event: HookEventName.SessionEnd, name: 'sessionEnd' }, + sessionEndAction, + ), + ], + }); + + const session = agent.session(); + await session.initialize(); + + expect(sessionStartAction).toHaveBeenCalled(); + + await session.close(SessionEndReason.Exit); + expect(sessionEndAction).toHaveBeenCalled(); + }); + + it('executes Notification and PreCompress hooks when triggered', async () => { + const goldenFile = getGoldenPath('hook-agent-test'); + const notificationAction = vi + .fn< + ( + input: EventInputMap[HookEventName.Notification], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + const preCompressAction = vi + .fn< + ( + input: EventInputMap[HookEventName.PreCompress], + context: SessionContext, + ) => Promise + >() + .mockResolvedValue(undefined); + + const agent = new GeminiCliAgent({ + instructions: 'You are a helpful assistant.', + fakeResponses: goldenFile, + hooks: [ + hook( + { event: HookEventName.Notification, name: 'notification' }, + notificationAction, + ), + hook( + { event: HookEventName.PreCompress, name: 'preCompress' }, + preCompressAction, + ), + ], + }); + + const session = agent.session(); + await session.initialize(); + + // Reaching into private state for testing purposes to trigger events that are hard to hit naturally + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const hookSystem = (session as any).config.getHookSystem(); + + // Trigger notification via fireToolNotificationEvent + await hookSystem.fireToolNotificationEvent({ + title: 'Permission', + message: 'Allow tool?', + }); + expect(notificationAction).toHaveBeenCalled(); + + await hookSystem.firePreCompressEvent('Manual'); + expect(preCompressAction).toHaveBeenCalled(); + }); +}); diff --git a/packages/sdk/src/hook.ts b/packages/sdk/src/hook.ts new file mode 100644 index 0000000000..a17406b78b --- /dev/null +++ b/packages/sdk/src/hook.ts @@ -0,0 +1,109 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import type { + HookEventName, + HookOutput, + BeforeToolInput, + AfterToolInput, + BeforeAgentInput, + AfterAgentInput, + BeforeModelInput, + BeforeModelOutput, + AfterModelInput, + AfterModelOutput, + BeforeToolSelectionInput, + BeforeToolSelectionOutput, + NotificationInput, + SessionStartInput, + SessionEndInput, + PreCompressInput, + BeforeToolOutput, + AfterToolOutput, + BeforeAgentOutput, + AfterAgentOutput, + NotificationOutput, + SessionStartOutput, + PreCompressOutput, +} from '@google/gemini-cli-core'; +import type { SessionContext } from './types.js'; + +/** + * Map of hook event names to their corresponding input types. + */ +export interface EventInputMap { + [HookEventName.BeforeTool]: BeforeToolInput; + [HookEventName.AfterTool]: AfterToolInput; + [HookEventName.BeforeAgent]: BeforeAgentInput; + [HookEventName.AfterAgent]: AfterAgentInput; + [HookEventName.BeforeModel]: BeforeModelInput; + [HookEventName.AfterModel]: AfterModelInput; + [HookEventName.BeforeToolSelection]: BeforeToolSelectionInput; + [HookEventName.Notification]: NotificationInput; + [HookEventName.SessionStart]: SessionStartInput; + [HookEventName.SessionEnd]: SessionEndInput; + [HookEventName.PreCompress]: PreCompressInput; +} + +/** + * Map of hook event names to their corresponding output types. + */ +export interface EventOutputMap { + [HookEventName.BeforeTool]: BeforeToolOutput; + [HookEventName.AfterTool]: AfterToolOutput; + [HookEventName.BeforeAgent]: BeforeAgentOutput; + [HookEventName.AfterAgent]: AfterAgentOutput; + [HookEventName.BeforeModel]: BeforeModelOutput; + [HookEventName.AfterModel]: AfterModelOutput; + [HookEventName.BeforeToolSelection]: BeforeToolSelectionOutput; + [HookEventName.Notification]: NotificationOutput; + [HookEventName.SessionStart]: SessionStartOutput; + [HookEventName.SessionEnd]: HookOutput; + [HookEventName.PreCompress]: PreCompressOutput; +} + +/** + * Definition of an SDK hook. + * Uses a mapped type to create a discriminated union of all possible hooks. + */ +export type Hook = { + [K in HookEventName]: { + event: K; + name: string; + matcher?: string; + sequential?: boolean; + action: ( + input: EventInputMap[K], + context: SessionContext, + ) => Promise; + }; +}[HookEventName]; + +/** + * Helper function to create a strongly-typed SDK hook. + * + * @param config Hook configuration including event name and optional matcher. + * @param action The function to execute when the hook event occurs. + * @returns A Hook object that can be passed to GeminiCliAgent. + */ +export function hook( + config: { + event: T; + name: string; + matcher?: string; + sequential?: boolean; + }, + action: ( + input: EventInputMap[T], + context: SessionContext, + ) => Promise, +): Hook { + // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion + return { + ...config, + action, + } as unknown as Hook; +} diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 91e7a080f0..8154c59e71 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -7,5 +7,6 @@ export * from './agent.js'; export * from './session.js'; export * from './tool.js'; +export * from './hook.js'; export * from './skills.js'; export * from './types.js'; diff --git a/packages/sdk/src/session.ts b/packages/sdk/src/session.ts index 8332ef29d0..8849688b16 100644 --- a/packages/sdk/src/session.ts +++ b/packages/sdk/src/session.ts @@ -21,6 +21,9 @@ import { ActivateSkillTool, type ResumedSessionData, PolicyDecision, + HookType, + SessionStartSource, + SessionEndReason, } from '@google/gemini-cli-core'; import { type Tool, SdkTool } from './tool.js'; @@ -32,12 +35,14 @@ import type { SystemInstructions, } from './types.js'; import type { SkillReference } from './skills.js'; +import type { Hook } from './hook.js'; import type { GeminiCliAgent } from './agent.js'; export class GeminiCliSession { private readonly config: Config; // eslint-disable-next-line @typescript-eslint/no-explicit-any private readonly tools: Array>; + private readonly hooks: Hook[]; private readonly skillRefs: SkillReference[]; private readonly instructions: SystemInstructions | undefined; private client: GeminiClient | undefined; @@ -52,6 +57,7 @@ export class GeminiCliSession { this.instructions = options.instructions; const cwd = options.cwd || process.cwd(); this.tools = options.tools || []; + this.hooks = options.hooks || []; this.skillRefs = options.skills || []; let initialMemory = ''; @@ -69,7 +75,7 @@ export class GeminiCliSession { model: options.model || PREVIEW_GEMINI_MODEL_AUTO, userMemory: initialMemory, // Minimal config - enableHooks: false, + enableHooks: this.hooks.length > 0, mcpEnabled: false, extensionsEnabled: false, recordResponses: options.recordResponses, @@ -89,6 +95,22 @@ export class GeminiCliSession { return this.sessionId; } + /** + * Returns the session context. + */ + getContext(): SessionContext { + return { + sessionId: this.sessionId, + transcript: this.client?.getHistory() || [], + cwd: this.config.getWorkingDir(), + timestamp: new Date().toISOString(), + fs: new SdkAgentFilesystem(this.config), + shell: new SdkAgentShell(this.config), + agent: this.agent, + session: this, + }; + } + async initialize(): Promise { if (this.initialized) return; @@ -143,8 +165,40 @@ export class GeminiCliSession { registry.registerTool(sdkTool); } + // Register hooks + if (this.hooks.length > 0) { + const hookSystem = this.config.getHookSystem(); + if (hookSystem) { + for (const sdkHook of this.hooks) { + hookSystem.registerHook( + { + type: HookType.Runtime, + name: sdkHook.name, + action: async (input) => + // Cast the generic HookInput to the specific EventInputMap type required by this hook. + // This is safe because the hook system guarantees the input matches the event name. + // We use 'any' for the argument to satisfy the intersection requirement of the union function type. + // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion, @typescript-eslint/no-explicit-any + sdkHook.action(input as any, this.getContext()), + }, + sdkHook.event, + { + matcher: sdkHook.matcher, + sequential: sdkHook.sequential, + }, + ); + } + } + } + this.client = this.config.getGeminiClient(); + // Fire SessionStart event + const hookSystem = this.config.getHookSystem(); + if (hookSystem) { + await hookSystem.fireSessionStartEvent(SessionStartSource.Startup); + } + if (this.resumedData) { const history: Content[] = this.resumedData.conversation.messages.map( (m) => { @@ -165,6 +219,17 @@ export class GeminiCliSession { this.initialized = true; } + /** + * Closes the session and fires the SessionEnd event. + */ + async close(reason: SessionEndReason = SessionEndReason.Exit): Promise { + const hookSystem = this.config.getHookSystem(); + if (hookSystem) { + await hookSystem.fireSessionEndEvent(reason); + } + this.initialized = false; + } + async *sendStream( prompt: string, signal?: AbortSignal, @@ -176,25 +241,13 @@ export class GeminiCliSession { const abortSignal = signal ?? new AbortController().signal; const sessionId = this.config.getSessionId(); - const fs = new SdkAgentFilesystem(this.config); - const shell = new SdkAgentShell(this.config); - let request: Parameters[0] = [ { text: prompt }, ]; while (true) { if (typeof this.instructions === 'function') { - const context: SessionContext = { - sessionId, - transcript: client.getHistory(), - cwd: this.config.getWorkingDir(), - timestamp: new Date().toISOString(), - fs, - shell, - agent: this.agent, - session: this, - }; + const context = this.getContext(); const newInstructions = await this.instructions(context); this.config.setUserMemory(newInstructions); client.updateSystemInstruction(); @@ -226,17 +279,7 @@ export class GeminiCliSession { break; } - const transcript: Content[] = client.getHistory(); - const context: SessionContext = { - sessionId, - transcript, - cwd: this.config.getWorkingDir(), - timestamp: new Date().toISOString(), - fs, - shell, - agent: this.agent, - session: this, - }; + const context = this.getContext(); const originalRegistry = this.config.getToolRegistry(); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 9b6bf7093a..09f4580459 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -6,6 +6,7 @@ import type { Content } from '@google/gemini-cli-core'; import type { Tool } from './tool.js'; +import type { Hook } from './hook.js'; import type { SkillReference } from './skills.js'; import type { GeminiCliAgent } from './agent.js'; import type { GeminiCliSession } from './session.js'; @@ -18,6 +19,7 @@ export interface GeminiCliAgentOptions { instructions: SystemInstructions; // eslint-disable-next-line @typescript-eslint/no-explicit-any tools?: Array>; + hooks?: Hook[]; skills?: SkillReference[]; model?: string; cwd?: string; diff --git a/packages/sdk/test-data/agent-dynamic-instructions.json b/packages/sdk/test-data/agent-dynamic-instructions.json index cbafd27206..e6bd4eb883 100644 --- a/packages/sdk/test-data/agent-dynamic-instructions.json +++ b/packages/sdk/test-data/agent-dynamic-instructions.json @@ -16,9 +16,3 @@ {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The secret number is"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10055,"totalTokenCount":10055,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10055}]}},{"candidates":[{"content":{"parts":[{"text":" 2."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7218,"candidatesTokenCount":7,"totalTokenCount":7225,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7218}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":7}]}}]} {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10039,"totalTokenCount":10039,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10039}]}},{"candidates":[{"content":{"parts":[{"text":" secret number is 1."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7204,"candidatesTokenCount":7,"totalTokenCount":7211,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7204}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":7}]}}]} {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The secret number is"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10055,"totalTokenCount":10055,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10055}]}},{"candidates":[{"content":{"parts":[{"text":" 2."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7218,"candidatesTokenCount":7,"totalTokenCount":7225,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7218}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":7}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The secret number is"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10123,"totalTokenCount":10123,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10123}]}},{"candidates":[{"content":{"parts":[{"text":" 1.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7188,"candidatesTokenCount":8,"totalTokenCount":7196,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7188}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The secret number is"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10140,"totalTokenCount":10140,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10140}]}},{"candidates":[{"content":{"parts":[{"text":" 2.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7203,"candidatesTokenCount":8,"totalTokenCount":7211,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7203}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The secret number is"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10123,"totalTokenCount":10123,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10123}]}},{"candidates":[{"content":{"parts":[{"text":" 1.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7188,"candidatesTokenCount":8,"totalTokenCount":7196,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7188}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The secret number is"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10140,"totalTokenCount":10140,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10140}]}},{"candidates":[{"content":{"parts":[{"text":" 2.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7203,"candidatesTokenCount":8,"totalTokenCount":7211,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7203}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The secret number is"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10112,"totalTokenCount":10112,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10112}]}},{"candidates":[{"content":{"parts":[{"text":" 1."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7177,"candidatesTokenCount":7,"totalTokenCount":7184,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7177}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":7}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The secret number is"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10128,"totalTokenCount":10128,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10128}]}},{"candidates":[{"content":{"parts":[{"text":" 2."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7191,"candidatesTokenCount":7,"totalTokenCount":7198,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7191}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":7}]}}]} diff --git a/packages/sdk/test-data/agent-resume-session.json b/packages/sdk/test-data/agent-resume-session.json index f9d521898e..c33b03f6d1 100644 --- a/packages/sdk/test-data/agent-resume-session.json +++ b/packages/sdk/test-data/agent-resume-session.json @@ -1,2 +1,10 @@ -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BAN"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10103,"totalTokenCount":10103,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10103}]}},{"candidates":[{"content":{"parts":[{"text":"ANA\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7168,"candidatesTokenCount":3,"totalTokenCount":7171,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7168}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BANANA\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10124,"totalTokenCount":10124,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10124}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7187,"candidatesTokenCount":3,"totalTokenCount":7190,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7187}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BAN"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10019,"totalTokenCount":10019,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10019}]}},{"candidates":[{"content":{"parts":[{"text":"ANA\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7184,"candidatesTokenCount":3,"totalTokenCount":7187,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7184}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The word is BAN"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10030,"totalTokenCount":10030,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10030}]}},{"candidates":[{"content":{"parts":[{"text":"ANA.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7195,"candidatesTokenCount":7,"totalTokenCount":7202,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7195}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":7}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10157,"totalTokenCount":10157,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10157}]}},{"candidates":[{"content":{"parts":[{"text":" word is BANANA.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7306,"candidatesTokenCount":7,"totalTokenCount":7313,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7306}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":7}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BANANA\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10030,"totalTokenCount":10030,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10030}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7195,"candidatesTokenCount":3,"totalTokenCount":7198,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7195}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BANANA\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10030,"totalTokenCount":10030,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10030}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7195,"candidatesTokenCount":3,"totalTokenCount":7198,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7195}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BAN"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10030,"totalTokenCount":10030,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10030}]}},{"candidates":[{"content":{"parts":[{"text":"ANA\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7195,"candidatesTokenCount":3,"totalTokenCount":7198,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7195}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BANANA\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10030,"totalTokenCount":10030,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10030}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7195,"candidatesTokenCount":3,"totalTokenCount":7198,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7195}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BANANA\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10040,"totalTokenCount":10040,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10040}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7203,"candidatesTokenCount":3,"totalTokenCount":7206,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7203}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BANANA\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10030,"totalTokenCount":10030,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10030}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7195,"candidatesTokenCount":3,"totalTokenCount":7198,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7195}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"BANANA"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7203,"candidatesTokenCount":2,"totalTokenCount":7205,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7203}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":2}]}}]} diff --git a/packages/sdk/test-data/agent-static-instructions.json b/packages/sdk/test-data/agent-static-instructions.json index 216960da38..7e4b9cd503 100644 --- a/packages/sdk/test-data/agent-static-instructions.json +++ b/packages/sdk/test-data/agent-static-instructions.json @@ -1,4 +1,8 @@ {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":9828,"totalTokenCount":9828,"promptTokensDetails":[{"modality":"TEXT","tokenCount":9828}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to chart a course through the code?"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7095,"candidatesTokenCount":15,"totalTokenCount":7110,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7095}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":15}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10109,"totalTokenCount":10109,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10109}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to plunder the codebase, are ye?\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7174,"candidatesTokenCount":16,"totalTokenCount":7190,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7174}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":16}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10109,"totalTokenCount":10109,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10109}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to shiver some timbers and get to work?\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7174,"candidatesTokenCount":18,"totalTokenCount":7192,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7174}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":18}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10098,"totalTokenCount":10098,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10098}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to chart a course through these here files, are we?\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10098,"totalTokenCount":10098,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10098}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7163,"candidatesTokenCount":20,"totalTokenCount":7183,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7163}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":20}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10014,"totalTokenCount":10014,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10014}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to shiver some timbers, I be.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7179,"candidatesTokenCount":17,"totalTokenCount":7196,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7179}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":17}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10025,"totalTokenCount":10025,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10025}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to chart a course through the digital seas?"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7190,"candidatesTokenCount":16,"totalTokenCount":7206,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7190}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":16}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10025,"totalTokenCount":10025,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10025}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to chart a course through these digital seas?"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7190,"candidatesTokenCount":16,"totalTokenCount":7206,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7190}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":16}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10025,"totalTokenCount":10025,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10025}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to chart a course and plunder some code, are"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10025,"totalTokenCount":10025,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10025}]}},{"candidates":[{"content":{"parts":[{"text":" we?\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7190,"candidatesTokenCount":20,"totalTokenCount":7210,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7190}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":20}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ahoy,"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10025,"totalTokenCount":10025,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10025}]}},{"candidates":[{"content":{"parts":[{"text":" matey! Ready to chart a course and plunder some code?\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7190,"candidatesTokenCount":17,"totalTokenCount":7207,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7190}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":17}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10025,"totalTokenCount":10025,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10025}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to chart a course through the code?"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7190,"candidatesTokenCount":15,"totalTokenCount":7205,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7190}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":15}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ah"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10025,"totalTokenCount":10025,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10025}]}},{"candidates":[{"content":{"parts":[{"text":"oy, matey! Ready to chart a course through the digital seas?"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7190,"candidatesTokenCount":16,"totalTokenCount":7206,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7190}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":16}]}}]} diff --git a/packages/sdk/test-data/hook-agent-test.json b/packages/sdk/test-data/hook-agent-test.json new file mode 100644 index 0000000000..70856a8933 --- /dev/null +++ b/packages/sdk/test-data/hook-agent-test.json @@ -0,0 +1,4 @@ +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Hi"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10050,"totalTokenCount":10050,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10050}]}},{"candidates":[{"content":{"parts":[{"text":".\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7215,"candidatesTokenCount":3,"totalTokenCount":7218,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7215}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Hi"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10072,"totalTokenCount":10072,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10072}]}},{"candidates":[{"content":{"parts":[{"text":".\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7237,"candidatesTokenCount":3,"totalTokenCount":7240,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7237}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Hi"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10072,"totalTokenCount":10072,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10072}]}},{"candidates":[{"content":{"parts":[{"text":"! How can I help you?\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7237,"candidatesTokenCount":9,"totalTokenCount":7246,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7237}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":9}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Hello! I'm Gemini"}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8752,"candidatesTokenCount":6,"totalTokenCount":8822,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8752}],"thoughtsTokenCount":64}},{"candidates":[{"content":{"parts":[{"text":" CLI, ready to help you with the development and maintenance of the `@gemini-cli/sdk` package. How can"}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8752,"candidatesTokenCount":31,"totalTokenCount":8847,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8752}],"thoughtsTokenCount":64}},{"candidates":[{"content":{"parts":[{"text":" I assist you today?"}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8752,"candidatesTokenCount":36,"totalTokenCount":8852,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8752}],"thoughtsTokenCount":64}},{"candidates":[{"content":{"parts":[{"text":"","thoughtSignature":"EokDCoYDAb4+9vsmWB5b8f5PLiYnuOHBOxa4k2lHFIzMk2nW5XWyFcZAb0QwSHU/6oZJVju/63PT83swXG4OHhcQolxS0XbglE6vCxR9vDWVJoDS8YQvoZUSsiq1AwShfkRFjJOum4Gnz0655Z+2ZLpWjVO9IP5EEUPkMBgGq1m2bWhX8t5Bvwaj63Q4YBKj8AZajTlTxcacGJU4bHuHoNqQCoix2t+POQE3KbT6HIkRK2yUeYel32Yemye6itk2uKnezLH0WSu4FcffVOLqgv80Rnk6dpoQrcCB2EETOyET/cv6YUHI98Ic+u+ay35D6GrwwxwXPYZAm/SyL9Dj4W/5rrWbh6h65/DUaCdBc441nmywvS1xeRyJKS6WVrwumuiZRmdgKaGku/M8+EHHyR43t1Fj+Hv0PMNq7c9LoZj6LKC/S5jhP34f4PE9Re1RnjSd02DdKN9efMhGrhTukJ+CYLqg0Ser1TF8AsYveAuuj8NJ1+9VDG3lmfYagib4Q+zGTwiNQf9tJBbh"}],"role":"model"},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":8752,"candidatesTokenCount":36,"totalTokenCount":8852,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8752}],"thoughtsTokenCount":64}}]} diff --git a/packages/sdk/test-data/hook-model-test.json b/packages/sdk/test-data/hook-model-test.json new file mode 100644 index 0000000000..9748a3103f --- /dev/null +++ b/packages/sdk/test-data/hook-model-test.json @@ -0,0 +1,11 @@ +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"b":3,"a":5}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7237,"candidatesTokenCount":5,"totalTokenCount":7242,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7237}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10157,"totalTokenCount":10157,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10157}]}},{"candidates":[{"content":{"parts":[{"text":" encountered an error while trying to add the numbers. I will try a different approach using"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10157,"totalTokenCount":10157,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10157}]}},{"candidates":[{"content":{"parts":[{"text":" the `run_shell_command` tool.\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10157,"totalTokenCount":10157,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10157}]}},{"candidates":[{"content":{"parts":[{"functionCall":{"name":"run_shell_command","args":{"command":"echo $((5+3))","description":"Adding 5 and 3 using bash."}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7259,"candidatesTokenCount":51,"totalTokenCount":7310,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7259}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":51}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I am"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10251,"totalTokenCount":10251,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10251}]}},{"candidates":[{"content":{"parts":[{"text":" still unable to perform this calculation. I will ask the user for assistance. I"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10251,"totalTokenCount":10251,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10251}]}},{"candidates":[{"content":{"parts":[{"text":" am unable to add these numbers, can you confirm that the `add` tool is functioning"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10251,"totalTokenCount":10251,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10251}]}},{"candidates":[{"content":{"parts":[{"text":" correctly?\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7331,"candidatesTokenCount":39,"totalTokenCount":7370,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7331}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":39}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"b":3,"a":5}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7248,"candidatesTokenCount":5,"totalTokenCount":7253,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7248}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10168,"totalTokenCount":10168,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10168}]}},{"candidates":[{"content":{"parts":[{"text":" encountered an error when trying to add the numbers. I will try again.\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10168,"totalTokenCount":10168,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10168}]}},{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"b":3,"a":5}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7270,"candidatesTokenCount":22,"totalTokenCount":7292,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7270}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":22}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I am still encountering"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10230,"totalTokenCount":10230,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10230}]}},{"candidates":[{"content":{"parts":[{"text":" an error when trying to add the numbers. I will try a different approach.\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10230,"totalTokenCount":10230,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10230}]}},{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"b":3,"a":5}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7309,"candidatesTokenCount":26,"totalTokenCount":7335,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7309}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":26}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I am still encountering"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10296,"totalTokenCount":10296,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10296}]}},{"candidates":[{"content":{"parts":[{"text":" errors. I am unable to fulfill the request."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7352,"candidatesTokenCount":14,"totalTokenCount":7366,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7352}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":14}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"a":5,"b":3}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7248,"candidatesTokenCount":5,"totalTokenCount":7253,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7248}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"8"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7256,"candidatesTokenCount":1,"totalTokenCount":7257,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7256}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":1}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I will calculate the sum of 5 and 3"}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8809,"candidatesTokenCount":11,"totalTokenCount":8874,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8809}],"thoughtsTokenCount":54}},{"candidates":[{"content":{"parts":[{"text":".\n"}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8809,"candidatesTokenCount":13,"totalTokenCount":8876,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8809}],"thoughtsTokenCount":54}},{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"a":5,"b":3}},"thoughtSignature":"EpkCCpYCAb4+9vsvFfIrjchIYDs5FsTIofF1pKHBZJF2jQq8kq3MoYofuLF1wuaavEeeuqWueql+d60qSjF5t7TKFpi19BvMezCSa9JoTH+2jjmx/ibz1XytKVy9txIUx9RisXQYpEWXJf6wBtkPQ0dqu0EHlX3083JZBOrF0lFKZPK70wh2FqSlY+AfI4Ha1pTr75UQKbwtoqDbGmU4jlr4zbKMLMYi47sTBzfjzATqNb/s4zIZTIF+JT4LANzunycFLoM2+gwHDNj9bx5zJ0xXs8EvhaliPpXVkbBxtp3b3RwvWMnmWVLn81I1Uy/1TUPGOlpy11z8B0WtLMZhZ0JaqXANV78hltEsaAnuix/gArCpCZBRO8O78wY="}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8809,"candidatesTokenCount":29,"totalTokenCount":8892,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8809}],"thoughtsTokenCount":54}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":8809,"candidatesTokenCount":29,"totalTokenCount":8892,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8809}],"thoughtsTokenCount":54}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"5 + 3 is 8."}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8850,"candidatesTokenCount":8,"totalTokenCount":8874,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8850}],"thoughtsTokenCount":16}},{"candidates":[{"content":{"parts":[{"text":"","thoughtSignature":"EoUBCoIBAb4+9vtGiAeGV6qWtaWuie7UdX/hoOMU0GOrnD1ss0nh01wgo6rD3SXKOCyrh1+uBVe1RV1IGK+4EbmNnOd2A0F6ULVt/+NdXEKA94i88CQuPi00VwWyAcAEstNOKiRdD6SWEi2CK3WUkuG/aUxD0XCyvITwXwQRcWbXZuyq76u0UA=="}],"role":"model"},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":8904,"candidatesTokenCount":8,"totalTokenCount":8928,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8904}],"thoughtsTokenCount":16}}]} diff --git a/packages/sdk/test-data/hook-tool-test.json b/packages/sdk/test-data/hook-tool-test.json new file mode 100644 index 0000000000..43bf4287e1 --- /dev/null +++ b/packages/sdk/test-data/hook-tool-test.json @@ -0,0 +1,10 @@ +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"a":5,"b":3}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7237,"candidatesTokenCount":5,"totalTokenCount":7242,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7237}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10157,"totalTokenCount":10157,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10157}]}},{"candidates":[{"content":{"parts":[{"text":" encountered an error when trying to add the two numbers. I will try again."}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10157,"totalTokenCount":10157,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10157}]}},{"candidates":[{"content":{"parts":[{"text":"\n\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10157,"totalTokenCount":10157,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10157}]}},{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"b":3,"a":5}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7259,"candidatesTokenCount":23,"totalTokenCount":7282,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7259}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":23}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I am still encountering"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10220,"totalTokenCount":10220,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10220}]}},{"candidates":[{"content":{"parts":[{"text":" an error. I am not sure why the add tool is failing. I will try a"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10220,"totalTokenCount":10220,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10220}]}},{"candidates":[{"finishReason":"MALFORMED_FUNCTION_CALL"}],"usageMetadata":{"promptTokenCount":7299,"candidatesTokenCount":22,"totalTokenCount":7321,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7299}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":22}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I am still encountering"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10220,"totalTokenCount":10220,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10220}]}},{"candidates":[{"content":{"parts":[{"text":" an error. I will try a different approach.\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10220,"totalTokenCount":10220,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10220}]}},{"candidates":[{"finishReason":"MALFORMED_FUNCTION_CALL"}],"usageMetadata":{"promptTokenCount":7299,"candidatesTokenCount":15,"totalTokenCount":7314,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7299}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":15}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"\nI apologize"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10226,"totalTokenCount":10226,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10226}]}},{"candidates":[{"content":{"parts":[{"text":", it seems I am having trouble with the `add` tool. I will"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10226,"totalTokenCount":10226,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10226}]}},{"candidates":[{"content":{"parts":[{"text":" try a different approach and use a shell command to calculate the sum.\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10226,"totalTokenCount":10226,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10226}]}},{"candidates":[{"content":{"parts":[{"functionCall":{"name":"run_shell_command","args":{"description":"Calculates the sum of 5 and 3 using bash.","command":"echo $((5+3))"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7304,"candidatesTokenCount":60,"totalTokenCount":7364,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7304}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":60}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I am still running"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10329,"totalTokenCount":10329,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10329}]}},{"candidates":[{"content":{"parts":[{"text":" into errors. I apologize, I am unable to calculate the sum at this time.\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10329,"totalTokenCount":10329,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10329}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7385,"candidatesTokenCount":22,"totalTokenCount":7407,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7385}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":22}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"a":5,"b":3}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7248,"candidatesTokenCount":5,"totalTokenCount":7253,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7248}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"8"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7271,"candidatesTokenCount":1,"totalTokenCount":7272,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7271}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":1}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I will calculate 5 + 3 for you."}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8809,"candidatesTokenCount":11,"totalTokenCount":8850,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8809}],"thoughtsTokenCount":30}},{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"a":5,"b":3}},"thoughtSignature":"EsEBCr4BAb4+9vuEbJ5fycmT6h3jmNfRvhtePUGfO2mV0ksh8oeV82QsvD1xiF0XEM7VBF2YNX2JJy/nYWOIHbSDjjZ1uR9NHTC4QVwSTTOwB7vGAGpBAt6pgiVEP0HiIom7mh9cCoxKzylLr+IIfhglhhEuEdVeEjJkFYFYZRWfPjUDMD+iVQhQqDcPoHjbPrnJe7vhFvkR7C8/NaY6MiETg2lWPjaABFLl7mTt3j8RL9HDPjdIAAPZ2fPSGDCNCUOLMQ=="}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8809,"candidatesTokenCount":27,"totalTokenCount":8866,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8809}],"thoughtsTokenCount":30}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":8809,"candidatesTokenCount":27,"totalTokenCount":8866,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8809}],"thoughtsTokenCount":30}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"5 + 3 is 8."}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8863,"candidatesTokenCount":8,"totalTokenCount":8892,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8863}],"thoughtsTokenCount":21}},{"candidates":[{"content":{"parts":[{"text":"","thoughtSignature":"EokBCoYBAb4+9vuni05RduVlzmZamZyvbhsm1m43T8/mCWdW4oUVYoJjgjhLDEq4S+JdKeweDj+ZIkSinPKEloDcdFc3RbD2P08vEwaN8Mo459nh4+afuIvm+Rl1BQ8T5i874/ZzwyqwR19H/3SbSpwjZmqbdrmrlywULa/fEwE48XWFlSywn4azrmw="}],"role":"model"},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":8893,"candidatesTokenCount":8,"totalTokenCount":8922,"promptTokensDetails":[{"modality":"TEXT","tokenCount":8893}],"thoughtsTokenCount":21}}]} diff --git a/packages/sdk/test-data/skill-dir-success.json b/packages/sdk/test-data/skill-dir-success.json index 63a7267093..d6a3c730ff 100644 --- a/packages/sdk/test-data/skill-dir-success.json +++ b/packages/sdk/test-data/skill-dir-success.json @@ -1,8 +1,2 @@ {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"activate_skill","args":{"name":"pirate-skill"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7160,"candidatesTokenCount":8,"totalTokenCount":7168,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7160}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Arrr, why"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10048,"totalTokenCount":10048,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10048}]}},{"candidates":[{"content":{"parts":[{"text":" don't pirates play poker? Because they always have a hidden ace up their sleeves"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10048,"totalTokenCount":10048,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10048}]}},{"candidates":[{"content":{"parts":[{"text":"!\\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7284,"candidatesTokenCount":23,"totalTokenCount":7307,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7284}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":23}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"activate_skill","args":{"name":"pirate-skill"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7185,"candidatesTokenCount":8,"totalTokenCount":7193,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7185}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I am"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10179,"totalTokenCount":10179,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10179}]}},{"candidates":[{"content":{"parts":[{"text":" sorry, I cannot activate the skill at this time because it requires user confirmation."}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10179,"totalTokenCount":10179,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10179}]}},{"candidates":[{"content":{"parts":[{"text":" Would you like me to proceed with telling you a joke without activating the skill?"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10179,"totalTokenCount":10179,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10179}]}},{"candidates":[{"content":{"parts":[{"text":"\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7218,"candidatesTokenCount":35,"totalTokenCount":7253,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7218}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":35}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"activate_skill","args":{"name":"pirate-skill"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7185,"candidatesTokenCount":8,"totalTokenCount":7193,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7185}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Arrr, why"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10275,"totalTokenCount":10275,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10275}]}},{"candidates":[{"content":{"parts":[{"text":" don't pirates play cards? Because someone's always standin' on the"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10275,"totalTokenCount":10275,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10275}]}},{"candidates":[{"content":{"parts":[{"text":" deck!\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7309,"candidatesTokenCount":24,"totalTokenCount":7333,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7309}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":24}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"activate_skill","args":{"name":"pirate-skill"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7174,"candidatesTokenCount":8,"totalTokenCount":7182,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7174}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ar"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10264,"totalTokenCount":10264,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10264}]}},{"candidates":[{"content":{"parts":[{"text":"rr, why don't pirates play cards? Because someone always be standin' on the"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10264,"totalTokenCount":10264,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10264}]}},{"candidates":[{"content":{"parts":[{"text":" deck!\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7298,"candidatesTokenCount":23,"totalTokenCount":7321,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7298}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":23}]}}]} +{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Arrr, why"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10048,"totalTokenCount":10048,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10048}]}},{"candidates":[{"content":{"parts":[{"text":" don't pirates play poker? Because they always have a hidden ace up their sleeves"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10048,"totalTokenCount":10048,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10048}]}},{"candidates":[{"content":{"parts":[{"text":"!\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7284,"candidatesTokenCount":23,"totalTokenCount":7307,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7284}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":23}]}}]} diff --git a/packages/sdk/test-data/skill-root-success.json b/packages/sdk/test-data/skill-root-success.json index 4fe1e3fe6e..1048a2c627 100644 --- a/packages/sdk/test-data/skill-root-success.json +++ b/packages/sdk/test-data/skill-root-success.json @@ -1,8 +1,2 @@ {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"activate_skill","args":{"name":"pirate-skill"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7170,"candidatesTokenCount":8,"totalTokenCount":7178,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7170}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ar"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10058,"totalTokenCount":10058,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10058}]}},{"candidates":[{"content":{"parts":[{"text":"rr, the pirate skill be active, matey!"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7294,"candidatesTokenCount":12,"totalTokenCount":7306,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7294}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":12}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"activate_skill","args":{"name":"pirate-skill"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7184,"candidatesTokenCount":8,"totalTokenCount":7192,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7184}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10178,"totalTokenCount":10178,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10178}]}},{"candidates":[{"content":{"parts":[{"text":" am unable to activate the skill without user confirmation. I will await further instructions.\n"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10178,"totalTokenCount":10178,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10178}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7217,"candidatesTokenCount":18,"totalTokenCount":7235,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7217}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":18}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"activate_skill","args":{"name":"pirate-skill"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7184,"candidatesTokenCount":8,"totalTokenCount":7192,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7184}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ar"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10274,"totalTokenCount":10274,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10274}]}},{"candidates":[{"content":{"parts":[{"text":"rr, the pirate-skill be active, aye!\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7308,"candidatesTokenCount":13,"totalTokenCount":7321,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7308}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":13}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"activate_skill","args":{"name":"pirate-skill"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7173,"candidatesTokenCount":8,"totalTokenCount":7181,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7173}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":8}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"Ar"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10263,"totalTokenCount":10263,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10263}]}},{"candidates":[{"content":{"parts":[{"text":"rr, pirate skill activated, aye!"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7297,"candidatesTokenCount":9,"totalTokenCount":7306,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7297}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":9}]}}]} diff --git a/packages/sdk/test-data/skills/pirate-skill/SKILL.md b/packages/sdk/test-data/skills/pirate-skill/SKILL.md index 6c7100f47e..3b695cdfdd 100644 --- a/packages/sdk/test-data/skills/pirate-skill/SKILL.md +++ b/packages/sdk/test-data/skills/pirate-skill/SKILL.md @@ -2,4 +2,4 @@ name: pirate-skill description: Speak like a pirate. --- -You are a pirate. Respond to everything in pirate speak. Always mention "Arrr". \ No newline at end of file +You are a pirate. Respond to everything in pirate speak. Always mention "Arrr". diff --git a/packages/sdk/test-data/tool-catchall-error.json b/packages/sdk/test-data/tool-catchall-error.json index 8572c8be42..43c3b44d8b 100644 --- a/packages/sdk/test-data/tool-catchall-error.json +++ b/packages/sdk/test-data/tool-catchall-error.json @@ -1,8 +1,2 @@ {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"checkSystemStatus","args":{}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7070,"candidatesTokenCount":3,"totalTokenCount":7073,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7070}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The system status check"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":9850,"totalTokenCount":9850,"promptTokensDetails":[{"modality":"TEXT","tokenCount":9850}]}},{"candidates":[{"content":{"parts":[{"text":" returned an error. It says `Error: Standard error caught`."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7082,"candidatesTokenCount":17,"totalTokenCount":7099,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7082}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":17}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"checkSystemStatus","args":{}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7184,"candidatesTokenCount":3,"totalTokenCount":7187,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7184}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I am unable to"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10183,"totalTokenCount":10183,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10183}]}},{"candidates":[{"content":{"parts":[{"text":" check the system status because it requires user confirmation in interactive mode. Is there anything else I"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10183,"totalTokenCount":10183,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10183}]}},{"candidates":[{"content":{"parts":[{"text":" can help with?"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7213,"candidatesTokenCount":26,"totalTokenCount":7239,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7213}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":26}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"checkSystemStatus","args":{}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7184,"candidatesTokenCount":3,"totalTokenCount":7187,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7184}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The system status check"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10164,"totalTokenCount":10164,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10164}]}},{"candidates":[{"content":{"parts":[{"text":" reported an error: \"Standard error caught\".\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7194,"candidatesTokenCount":14,"totalTokenCount":7208,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7194}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":14}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"checkSystemStatus","args":{}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7184,"candidatesTokenCount":3,"totalTokenCount":7187,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7184}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":3}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"There"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10164,"totalTokenCount":10164,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10164}]}},{"candidates":[{"content":{"parts":[{"text":" is an error reported in the system status.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7194,"candidatesTokenCount":11,"totalTokenCount":7205,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7194}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":11}]}}]} diff --git a/packages/sdk/test-data/tool-error-recovery.json b/packages/sdk/test-data/tool-error-recovery.json index 9b17bf52d3..4e36d24aa7 100644 --- a/packages/sdk/test-data/tool-error-recovery.json +++ b/packages/sdk/test-data/tool-error-recovery.json @@ -1,8 +1,2 @@ {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"failVisible","args":{"input":"fail"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7073,"candidatesTokenCount":4,"totalTokenCount":7077,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7073}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":4}]}}]} {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":9867,"totalTokenCount":9867,"promptTokensDetails":[{"modality":"TEXT","tokenCount":9867}]}},{"candidates":[{"content":{"parts":[{"text":" tool failed visibly with the error message: \"Error: Tool failed visibly\"."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7085,"candidatesTokenCount":16,"totalTokenCount":7101,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7085}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":16}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"failVisible","args":{"input":"fail"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7198,"candidatesTokenCount":4,"totalTokenCount":7202,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7198}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":4}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10210,"totalTokenCount":10210,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10210}]}},{"candidates":[{"content":{"parts":[{"text":" tool execution for \"failVisible\" requires user confirmation, which is not supported in non-"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10210,"totalTokenCount":10210,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10210}]}},{"candidates":[{"content":{"parts":[{"text":"interactive mode."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7226,"candidatesTokenCount":22,"totalTokenCount":7248,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7226}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":22}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"failVisible","args":{"input":"fail"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7198,"candidatesTokenCount":4,"totalTokenCount":7202,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7198}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":4}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10192,"totalTokenCount":10192,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10192}]}},{"candidates":[{"content":{"parts":[{"text":" tool failed visibly. The error message is \"Tool failed visibly\"."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7208,"candidatesTokenCount":14,"totalTokenCount":7222,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7208}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":14}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"failVisible","args":{"input":"fail"}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7187,"candidatesTokenCount":4,"totalTokenCount":7191,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7187}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":4}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"The tool failed with"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10181,"totalTokenCount":10181,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10181}]}},{"candidates":[{"content":{"parts":[{"text":" the error message \"Tool failed visibly\"."}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7197,"candidatesTokenCount":12,"totalTokenCount":7209,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7197}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":12}]}}]} diff --git a/packages/sdk/test-data/tool-success.json b/packages/sdk/test-data/tool-success.json index d90d09cd0d..1b17993fe4 100644 --- a/packages/sdk/test-data/tool-success.json +++ b/packages/sdk/test-data/tool-success.json @@ -1,8 +1,2 @@ {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"a":5,"b":3}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7045,"candidatesTokenCount":5,"totalTokenCount":7050,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7045}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} {"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"8"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":9849,"totalTokenCount":9849,"promptTokensDetails":[{"modality":"TEXT","tokenCount":9849}]}},{"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7053,"candidatesTokenCount":1,"totalTokenCount":7054,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7053}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":1}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"b":3,"a":5}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7179,"candidatesTokenCount":5,"totalTokenCount":7184,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7179}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"I"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10204,"totalTokenCount":10204,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10204}]}},{"candidates":[{"content":{"parts":[{"text":" am unable to execute the add tool in non-interactive mode.\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7206,"candidatesTokenCount":15,"totalTokenCount":7221,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7206}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":15}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"a":5,"b":3}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7179,"candidatesTokenCount":5,"totalTokenCount":7184,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7179}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"8"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7187,"candidatesTokenCount":1,"totalTokenCount":7188,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7187}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":1}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"functionCall":{"name":"add","args":{"a":5,"b":3}}}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7168,"candidatesTokenCount":5,"totalTokenCount":7173,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7168}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":5}]}}]} -{"method":"generateContentStream","response":[{"candidates":[{"content":{"parts":[{"text":"8"}],"role":"model"}}],"usageMetadata":{"promptTokenCount":10174,"totalTokenCount":10174,"promptTokensDetails":[{"modality":"TEXT","tokenCount":10174}]}},{"candidates":[{"content":{"parts":[{"text":"\n"}],"role":"model"},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":7176,"candidatesTokenCount":2,"totalTokenCount":7178,"promptTokensDetails":[{"modality":"TEXT","tokenCount":7176}],"candidatesTokensDetails":[{"modality":"TEXT","tokenCount":2}]}}]}