Repository navigation
test: accept Gemini Interactions upstream nondeterminism on live native legs - #522
Merged
Merged
Conversation
…ve legs The live K5 object request sometimes gets a 400 malformed_tool_call from Google (2/28 calls), and the live K9 requests sometimes add one trailing model_output step after the thought (3/47 object, 1/47 stream). No max_output_tokens value from 8 to 128, and no thinking_level, made the trigger reliable. The live native leg now accepts exactly these variants. The K9 variant is validated, then removed, and the rest must pass the unchanged strict thought-only contract. Captured references and localhost stay strict. Real variant captures and mutations pin both the accepted and rejected shapes.
commit: |
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.
Problem
Three "Gemini Interactions live incomplete contracts" drift tests fail now and then on main (Scheduled Drift Tests run 38030209547, and PR #520's drift-live-pr run 38091527077):
'K5 object':expected 400 to be 200'K9 object':expected [...] to have a length of 1 but got 2(steps)'K9 stream': same cause, seen in run 37994194206Root cause: upstream model nondeterminism
aimock and the test's request are both fine. I re-sent the test's exact requests to live
gemini-2.5-flashon 2026-10-10:{"error":{"message":"Model generated invalid JSON syntax ...","code":"malformed_tool_call"}}model_outputstep after the thought (1-2 output tokens)thought_signaturedelta, then amodel_outputstep with one text delta (plus one failed local test run)The failing K9 assertion is the native-side check (
incompleteContract(nativeRaw), line 510), not localhost.I also tried making the K9 trigger reliable by changing the request. No value fixed it:
max_output_tokensthinking_level: "low"was worse (3/6 and 4/6)."medium"is rejected with a 400 by this model.Change (one test file only)
{"error":{"message":<string>,"code":"malformed_tool_call"}}. Any other status, code or body shape still fails. Localhost is still graded strictly against the capture.model_outputstep with one non-empty text part.thought_signaturedelta closing step 0, then 1-6 text deltas in step 1.max_output_tokensstays at 32. Captured references, derived segmentation tests and localhost stay strict.Mutation check
These tests run without a key. I changed the new contract code one way at a time to see whether a test catches each change. All 12 changes were caught (at least 1 test failed for each):
step.startcheck, the object answer shape check, or the non-empty answer text checksRejected mutant shapes include:
model_outputsteps, wrong order, wrong step type, an extra field, empty or doubled content, 0 or 7 output tokens,output_textset,status: completedinvalid_requestorMALFORMED_TOOL_CALL, a missing code, extra fields, statuses 200/429/500, a non-JSON bodyRED (before, live,
npx vitest run --config vitest.config.drift.ts src/__tests__/drift/gemini-interactions.drift.ts -t "live incomplete")The K5 400 and K9 object variant reproduced in direct live probes (table above). CI shows the same failures.
GREEN (after, live,
npx vitest run --config vitest.config.drift.ts src/__tests__/drift/gemini-interactions.drift.ts, two consecutive runs)At a ~5% rate, the live runs mostly exercise the strict path. The keyless variant tests exercise the accept path with real captured variant bodies.
Gates
pnpm typecheck,pnpm lint,pnpm format:checkandpnpm buildall pass.pnpm test: 377 files, 14073 passed, 3 skipped. Nosrc/changes, so the public API and types are unchanged.Review follow-up
I checked the review findings against live evidence before changing anything:
model_outputstep all reporttotal_output_tokens: 0in final usage: 11 new probes atmax_output_tokens: 16, where the variant shows up 11/12 times, plus the two earlier captures. A further 20 probes at 32 had no variant. Unlike the object, the stream reports 0, so the strict check is correct.thought_signaturedeltas): no change. None of 20 live K5 stream calls had a thought step or athought_signaturedelta. 19 had no steps at all, and 1 returned HTTP 400malformed_tool_call. The signature capture in this PR is a K9 stream.Re-check after this change: the live drift command for this file passed 30/30 on two more consecutive runs. All gates pass again, and
pnpm testis 14073 passed, 3 skipped.Earlier CI note:
test (22)failed once onvalidate CLI — report-mode consistency > does not print OK ...because the random temp dir/tmp/aimock-validate-modes-GEgOKgcontains "OK". The same test failed on main in run 38007611924. The rerun passed.