Skip to content

fix(agent): withhold replay metadata when a tool call was suppressed - #3826

Merged
kojiwakayama merged 4 commits into
mainfrom
fix/google-replay-mismatch-fallback
Aug 17, 2026
Merged

fix(agent): withhold replay metadata when a tool call was suppressed#3826
kojiwakayama merged 4 commits into
mainfrom
fix/google-replay-mismatch-fallback

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #3820, closing the residual replay failure found in review.

When a streamed Gemini turn contained an unavailable call alongside signed replay content, the runtime removed the unavailable call from canonical history. Replaying the original raw metadata then failed exact-history validation, but removing all metadata also stripped signatures from valid surviving calls and reasoning.

Change

  • Ask the model runtime to reconcile opaque provider metadata after a tool call is suppressed, including when no tool call survives.
  • Fall back to synthesized replay for public custom runtimes that do not expose the private reconciliation hook.
  • Fail closed when surviving calls cannot retain reconciled replay metadata.
  • Let Google remove only suppressed raw tool parts while preserving exact signed surviving calls and non-tool reasoning.
  • Keep a reasoning-only assistant turn provider-sendable when exact replay metadata is attached.
  • Preserve validated original raw-part indexes so filtering cannot renumber anonymous surviving calls.
  • Reject reconciliation when a remaining Google tool call has no replay signature.
  • Keep provider-specific wire knowledge out of the core agent loop.

Testing

  • RED: the mixed-call continuation synthesized a valid Gemini call without its thought signature.
  • RED: filtering an earlier anonymous call renumbered the surviving tool-1 call to tool-0 and failed exact replay validation.
  • RED: a custom public runtime without the private hook aborted before its continuation.
  • RED: an all-suppressed Gemini tool turn dropped the signed non-tool reasoning metadata.
  • GREEN: the Google runtime replays signed surviving content and omits unavailable calls.
  • GREEN: custom runtimes fall back to synthesized replay without an API-breaking hook requirement.
  • Direct reconciliation tests cover unchanged metadata, all calls suppressed, and unsigned-survivor rejection.
  • Google request, provider, stream-handler, continuation, and message-converter suites pass: 224 steps.
  • Changed-file format, lint, typecheck, and diff checks pass.
  • The branch is based on main commit 2c2091a3975eb9ec8005f62dc56643cf31ac8e9c.

Risk

Moderate and contained. The core runtime treats metadata as opaque. Google owns validation and reconstruction. Unsupported custom runtimes retain the synthesized-replay behavior from the first fix, while unsafe provider-specific reconciliation paths fail closed.

Refs VERYFRONT-AGENT-9

@github-actions

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 325 1937 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.


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: 24b4cb84b6

ℹ️ 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/agent/runtime/index.ts Outdated
@kojiwakayama
kojiwakayama force-pushed the fix/google-replay-mismatch-fallback branch from 24b4cb8 to 8ec96ec Compare August 17, 2026 14:15
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review exact rebased head 8ec96ecbca0404869d8029692750148dcc82ddcd. The P1 is fixed with provider-owned reconciliation, signed-survivor RED-GREEN coverage, fail-closed unsigned behavior, and all prior threads resolved.

@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: 8ec96ecbca

ℹ️ 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 extensions/ext-llm-google/src/google-thought-signatures.ts
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review exact head 97f4b42b5d0b93fb1ea7e0e14b946dd7a0601cb8. The anonymous survivor P1 is fixed by validated original raw-part indexes that are used for correlation but not sent to Google. All prior threads are resolved.

@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: 97f4b42b5d

ℹ️ 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/agent/runtime/index.ts Outdated
Comment thread src/agent/runtime/index.ts Outdated
@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 17, 2026
@kojiwakayama
kojiwakayama force-pushed the fix/google-replay-mismatch-fallback branch from b76d1b1 to 5cc8434 Compare August 17, 2026 14:47
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review exact head 5cc843480542760528724698938460e50f271dff. Both P1 findings are fixed with RED-GREEN coverage: all-suppressed signed reasoning is reconciled and retained, reasoning-only exact replay remains provider-sendable, and public custom runtimes without the private hook fall back without aborting. All review threads are resolved; the five focused suites pass 224 steps.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 5cc8434805

ℹ️ 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".

PR #3820 attaches the provider's raw replay metadata to every streamed
assistant message, but when the runtime suppresses an unavailable tool
call the persisted parts no longer mirror the raw model turn. The Google
request builder then fails its exact-history validation
(validateGoogleToolReplay throws TypeError) before any request is sent,
killing the continuation client-side.

Skip the metadata attach when state.suppressedToolCalls is non-empty so
the continuation falls back to synthesized parts — the pre-#3820
behavior for that turn — while the extension's fail-fast validation for
genuinely corrupted history stays intact.

Refs VERYFRONT-AGENT-9
@kojiwakayama
kojiwakayama force-pushed the fix/google-replay-mismatch-fallback branch from 5cc8434 to 109de08 Compare August 17, 2026 15:23
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

@codex review exact rebased head 109de088eb360340050d6f884fe8c54c90f99a9e. This is rebased onto main after #3823. The five focused suites pass 224 steps; changed-file format, lint, typecheck, and diff checks pass; every prior review thread remains resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 109de088eb

ℹ️ 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".

@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 17, 2026
@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 17, 2026
Merged via the queue into main with commit a53d846 Aug 17, 2026
33 checks passed
@kojiwakayama
kojiwakayama deleted the fix/google-replay-mismatch-fallback branch August 17, 2026 16:03
This was referenced Aug 17, 2026
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