Skip to content

test: accept Vertex stream interpreter anomaly; keep measuring after rejections - #526

Merged
jpr5 merged 3 commits into
mainfrom
fix/drift-vertex-misbehavior-suite
Oct 11, 2026
Merged

jpr5 merged 3 commits into
mainfrom
fix/drift-vertex-misbehavior-suite

Conversation

@jpr5

@jpr5 jpr5 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Drift Tests run 38158387279 (main @ 9420afa) failed k5-stream with FAILURE / MAX_TOKENS / WIRE_OR_SDK_REJECTED. Vertex streamed the known interpreter anomaly as two chunks: a google:python_interpreter call, then a MAX_TOKENS terminal with one empty text part. The suite only accepted that anomaly in object mode. k9-object and k9-stream were then UNATTEMPTED (earlier-case-failed), so we could not see their live behavior.

Live measurement (2026-10-11, llmock-drift-testing / us-central1 / gemini-2.5-flash, exact drift request bytes)

Case n Outcome Count Before After
k5-object 60 interpreter anomaly, Tokyo 29 accepted accepted
k5-object interpreter anomaly, London 1 rejected accepted
k5-object MALFORMED_FUNCTION_CALL, content: {} 30 accepted accepted
k5-stream 60 two-chunk interpreter anomaly, Tokyo 30 rejected accepted
k5-stream two-chunk interpreter anomaly, London 2 rejected accepted
k5-stream MALFORMED_FUNCTION_CALL 28 accepted accepted
k9-object 20 thought + visible text, MAX_TOKENS 15 accepted accepted
k9-object reasoning-only, MAX_TOKENS (target) 5 accepted accepted
k9-stream 20 thought + visible text + empty terminal 18 accepted accepted
k9-stream reasoning-only, MAX_TOKENS (target) 2 accepted accepted

Before this change, k5-stream was rejected in 32 of 60 runs. After it, all 161 captures are accepted (the 160 local captures plus the CI capture).

Changes (src/__tests__/drift/vertex-misbehavior.drift.ts only)

  1. Comparator, native leg only. Accepts the stream interpreter anomaly only in its observed shape, checked position by position: chunk 1 carries only the interpreter call, and chunk 2 is the MAX_TOKENS terminal with exactly one {text: ""} part. Accepts the first-city codes Tokyo and London, both observed live. The K5 prompt names no cities (it asks for "200 distinct full city names"), so there is no list to derive from the request. The accepted list comes from observation only, and any other city is still rejected. The modeled leg stays strict. Other terminals, function names, cities, args and call fields, and any thought, non-empty or extra parts, are still rejected.
  2. Recurrence runner. When the comparator rejects a complete HTTP 200, that case is recorded as FAILURE and the run continues to the remaining cases. HTTP, transport and byte-bound failures still stop the run. The per-case assertions and the 4-send / 160-token budget are unchanged.

Red / green

  • RED (before the fix): the CI capture (sha256 6c4382…87a5) and the London captures are rejected with contradictory-target: K5 tool or thought, the same rejection as CI. The recurrence stopped after 2 requests. Result: 4 failed / 93 passed.
  • GREEN (after the fix): 99 passed / 4 skipped (live-only).
  • Mutants that still fail: the anomaly on the modeled leg; STOP and SAFETY terminals; a non-interpreter name; the declared archive tool; non-empty text; a thought part; an extra part; an unobserved city; an extra arg; an extra call field; a second call; call and text merged into one chunk; an empty first chunk with the call and text in the terminal; the call and text in the first chunk with an empty terminal; the call in the terminal with the text in the first chunk.
  • Positional check (review fix): with the old position-blind check, the empty-first-chunk and call-plus-text-in-first-chunk mutants were accepted (2 failed). With the per-chunk check, all 102 pass, and removing any one positional check fails at least one test. All 161 live captures are still accepted.
  • Mutation testing: each new guard was removed in turn, and at least one test fails for each.
  • Live (AIMOCK_VERTEX_LIVE=1, ADC token, same project): the file passed 5 consecutive times, 103/103 each time. All 4 cases ran every time, with none UNATTEMPTED. The stream anomaly was accepted live in runs 3 and 4. After the positional fix, 2 more consecutive live passes ran (106/106 each, all 4 cases run), and the stream anomaly was accepted live in both.

Gates

pnpm typecheck, pnpm lint, pnpm format:check, pnpm build and pnpm test all pass (377 files, 14073 tests).

jpr5 added 2 commits October 11, 2026 10:28
Live k5 measurement (2026-10-11, exact drift request) showed the
interpreter anomaly in stream mode as two chunks: the call, then a
MAX_TOKENS terminal with one empty text part (32/60 runs). The first
city also varies: 59 Tokyo, 3 London over 120 k5 runs.

Accept exactly those shapes on the native leg only. The modeled leg
stays strict, and other terminals, names, cities, or extra output are
still rejected. Adds the sha256-pinned CI run 38158387279 capture and
two London captures.
The recurrence runner stopped at the first failed case, so a rejection
in k5-stream left k9-object and k9-stream UNATTEMPTED and hid their
live behavior until a later CI run.

A complete HTTP 200 that the comparator rejects is now recorded as that
case's FAILURE and the run continues. HTTP, transport, and byte-bound
failures still stop before another send. Per-case assertions and the
4-send / 160-token budget are unchanged.
@pkg-pr-new

pkg-pr-new Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 97fda90

…maly

The stream check counted parts across chunks, so an empty first chunk
with the call and text in the terminal, or the call and text in the
first chunk with an empty terminal, were wrongly accepted. Require
chunk 1 to carry only the call and chunk 2 (MAX_TOKENS) exactly one
empty text part, with mutants for each misplacement.

Also document that the K5 prompt names no cities, so the accepted
first-city codes stay observation-only.
@jpr5
jpr5 merged commit 1ba9750 into main Oct 11, 2026
33 checks passed
@jpr5
jpr5 deleted the fix/drift-vertex-misbehavior-suite branch October 11, 2026 18:09
jpr5 added a commit that referenced this pull request Oct 11, 2026
## What

The Vertex K5 interpreter-anomaly check in
`src/__tests__/drift/vertex-misbehavior.drift.ts` matched only two first
cities, Tokyo and London. Those are the cities seen live in #526. The K5
prompt ("Call archive with an array of 200 distinct full city names...")
names no cities, so any first city is legitimate. A city not in the list
would raise a false drift alert.

The check now matches
`/^print\(default_api\.archive\(cities=\['[^'\\\n\r]*[^'\\\s][^'\\\n\r]*$/`.
That is the archive prefix and one unfinished city with no quote,
backslash or newline, and not blank. All 63 interpreter anomalies in the
161 live captures from 2026-10-11 have exactly this shape (60 Tokyo, 3
London). None has more than one city.

Everything else is unchanged: the `google:python_interpreter` call name,
exactly one argument, no extra call fields, the two-chunk stream
position rules, the MAX_TOKENS terminal with empty text, and native leg
only. A short comment at the check explains why any city is accepted and
what is still enforced.

## Tests

- New: Paris variants (stream and object) are accepted on the native leg
and rejected on the modeled leg.
- Removed: the "unobserved first city is rejected" mutant. That behavior
is intentionally gone.
- New mutants that must fail: empty city (`cities=['`), empty quoted
city (`['']`), whitespace-only city (`[' `), a finished call
(`['Tokyo'])`), trailing code (`['Tokyo'] + x`), leading code before the
call, a non-archive tool in the code (`default_api.search(...)`), and a
different prefix (`archive(names=[...`). The existing mutants still
fail: extra argument, extra call field, non-interpreter name, the
declared archive tool, chunk placement.
- Regex mutation check: using `\S` for the required character (it can
match the closing quote), removing either anchor, or making the city
optional each fails at least one test. Removing `origin === "native"`
fails 7 modeled-leg tests.
- Replay of all 161 live captures through the classifier: same verdict
for every capture before and after the regex change, 0 rejected, 63
interpreter anomalies.

## Local red/green

RED (Tokyo/London list, Paris variants):
```
AssertionError: contradictory-target: K5 tool or thought
Tests  2 failed | 2 passed | 108 skipped (112)
```

RED for the tightening (prefix-only check, new negative tests):
```
Tests  4 failed | 108 passed | 4 skipped (116)
```

GREEN (final, full drift file):
```
Tests  113 passed | 4 skipped (117)
```

## Live (`AIMOCK_VERTEX_LIVE=1`, gemini-2.5-flash, us-central1)

Two consecutive runs on the final code, 4/4 cases run and passed each
time:
- Run 1: k5-object and k5-stream `approved-interpreter-anomaly`;
k9-object and k9-stream `visible-answer-completion`.
- Run 2: k5-object and k5-stream `approved-interpreter-anomaly`;
k9-object `reasoning-only-exhaustion`, k9-stream
`visible-answer-completion`.

## Gates

`pnpm typecheck`, `pnpm lint`, `pnpm format:check`, `pnpm build` and
`pnpm test` (377 files, 14079 passed) all pass.
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