Skip to content

bug(ci): SDK tests not run in PR CI; nightly broken by incorrect mock in session.test.ts #24999

@SandyTao520

Description

@SandyTao520

What happened?

The nightly release workflow (run #24165914961) fails with 6 test failures in packages/sdk/src/session.test.ts. All 6 failures are in the GeminiCliSession sendStream() describe block with:

TypeError: Cannot read properties of undefined (reading 'sendMessageStream')
 ❯ GeminiCliSession.sendStream src/session.ts:206:29

Root cause has two parts:

1. Incorrect mock in session.test.ts (PR #21897)

The test file (added in #21897, commit 1023c5b7a) mocks Config with getGeminiClient() as a method:

getGeminiClient: vi.fn().mockReturnValue(mockClient),

But session.ts accesses the client via the AgentLoopContext property getter (migrated in #22115):

const loopContext2: AgentLoopContext = this.config;
this.client = loopContext2.geminiClient; // property, not method

Since the mock has no geminiClient property, this.client remains undefined, crashing all sendStream() tests.

2. @google/gemini-cli-sdk is missing from PR CI test matrix

The CI workflow (.github/workflows/ci.yml) explicitly lists workspaces per shard:

  • cli shard: @google/gemini-cli
  • others shard: @google/gemini-cli-core, @google/gemini-cli-a2a-server, gemini-cli-vscode-ide-companion, @google/gemini-cli-test-utils

@google/gemini-cli-sdk is not included in either shard, so its tests never run during PR checks. The nightly release uses npm run test:ci --workspaces --if-present (all workspaces), which is why it caught the failure.

What did you expect to happen?

  1. The SDK test mock should correctly match the AgentLoopContext interface (using geminiClient property instead of getGeminiClient() method).
  2. @google/gemini-cli-sdk should be included in the others shard of ci.yml so SDK tests are run during PR checks.

Client information

Client Information

N/A — this is a CI infrastructure issue, not a runtime bug.

Anything else we need to know?

Failed tests (all in packages/sdk/src/session.test.ts):

  • GeminiCliSession sendStream() > auto-initializes if not yet initialized
  • GeminiCliSession sendStream() > completes cleanly when model returns no tool calls
  • GeminiCliSession sendStream() > accepts an AbortSignal without throwing
  • GeminiCliSession sendStream() > executes tool call loop and sends function response back to model
  • GeminiCliSession sendStream() > calls setUserMemory and updateSystemInstruction when instructions is a function
  • GeminiCliSession sendStream() > does not call setUserMemory when instructions is a string

Suggested fix:

  1. In session.test.ts, change the mock to use geminiClient: mockClient (property) and similarly fix toolRegistry, messageBus to match AgentLoopContext.
  2. In .github/workflows/ci.yml, add --workspace "@google/gemini-cli-sdk" to the others shard (lines 181, 269, 436).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/platformIssues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmtstatus/need-triageIssues that need to be triaged by the triage automation.type/bug🔒 maintainer only⛔ Do not contribute. Internal roadmap item.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions