Skip to content

fix(google): stabilize thought-signature replay and evict rejected signatures on every mode (rebase of #2513) - #2577

Merged
lidge-jun merged 2 commits into
devfrom
codex/google-signature-2513
Aug 25, 2026
Merged

lidge-jun merged 2 commits into
devfrom
codex/google-signature-2513

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Rebase of #2513 (by @Hsia97) onto current dev, with the review finding fixed.

The original change stabilizes thought-signature replay across repeated and truncated
history. The review objected that eviction was gated on cloud-code-assist/vertex
while the durable store is not mode-scoped, and that is correct: signatures are written by
rememberAndSerializeExtraContent and read back by lookupReplayThoughtSignature on
every Google mode, AI Studio included (src/adapters/google.ts:311).

So an AI Studio turn whose signature the upstream rejected kept that signature in the
store and replayed it into every following turn — the store poisons itself and the request
keeps failing with the same rejection. Eviction now follows the same scope the write does.

Clearing the in-memory Antigravity replay cache stays CCA/Vertex-scoped, because that
cache only exists for those modes.

The test-home isolation the review also asked for is already present on this branch
(OPENCODEX_HOME is redirected to an mkdtemp directory in beforeEach).

Closes #2513.

Verification

The added regression was driven red first:

# with eviction re-gated on CCA/Vertex (the pre-fix behaviour)
$ bun test tests/google-signature-history-roundtrip.test.ts
 31 pass, 1 fail   <- only the ai-studio case fails

# with the fix
$ bun test tests/google-signature-history-roundtrip.test.ts
 32 pass, 0 fail

$ bun x tsc --noEmit
(clean)

The new block covers both ai-studio and vertex so the mode symmetry stays pinned.

Checklist

  • Targets dev
  • Rebased onto the current dev head (1/1, no conflicts)
  • Regression driven red first, then green
  • Typecheck clean
  • Original authorship preserved in the commit history
  • No secrets or account identifiers in the diff

Summary by CodeRabbit

  • Bug Fixes

    • Improved replay of thought signatures across repeated and interleaved tool calls.
    • Preserved client-provided signatures and restored saved signatures after process restarts.
    • Improved handling of rejected signatures by removing invalid replay data consistently.
    • Added support for matching custom-tool JSON inputs against parsed arguments.
  • Reliability

    • Enforced per-signature and per-session storage limits.
    • Added durable deletion and cleanup of invalid replay entries.

Hsia97 and others added 2 commits August 26, 2026 00:50
…rtex

The durable replay store is not mode-scoped: signatures are written by
rememberAndSerializeExtraContent and read back by lookupReplayThoughtSignature
on every Google mode, AI Studio included. Eviction was gated on
cloud-code-assist/vertex, so an AI Studio turn whose signature the upstream
rejected kept that signature in the store and replayed it into every following
turn - the store poisons itself and the request keeps failing.

Eviction now follows the same scope the write does. Clearing the in-memory
Antigravity cache stays CCA/Vertex-scoped because that cache only exists there.

Driven red first: with eviction re-gated on CCA/Vertex only the ai-studio case
fails (31 pass / 1 fail); with the fix 32 pass.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 25, 2026 15:53
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 25, 2026
@lidge-jun
lidge-jun merged commit 4d3d271 into dev Aug 25, 2026
8 of 9 checks passed
@lidge-jun
lidge-jun deleted the codex/google-signature-2513 branch August 25, 2026 15:53
@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 71b8fa24-be09-4fc3-a099-dddc0cd87ffe

📥 Commits

Reviewing files that changed from the base of the PR and between dd0f4af and 10c112e.

📒 Files selected for processing (6)
  • src/adapters/google-antigravity-replay.ts
  • src/adapters/google.ts
  • src/responses/thought-signature-replay.ts
  • tests/google-antigravity-replay.test.ts
  • tests/google-signature-history-roundtrip.test.ts
  • tests/thought-signature-credential-scope.test.ts

📝 Walkthrough

Walkthrough

Google thought-signature replay now retains bounded history for repeated calls, restores signatures from the end of truncated history, preserves client signatures, and removes rejected signatures from durable storage across request modes.

Changes

Thought-signature replay

Layer / File(s) Summary
Retain signature history
src/adapters/google-antigravity-replay.ts
Replay entries retain up to 32 signatures. Snapshot loading remains backward compatible. Observation and serialization update byte accounting and retained history.
Restore signatures by occurrence
src/adapters/google-antigravity-replay.ts, tests/google-antigravity-replay.test.ts, tests/google-signature-history-roundtrip.test.ts
Replay scans calls from the end, matches repeated and interleaved occurrences to retained signatures, preserves existing signatures, and supports custom-tool arguments.
Evict rejected durable signatures
src/adapters/google.ts, src/responses/thought-signature-replay.ts, tests/google-signature-history-roundtrip.test.ts
Request serialization tracks replayed call IDs. Shared rejection handling clears durable signatures for AI Studio and Vertex flows. The new helper removes scoped entries and updates persistence.
Validate scoped replay behavior
tests/google-signature-history-roundtrip.test.ts, tests/thought-signature-credential-scope.test.ts
Tests cover scope isolation, selective and conservative batch eviction, persistence, process restart, and deterministic Windows ACL seams.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: ingwannu

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/google-signature-2513

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.

@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: 10c112ea2b

ℹ️ 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
Comment on lines 1267 to +1269
if (raw.error) {
const err = raw.error as { message?: string };
handleSignatureRejection(err.message);

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 Route signature eviction through the HTTP-error path

A normal Gemini signature rejection is an HTTP 400, but the production Responses flow returns from src/server/responses/core.ts:4948-5005 before calling parseResponse or parseStream, so this handler never runs and the rejected durable signature continues poisoning subsequent turns. The new tests hide this by invoking adapter.parseResponse directly on a 400 response; expose invalidation through the non-2xx transport path and add a server-level regression that exercises an actual provider 400.

AGENTS.md reference: src/AGENTS.md:L17-L19

Useful? React with 👍 / 👎.

tarunravi pushed a commit to tarunravi/opencodex that referenced this pull request Sep 14, 2026
…gnatures on every mode (rebase of lidge-jun#2513) (lidge-jun#2577)

* fix(google): stabilize thought-signature replay across repeated and truncated history

* fix(google): evict rejected signatures on every mode, not just CCA/Vertex

The durable replay store is not mode-scoped: signatures are written by
rememberAndSerializeExtraContent and read back by lookupReplayThoughtSignature
on every Google mode, AI Studio included. Eviction was gated on
cloud-code-assist/vertex, so an AI Studio turn whose signature the upstream
rejected kept that signature in the store and replayed it into every following
turn - the store poisons itself and the request keeps failing.

Eviction now follows the same scope the write does. Clearing the in-memory
Antigravity cache stays CCA/Vertex-scoped because that cache only exists there.

Driven red first: with eviction re-gated on CCA/Vertex only the ai-studio case
fails (31 pass / 1 fail); with the fix 32 pass.

---------

Co-authored-by: Hsia97 <[email protected]>
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…gnatures on every mode (rebase of lidge-jun#2513) (lidge-jun#2577)

* fix(google): stabilize thought-signature replay across repeated and truncated history

* fix(google): evict rejected signatures on every mode, not just CCA/Vertex

The durable replay store is not mode-scoped: signatures are written by
rememberAndSerializeExtraContent and read back by lookupReplayThoughtSignature
on every Google mode, AI Studio included. Eviction was gated on
cloud-code-assist/vertex, so an AI Studio turn whose signature the upstream
rejected kept that signature in the store and replayed it into every following
turn - the store poisons itself and the request keeps failing.

Eviction now follows the same scope the write does. Clearing the in-memory
Antigravity cache stays CCA/Vertex-scoped because that cache only exists there.

Driven red first: with eviction re-gated on CCA/Vertex only the ai-studio case
fails (31 pass / 1 fail); with the fix 32 pass.

---------

Co-authored-by: Hsia97 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants