From ea5142dd1151a7064a67351f87e1fc3cfdd93a5b Mon Sep 17 00:00:00 2001 From: Rawdyrathaur Date: Thu, 26 Feb 2026 13:54:47 +0530 Subject: [PATCH 1/3] fix(sdk): move dynamic instructions error test to unit test --- packages/sdk/src/agent.integration.test.ts | 18 ------------------ packages/sdk/src/agent.test.ts | 5 +++++ 2 files changed, 5 insertions(+), 18 deletions(-) create mode 100644 packages/sdk/src/agent.test.ts diff --git a/packages/sdk/src/agent.integration.test.ts b/packages/sdk/src/agent.integration.test.ts index 064cd9fad75..4a7143c8513 100644 --- a/packages/sdk/src/agent.integration.test.ts +++ b/packages/sdk/src/agent.integration.test.ts @@ -142,22 +142,4 @@ describe('GeminiCliAgent Integration', () => { new GeminiCliAgent({ instructions: 123 as any }).session(), ).toThrow('Instructions must be a string or a function.'); }); - - it('propagates errors from dynamic instructions', async () => { - const agent = new GeminiCliAgent({ - instructions: () => { - throw new Error('Dynamic instruction failure'); - }, - model: 'gemini-2.0-flash', - }); - - const session = agent.session(); - const stream = session.sendStream('Say hello.'); - - await expect(async () => { - for await (const _event of stream) { - // Just consume the stream - } - }).rejects.toThrow('Dynamic instruction failure'); - }); }); diff --git a/packages/sdk/src/agent.test.ts b/packages/sdk/src/agent.test.ts new file mode 100644 index 00000000000..f85b3e5e97c --- /dev/null +++ b/packages/sdk/src/agent.test.ts @@ -0,0 +1,5 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ From ec6815938aee373c701d284e3285a63a41be2bd9 Mon Sep 17 00:00:00 2001 From: Rawdyrathaur Date: Thu, 26 Feb 2026 13:57:06 +0530 Subject: [PATCH 2/3] chore: ignore .claude/ and ISSUE_LIST.md --- .gitignore | 2 ++ packages/sdk/src/agent.test.ts | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/.gitignore b/.gitignore index a2a6553cd3a..dcae9c4461b 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,5 @@ gemini-debug.log .gemini-clipboard/ .eslintcache evals/logs/ +.claude/ +ISSUE_LIST.md diff --git a/packages/sdk/src/agent.test.ts b/packages/sdk/src/agent.test.ts index f85b3e5e97c..1fa187dfbc9 100644 --- a/packages/sdk/src/agent.test.ts +++ b/packages/sdk/src/agent.test.ts @@ -3,3 +3,42 @@ * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ + +import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { GeminiCliAgent } from './agent.js'; +import { GeminiCliSession } from './session.js'; + +beforeEach(() => { + vi.restoreAllMocks(); +}); + +describe('GeminiCliSession', () => { + it('propagates errors from dynamic instructions', async () => { + vi.spyOn(GeminiCliSession.prototype, 'initialize').mockImplementation( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + async function (this: any) { + this.client = { getHistory: () => [] }; + this.initialized = true; + }, + ); + + let callCount = 0; + const agent = new GeminiCliAgent({ + instructions: () => { + callCount++; + throw new Error('Dynamic instruction failure'); + }, + model: 'gemini-2.0-flash', + }); + + const stream = agent.session().sendStream('Say hello.'); + + await expect(async () => { + for await (const _event of stream) { + // consume stream + } + }).rejects.toThrow('Dynamic instruction failure'); + + expect(callCount).toBe(1); + }); +}); From 32fa26562a503a104954b7a9fd8e40406885ae6b Mon Sep 17 00:00:00 2001 From: Rawdyrathaur Date: Thu, 26 Feb 2026 14:31:17 +0530 Subject: [PATCH 3/3] fix(sdk): add sendMessageStream to client mock --- packages/sdk/src/agent.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/agent.test.ts b/packages/sdk/src/agent.test.ts index 1fa187dfbc9..d85d671b4b9 100644 --- a/packages/sdk/src/agent.test.ts +++ b/packages/sdk/src/agent.test.ts @@ -17,7 +17,10 @@ describe('GeminiCliSession', () => { vi.spyOn(GeminiCliSession.prototype, 'initialize').mockImplementation( // eslint-disable-next-line @typescript-eslint/no-explicit-any async function (this: any) { - this.client = { getHistory: () => [] }; + this.client = { + getHistory: () => [], + async *sendMessageStream () {}, + }; this.initialized = true; }, );