Repository navigation
fix: match userMessage fixtures on split image turns for Gemini Live - #648
Merged
jpr5 merged 4 commits intoDec 1, 2026
Merged
Conversation
commit: |
Contributor
|
Merged, thanks! Added the PR number to your changelog line on the way in. |
Merged
jpr5
added a commit
that referenced
this pull request
Dec 1, 2026
## [1.49.0] - 2026-11-30 ### Added - Replayable seeded chaos: `--chaos-seed`/`x-aimock-chaos-seed`; journal `chaosOrigin` (#618, #653) - Recorder writes `requestHash`; stale replays get journal `staleFixture` and a warning (#640, #651) ### Changed - `aimock-pytest` 0.7.4 defaults to `@copilotkit/aimock` 1.49.0 ### Fixed - Split image turns match `userMessage` on Anthropic, Gemini (+Live), Bedrock, Cohere (#643, #648) - `llmock` now errors on blank `--port`/`--host`/`--latency`/... values instead of starting (#644)
jpr5
added a commit
that referenced
this pull request
Dec 1, 2026
**Merging this publishes @copilotkit/aimock 1.49.0 to npm and aimock-pytest 0.7.4 to PyPI.** ## [1.49.0] - 2026-11-30 ### Added - Replayable seeded chaos: `--chaos-seed`/`x-aimock-chaos-seed`; journal `chaosOrigin` (#618, #653) - Recorder writes `requestHash`; stale replays get journal `staleFixture` and a warning (#640, #651) ### Changed - `aimock-pytest` 0.7.4 defaults to `@copilotkit/aimock` 1.49.0 ### Fixed - Split image turns match `userMessage` on Anthropic, Gemini (+Live), Bedrock, Cohere (#643, #648) - `llmock` now errors on blank `--port`/`--host`/`--latency`/... values instead of starting (#644) Two new features, so this is a minor release. ## Version carriers (from `git grep -F 1.48.1`) Bumped to 1.49.0: - `package.json` version - `charts/aimock/Chart.yaml` appVersion - `.claude-plugin/plugin.json` version - `.claude-plugin/marketplace.json` source version (`^1.49.0`) - `docs/index.html` banner - `packages/aimock-pytest/README.md` `--aimock-version` default - `packages/aimock-pytest/src/aimock_pytest/_version.py` `AIMOCK_VERSION` Also bumped: `packages/aimock-pytest/pyproject.toml` 0.7.3 → 0.7.4, because the pin moved (same pattern as #628). Left as is: the `## [1.48.1]` CHANGELOG section. ## CHANGELOG edits - `## [Unreleased]` becomes `## [1.49.0] - 2026-11-30`. - Seven bullets became four, plus the aimock-pytest `Changed` line: the two #618 lines are one, #643 and #648 are one, and #651 joins the stale-fixture line. - The stale-fixture line now references PR #640 instead of issue #638. ## Docs - `docs/record-replay`: the `llmock` flag table gets `--chaos-seed` and `--chaos-keys-max`, and a note that blank `--port`/`--host`/`--latency`/`--journal-max`/`--fixture-counts-max` values are a usage error (#644). - `docs/fixtures`: the "last user message" rule now says a trailing image-only user message is skipped (#643, #648). - `README.md`: the Record & Replay line mentions stale-fixture flagging. Seeded chaos was already in the Chaos Testing line. Already covered, left alone: `docs/chaos-testing` (seeds, `x-aimock-chaos-seed`, `chaosOrigin`, `--chaos-keys-max`) and the Stale Fixtures section of `docs/record-replay` (`requestHash`, `staleFixture`, the `STALE FIXTURE` warning, `requestTransform`). The `package.json` description already matches the README subtitle. ## Local checks - `pnpm install --frozen-lockfile`, `format:check`, `lint`, `typecheck`, `build`: pass - `api:report`: 14 entries, 0 failed, no report change - `vitest run`: 503 files, 20,346 passed, 11 skipped
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Gemini Live client sends a prompt and then an image only turn, a
userMessagefixture now matches the prompt, the same as every other provider after #643.What this code is for
geminiTurnsToMessagesturns theturnsof each LiveclientContentmessage into the sharedChatMessage[]list (called here). The handler then matches fixtures on the whole session,[...session.conversationHistory, ...newMessages], andgetLastUserTextpicks the user text auserMessagefixture is compared against: it skips user messages whose content isnulland stops at the first string, including"".Before this PR
A test using a strict LLMock with the fixture
{ match: { userMessage: "what is in this image" } }opens the Live WebSocket and sends oneclientContentwith two user turns: the prompt, then a turn holding only aninlineDataimage.geminiTurnsToMessagesconverts the prompt turn to{ role: "user", content: "what is in this image" }.textpart, so the plain user branch joins zero parts and pushes{ role: "user", content: "" }.getLastUserTextreaches that message first, sees"", and returns it."", so strict mode closes the socket with 1008.clientContentafter the prompt fails the same way, since the history ends with that""message too.After this PR
Same test, same message.
textpart, so its content is nownull.getLastUserTextskips thenullmessage and returns"what is in this image".serverContentwith "A logo.".{ text: "" }, or with an emptypartslist, still converts to"", so fixtures keyed on an empty body behave as before.flowchart LR classDef box fill:#eef1ff,stroke:#4c5bd4,color:#111827 classDef bad fill:#ffd6d6,stroke:#cc0000,color:#111827,stroke-width:3px classDef good fill:#c8f0c8,stroke:#008800,color:#111827,stroke-width:3px subgraph BEFORE["BEFORE: strict close 1008"] direction TB B1["clientContent: prompt turn, image only turn"] --> B2["geminiTurnsToMessages"] B2 --> B3{"image only turn"} B3 -->|"content becomes empty string"| B4["getLastUserText returns empty string"] B4 --> B5["no fixture matched, close 1008"] B3 -->|"turn with a text part"| B6["text kept"] end subgraph AFTER["AFTER: fixture matches, A logo."] direction TB A1["clientContent: prompt turn, image only turn"] --> A2["geminiTurnsToMessages"] A2 --> A3{"THE CHANGE: no text part means null"} A3 -->|"image only turn is null"| A4["getLastUserText skips it, returns prompt"] A4 --> A5["userMessage fixture matches"] A3 -->|"text part or empty parts"| A6["same as before"] end B1 ~~~ A1 class B1,B2,B6 box class A1,A2,A6 box class B3,B4,B5 bad class A3,A4,A5 good linkStyle 2 stroke:#cc0000,stroke-width:5px linkStyle 7 stroke:#008800,stroke-width:5px style BEFORE fill:#fff5f5,stroke:#cc0000,color:#111827 style AFTER fill:#f3fff3,stroke:#008800,color:#111827geminiTurnsToMessages with its one caller processMessage and its one callee generateToolCallId, Functions view in Architect
The change
In
src/ws-gemini-live.ts, the plain user branch ofgeminiTurnsToMessagesnow uses the same rule as the generateContent branch insrc/gemini.ts:That is the whole fix.
clientContentis the only Live message that builds user messages (toolResponseonly buildstoolmessages, anything else is rejected), so nothing else needed to change. Thenullgoes through the same matching and journal code that #643 already sendsnullthrough for Gemini generateContent.The new
src/__tests__/split-image-turns-live.test.tssits next to the #643 tests and covers: the split in oneclientContent, the image sent as its ownclientContentafter the prompt, an explicit{ text: "" }part, an emptypartslist, and one turn mixing text and an image. On main the first four fail (two strict closes, two""wherenullis expected), and all five pass here. Typecheck, lint, prettier and the full test suite pass.What changes for a user
userMessagefixture on Gemini Live, whether both turns come in oneclientContentor in two.{ text: "" }or no parts match exactly as before.CHANGELOG.mdso you don't have to write one this time. It has no PR number yet; would you rather I add the number, or fold it into the fix: match userMessage fixtures on split image turns for Anthropic, Gemini, Bedrock and Cohere #643 line?Hope you're doing well @jpr5, and thanks again for merging #643 so quickly and for the note that Gemini Live could come as its own PR. Your
hasTextshape fromgemini.tscarried straight over, so this one stayed tiny.