gemini-cli - ✅(Solved) Fix bug(ci): SDK tests not run in PR CI; nightly broken by incorrect mock in session.test.ts [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#24999Fetched 2026-04-09 08:16:20
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×4cross-referenced ×1referenced ×1

Error Message

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

Root Cause

Root cause has two parts:

Fix Action

Fixed

PR fix notes

PR #25000: fix(sdk): skip broken sendStream tests to unblock nightly

Description (problem / solution / changelog)

Summary

Skip the 6 broken sendStream() tests in packages/sdk/src/session.test.ts to unblock the nightly release.

Details

PR #21897 added session.test.ts with a mock that uses getGeminiClient() (method), but session.ts accesses the client via AgentLoopContext.geminiClient (property getter). This causes all 6 sendStream() tests to crash with TypeError: Cannot read properties of undefined (reading 'sendMessageStream').

These tests were never caught in PR CI because @google/gemini-cli-sdk is not included in either shard of the CI test matrix (ci.yml). The nightly release runs all workspaces and surfaced the failure.

This PR applies describe.skip with a TODO(#24999) reference until the mock is properly fixed.

Related Issues

Related to #24999

How to Validate

npm test -w @google/gemini-cli-sdk -- --run

Expected: 5 test files pass, 29 tests pass, 6 skipped.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Noted breaking changes (if any)

Changed files

  • packages/sdk/src/session.test.ts (modified, +2/-1)

Code Example

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

---

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

---

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

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

<details> <summary>Client Information</summary>

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

</details>

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).

extent analysis

TL;DR

Update the mock in session.test.ts to use geminiClient property and add @google/gemini-cli-sdk to the others shard in .github/workflows/ci.yml.

Guidance

  • Update the session.test.ts mock to match the AgentLoopContext interface by changing getGeminiClient: vi.fn().mockReturnValue(mockClient) to geminiClient: mockClient.
  • Similarly, update the mocks for toolRegistry and messageBus to match the AgentLoopContext properties.
  • Add --workspace "@google/gemini-cli-sdk" to the others shard in .github/workflows/ci.yml to include the SDK tests in the PR checks.
  • Verify the fix by re-running the nightly release workflow and checking that the tests in session.test.ts pass.

Example

// Updated mock in session.test.ts
getGeminiClient: mockClient,
// becomes
geminiClient: mockClient,

Notes

The fix assumes that the mockClient object is correctly defined and mocked. Additionally, the update to .github/workflows/ci.yml will ensure that the SDK tests are run during PR checks, preventing similar issues in the future.

Recommendation

Apply the suggested fix by updating the mock in session.test.ts and adding @google/gemini-cli-sdk to the others shard in .github/workflows/ci.yml, as this will resolve the test failures and ensure that the SDK tests are included in the PR checks.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING