Skip to content

test(drift): accept gemini-3.5-flash-lite wire on the live Gemini legs - #660

Merged
jpr5 merged 4 commits into
mainfrom
fix/drift-gemini-stream-shape
Dec 3, 2026
Merged

jpr5 merged 4 commits into
mainfrom
fix/drift-gemini-stream-shape

Conversation

@jpr5

@jpr5 jpr5 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What happened

The nightly Drift Tests have failed on Gemini since the Dec 1 run (46822766380, 10:11 PM PST) and again on Dec 2 (47048242663). The last good run was 46588624835 (Nov 30). No aimock code changed in between.

The cause is on Google's side. Requests for gemini-2.5-flash are now served by gemini-3.5-flash-lite. Every live response we captured says so: "modelVersion": "gemini-3.5-flash-lite" on GenerateContent, and "model": "gemini-3.5-flash-lite" on Interactions events. The October captures in these tests say gemini-2.5-flash. The new model streams a few things differently, and five live tests read those streams too strictly.

This PR only changes the two Gemini drift test files. The mock is not changed (reasoning below).

Each failing test

Test Live failure message Real wire now Verdict and fix
gemini.drift.ts streaming tool call shape matches [critical] LLMOCK DRIFT ... candidates[].content.parts[].text (mock has functionCall) The functionCall (now with id and thoughtSignature) comes in one chunk. Then a separate last chunk carries parts: [{"text": ""}] and finishReason: "STOP". Seen in 10/10 calls, with and without toolConfig mode ANY, so forcing the tool does not help. Test was comparing the last chunk only. It now compares the chunk that carries the functionCall, against the SDK tool-call shape.
gemini.drift.ts live bounded stop-length-mid-tool stream=false Invalid Gemini content "content": {}, no parts and no role, with MAX_TOKENS (3/3 calls) The reader required a parts array. It now reads absent parts as empty. A non-array parts value still throws.
gemini.drift.ts live bounded reasoning-only stream=true (5 of 6 nightly attempts) (passed in the diagnostic run itself) Every MAX_TOKENS stream now ends with a part holding only "text": "" and a thoughtSignature. When the model only thought (1/13 probe calls), the stream is [thought part] then [{text: "", thoughtSignature}] MAX_TOKENS. That counts as triggered, then fails the thought-only check on the empty part. The native comparison drops empty non-thought text parts. Local strict checks are unchanged.
gemini-interactions.drift.ts 'K9 stream' matches native and localhost expected 'thought_signature' to be 'thought_summary' Thought steps now end with one thought_signature delta right before step.stop (8/11 calls). In the other 3/11 calls the thought step holds only that signature, and an answer step follows (1-6 text deltas, total_output_tokens 2). The live native leg drops exactly one closing signature delta. The summary-less answer is classified as an untriggered K9 and checked strictly for that exact shape. Localhost is then graded against the capture, the same way as the K5 malformed_tool_call outcome. Captured references and localhost stay strict.
gemini-interactions.drift.ts live modeled K5 stream expected undefined to be 'in_progress' interaction.created now has only object and model, with no id and no status. The thought step's only delta is a thought_signature (3/3 calls). On the native side, status may be absent (if present it must be in_progress), and a signature delta is accepted in a thought step. Localhost still must send in_progress. The outcome is NOT_TRIGGERED, as it was before.

The Anthropic and Gemini native-auth differences are unchanged. They are the already-approved policy set.

Why the mock is not changed

The mock's chunks are still valid streams that clients read the same way. The new-model extras (a separate empty STOP chunk, signature deltas, a created event without id or status) are either metadata or model-specific. Older models, and the non-streaming tool call that still passes, keep the old shape. Changing the mock would change every Gemini streaming replay to match one aliased model. One open question for later: Gemini 3 models expect thoughtSignature to be sent back in multi-turn tool calls, and aimock does not emit signatures. That is a separate feature question and is not part of this fix.

Evidence

There are no provider keys locally, so the live probe ran in CI, following the #636 pattern. Commit 95fe7834 added a temporary probe that repeated each live request and wrote the raw native responses. It also added a hook that wrote each failing test's error message, into key-free drift-evidence/ files in the drift-live-pr head artifact. Commit fa34a9b9 took more samples. Commit 881f088d reverted both, with no force-push. The artifacts were scanned for key material, and none was found.

RED

  • Nightly runs 46822766380 and 47048242663: the 5 tests above failed on every attempt (reasoning-only stream=true failed on 5 of 6).
  • drift-live-pr run 47214714903 (2:11 PM PST, diagnostic head). A fresh live base report on main had Google Gemini crit=1. The head capture recorded the failure messages in the table above.
  • drift-live-pr run 47216091504 (2:19 PM PST). It recorded the same 5 messages (reasoning-only stream=true passed in both runs; its failing shape showed up in probe sample k9-stream Add Claude + Gemini provider support, rename to LLMock #9).

Raw excerpts (signatures shortened):

streamGenerateContent, tool call:
data: {"candidates":[{"content":{"parts":[{"functionCall":{"name":"get_weather","args":{"city":"Paris"},"id":"call_816..."},"thoughtSignature":"EqMB..."}],"role":"model"},"index":0}], ... "modelVersion":"gemini-3.5-flash-lite"}
data: {"candidates":[{"content":{"parts":[{"text":""}],"role":"model"},"finishReason":"STOP","index":0}], ... "modelVersion":"gemini-3.5-flash-lite"}

generateContent, K5:
{"candidates":[{"content":{},"finishReason":"MAX_TOKENS","index":0}], ... "modelVersion":"gemini-3.5-flash-lite"}

interactions, K5 stream:
event: interaction.created      data: {"interaction":{"object":"interaction","model":"gemini-3.5-flash-lite"},...}
event: step.start               data: {"index":0,"step":{"type":"thought"},...}
event: step.delta               data: {"index":0,"delta":{"signature":"...","type":"thought_signature"},...}
event: step.stop / interaction.completed (status incomplete) / done

GREEN (head 506f5c7e)

  • drift-live-pr run 47218958655 (2:35 PM PST): success. 75 Gemini assertions passed, including all 5 targets. The only Gemini failure is the approved native-auth comparison. The head report has no Google Gemini entry.
  • Full nightly-equivalent drift job via workflow_dispatch on this branch, run 47218965022 (2:35 PM PST): success, with the same results. The report holds only the approved native-auth criticals.

Offline pins. Real captures from the runs above, pinned by sha256, plus mutations: the K5 content: {}, the K9 thought plus empty-signature stream, the Interactions K9 signed and summary-less streams, and the K5 stream. Each accepted shape compares. Each mutation (non-array parts, a non-empty answer part, a STOP terminal, a completed status, a wrong token total, an empty signature, a wrong created status) still fails. When the fixes are reverted locally, these 4 new tests fail.

Local: vitest --config vitest.config.drift.ts src/__tests__/drift/gemini 56 passed, 20 skipped (no key). tsc -p tsconfig.test.json clean. eslint and prettier clean on both files. No src/ code changed, so there is no CHANGELOG entry.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jay9vBCbXhVHCDgyRBABVx

Diagnostic only, reverted in a follow-up commit. Repeats the live Gemini
requests behind the tests that started failing on 2026-12-01 and writes
the raw native responses, plus each failing test's error messages, into
key-free drift-evidence files that the drift-live-pr head artifact keeps.
@pkg-pr-new

pkg-pr-new Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@660

commit: 506f5c7

jpr5 added 3 commits December 3, 2026 14:18
Diagnostic only, reverted with the probe. Takes more samples of the
GenerateContent and Interactions K9 streams, which vary between calls.
Removes the diagnostic probe and failure capture added in 95fe783 and
widened in fa34a9b. Their evidence is recorded in the pull request.
Since 2026-12-01 Google serves gemini-2.5-flash requests with
gemini-3.5-flash-lite (modelVersion and interaction.model say so). Its
streams differ in ways the live legs read too strictly:

- A streamed tool call ends with a separate { text: "" } STOP chunk, so
  the tool-call shape check now compares the chunk that carries the
  functionCall instead of the last chunk.
- A K5 object that produced nothing has "content": {} with no parts;
  the modeled reader reads absent parts as empty.
- MAX_TOKENS streams end with an empty text part holding only a
  thoughtSignature; the native modeled comparison drops it.
- Interactions thought steps close with one thought_signature delta,
  interaction.created has no id or status, and the K9 stream sometimes
  answers with no thought summary. The live native leg accepts exactly
  these shapes; captured references and localhost stay strict.

Real captures and mutations pin each accepted and rejected shape.
@jpr5 jpr5 changed the title fix(drift): Gemini nightly drift failures since Dec 1 test(drift): accept gemini-3.5-flash-lite wire on the live Gemini legs Dec 3, 2026
@jpr5
jpr5 marked this pull request as ready for review December 3, 2026 22:43
@jpr5
jpr5 merged commit 9830123 into main Dec 3, 2026
38 checks passed
@jpr5
jpr5 deleted the fix/drift-gemini-stream-shape branch December 3, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant