Repository navigation
Conversation
[bot] 🏷 查重: 不重复 — searched open+closed issues and PRs for "turn bleed" / "tag-echo" / "USER_REQUEST": only #7416 (source issue) and #7417 (this PR) exist for this topic. No prior fix, no parallel PR. 标签: bug + antigravity + scope/wiring + p1 — defect fix in the Google wire adapter; the affected client is Antigravity (agy) on the v1internal lane; p1 because triggering means the client executes tool calls the user never issued (core promise failure). Review of PR #7417① Original issue (direction gate). #7416 is real and well-evidenced (sanitized logs, 3 repros, exact mechanism). Root-cause layering: the model-side conditioning (≈100+ render tags → missed native turn stop) is upstream and unfixable here; the in-repo root cause is that the loop has no turn-boundary judgment — every ② Regression review (existing behavior of touched paths, pre-change code read):
③ Code review. Proper streaming state machine: line-based scan, CommonMark-faithful fence approximation (≥3 backticks/tildes, closing fence same char + ≥ length + whitespace-only tail, backtick info string may not contain a backtick), CRLF-aware, re-scans from the held prefix on every ④ Test validity. 9 tests with real teeth, both directions per gate discipline #3617: 5 positive bleed variants (single chunk, split across chunks, bare envelope, SYSTEM_MESSAGE sentence, CRLF) asserting the exact cut text, zero fake bytes on the wire, no post-bleed ⑤ Diff cleanliness. 2 files, +526/−2, single commit, base current (0 behind master), ⑤b Code cleanliness. Naming consistent with the repo's CI: 30/30 checks completed on the pushed head, 0 failures — all Two disclosure notes:
Hot-file note (non-blocking): open PRs #7181 (tag-echo mangled names, touches 结构化八问
判定:可合并 — mergeable=true、CI 30/30 绿、base 最新、diff 干净、测试有牙且双向。等 owner 合并。 |
Fixes #7416
What broke
After ~100 tagged messages in a long Google session, the model sometimes misses its turn stop and emits a hallucinated "\nuser\n" turn followed by a fake user request and real functionCall parts in the same response. The tag-echo filter stripped the echoed tags but let the fake user prose and the trailing calls through, so the loop executed them as tool calls.
What changed
Added a code-fence-aware turn-bleed circuit breaker in createGoogleAdapter.parseStream. Outside fenced code blocks, a "user" line followed by a render tag or a client user-turn envelope (USER_REQUEST, ADDITIONAL_METADATA, SYSTEM_MESSAGE, or the "The following is a SYSTEM_MESSAGE" sentence) ends the turn: visible text is cut right before "\nuser", later parts in the chunk and stream are dropped, the upstream is cancelled, and the round settles with finishReason STOP. Short ambiguous prefixes are held across SSE chunk boundaries so a bleed split across chunks is still cut whole. Calls buffered before the bleed still settle normally; tool-call arguments are never touched.
How verified
New tests/issue7416-turn-bleed.test.ts, 9 tests: bleed cut with the trailing call suppressed and the upstream cancelled (single chunk, split across chunks, bare envelope, SYSTEM_MESSAGE sentence, CRLF); a pre-bleed proxy call still executes while a post-bleed call does not; fenced examples, innocent "user" lines, and genuine real-turn calls pass through byte-exact. Targeted suites green locally: adapter-google, verif-tag-echo-filter, absorb-emission, tag-echo, loop-adapters, e2e-tag-echo (203 tests total). Full suite verdict is CI.
Notes
No model-facing text changed. Signed text parts are forwarded verbatim per KDD #10 and are only fence-synced, so a bleed inside signed text is not truncated, though later post-bleed calls are still suppressed.