Skip to content

[WRONG BRANCH] fix(google): prevent backward attachment of thought signatures in streaming parser - #322

Closed
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-streaming-parser
Closed

[WRONG BRANCH] fix(google): prevent backward attachment of thought signatures in streaming parser#322
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-streaming-parser

Conversation

@luvs01

@luvs01 luvs01 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a streaming-parser ordering bug where a later thought_signature in the same SSE frame could be attached backwards to an earlier unsigned functionCall, corrupting replay metadata and causing subsequent replay/serialization errors.

Description

  • In src/adapters/google.ts the observer result is now captured to observedStreamThoughtSig and only published to pendingStreamThoughtSig after parts are emitted in source order, avoiding backward pairing.
  • The change preserves cross-chunk carry and the existing observeAntigravityReplay behavior while ensuring per-frame fallback metadata cannot be applied to earlier parts.
  • Added a regression test in tests/google-signature-history-roundtrip.test.ts that emits an SSE frame with an earlier unsigned call, a later thought part with thought_signature, and a following call, asserting only the following call receives the signature.

Testing

  • git diff --check completed successfully.
  • bun test tests/google-signature-history-roundtrip.test.ts tests/google-antigravity-replay.test.ts passed (focused Google adapter tests).
  • bun run typecheck completed successfully.
  • bun run privacy:scan completed successfully.
  • A repository-wide bun run test was 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

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 68bf6594-7c9a-46da-8fb7-aab8a524fd70


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 20, 2026
@github-actions github-actions Bot changed the title fix(google): prevent backward attachment of thought signatures in streaming parser [WRONG BRANCH] fix(google): prevent backward attachment of thought signatures in streaming parser Aug 20, 2026
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 20, 2026 15:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/adapters/google.ts
// 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@luvs01 luvs01 closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant