[WRONG BRANCH] fix(google): prevent backward attachment of thought signatures in streaming parser - #322
[WRONG BRANCH] fix(google): prevent backward attachment of thought signatures in streaming parser#322luvs01 wants to merge 1 commit into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Its title has been prefixed with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bcf3b528f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // The observer scans the complete frame to populate replay state. Publish its carried | ||
| // signature only after emitting parts in source order, so a later thought part cannot | ||
| // supply fallback metadata to an earlier function call in the same frame. | ||
| pendingStreamThoughtSig = observedStreamThoughtSig; |
There was a problem hiding this comment.
Preserve signature carry when replay observation is inactive
For streaming AI Studio requests, the replay observer is skipped by the googleMode guard, so observedStreamThoughtSig retains the value from before this frame. After the loop records a standalone thought signature in pendingStreamThoughtSig, this assignment immediately resets it; if the corresponding unsigned function call arrives in a later SSE frame, its tool_call_start lacks the required Google signature metadata and the subsequent tool-result turn can be rejected by Gemini. Keep the source-order value computed by the loop authoritative (and invoke the observer only for its replay-cache side effect), including for modes such as Claude-on-Antigravity where the observer returns without scanning.
AGENTS.md reference: src/AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
Motivation
thought_signaturein the same SSE frame could be attached backwards to an earlier unsignedfunctionCall, corrupting replay metadata and causing subsequent replay/serialization errors.Description
src/adapters/google.tsthe observer result is now captured toobservedStreamThoughtSigand only published topendingStreamThoughtSigafter parts are emitted in source order, avoiding backward pairing.observeAntigravityReplaybehavior while ensuring per-frame fallback metadata cannot be applied to earlier parts.tests/google-signature-history-roundtrip.test.tsthat emits an SSE frame with an earlier unsigned call, a later thought part withthought_signature, and a following call, asserting only the following call receives the signature.Testing
git diff --checkcompleted successfully.bun test tests/google-signature-history-roundtrip.test.ts tests/google-antigravity-replay.test.tspassed (focused Google adapter tests).bun run typecheckcompleted successfully.bun run privacy:scancompleted successfully.bun run testwas run and exposed unrelated pre-existing management-auth expectations failing (HTTP 403 vs expected statuses) that are not caused by this focused adapter change.Codex Task