Skip to content

fix(agent): replay signed Gemini tool turns - #3819

Closed
kojiwakayama wants to merge 2 commits into
mainfrom
fix/issue-549-gemini-tool-result
Closed

kojiwakayama wants to merge 2 commits into
mainfrom
fix/issue-549-gemini-tool-result

Conversation

@kojiwakayama

Copy link
Copy Markdown
Contributor

Summary

  • preserve provider replay metadata across direct generation and streamed agent steps
  • replay the exact signed Gemini assistant parts before matching tool responses
  • keep provider-private replay data out of SSE output and durable model-call telemetry
  • cover generate, stream, legacy and active lifecycle paths with red-green regressions and a credential-free Google wire test

Root cause

The Google runtime already captured the exact signed assistant parts required by Gemini 3, but the agent runtime bridge dropped providerMetadata before building the next tool-result request. Gemini 2.5 tolerated the reconstructed call; Gemini 3 rejected the unsigned continuation with HTTP 400.

Verification

  • focused provider/runtime matrix: 12 suites, 386 steps
  • active stream lifecycle provider transport: 16 steps
  • broad unit sweep: 3,934 tests, 30,188 steps
  • full source typecheck and repository lint
  • anti-slop, test-typecheck, dependency, module, and public-doc gates
  • isolated npm build
  • API reference generation with CI-pinned Deno 2.7.7

Not tested against live Gemini credentials; the wire regression uses the real Google runtime and request builder with a mocked transport.

Closes veryfront/veryfront-issue-inbox#549

Gemini 3 rejects tool-result requests when the original signed functionCall parts are not replayed. Carry provider metadata through generate and stream, persist it as assistant provider options, and keep it out of SSE and durable model-call telemetry.

Constraint: Gemini 3 requires exact thoughtSignature and functionCall replay before the matching functionResponse
Rejected: Reconstruct signatures from normalized tool calls | signatures are opaque provider output and cannot be recomputed
Confidence: high
Scope-risk: moderate
Directive: Do not attach whole-turn provider metadata to split assistant replay segments
Tested: focused 386-step matrix, active lifecycle, 30,188-step unit sweep, full typecheck and lint, isolated npm build, pinned API docs
Not-tested: live credentialed Gemini staging request
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kojiwakayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Limit details: You’ve used all 1 included review currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 46fdcf9d-cf93-4d69-9922-6a89818a4537

📥 Commits

Reviewing files that changed from the base of the PR and between 5887da1 and 9ba168e.

📒 Files selected for processing (21)
  • docs/api-reference/veryfront/agent.md
  • docs/api-reference/veryfront/embedding.md
  • src/agent/runtime/chat-stream-handler.ts
  • src/agent/runtime/index.ts
  • src/agent/runtime/provider-transport.test.ts
  • src/agent/runtime/runtime-tool-types.ts
  • src/agent/runtime/streamed-assistant-message.test.ts
  • src/agent/runtime/streamed-assistant-message.ts
  • src/agent/runtime/text-generation-runtime-message-converter.test.ts
  • src/agent/runtime/text-generation-runtime-message-converter.ts
  • src/agent/runtime/text-generation-runtime-message-types.ts
  • src/agent/schemas/agent.schema.test.ts
  • src/agent/schemas/agent.schema.ts
  • src/agent/streaming/lifecycle/live-adapter.test.ts
  • src/agent/streaming/lifecycle/live-adapter.ts
  • src/agent/streaming/lifecycle/reducer.test.ts
  • src/agent/streaming/lifecycle/reducer.ts
  • src/agent/streaming/lifecycle/runtime-provider-adapter.test.ts
  • src/agent/streaming/lifecycle/runtime-provider-adapter.ts
  • src/agent/streaming/lifecycle/types.ts
  • src/runtime/runtime-bridge.ts

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

📦 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.

@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: 0927e54494

ℹ️ 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/schemas/agent.schema.ts
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Superseded by #3820. The replacement preserves the active-lifecycle and exact Gemini wire coverage while keeping replay metadata internal and out of the public message schema. The Codex P2 thread here is addressed and resolved.

Agent message parsing previously accepted providerOptions for every role even though provider conversion only preserved it on assistant turns. Reject role-incompatible replay metadata at the validation boundary and lock assistant acceptance plus non-assistant rejection.

Constraint: Provider replay metadata represents opaque assistant output and must remain attached only to the original assistant turn
Rejected: Strict role-discriminated object schemas | would also reject unrelated unknown keys that the public schema currently strips
Confidence: high
Scope-risk: narrow
Directive: Keep providerOptions scoped to assistant replay messages unless conversion support is intentionally expanded for another role
Tested: Schema RED then GREEN; affected 7-suite matrix 149 steps; targeted check, lint, format, anti-slop, test-typecheck, public docs, error docs, and pinned Deno 2.7.7 API docs
Not-tested: Live Gemini credentials
@kojiwakayama kojiwakayama reopened this Aug 17, 2026
@kojiwakayama

Copy link
Copy Markdown
Contributor Author

Re-closing this duplicate. The issue timeline and prior review decision designate #3820 as the sole internal-only merge candidate; reopening #3819 was accidental. Its Codex P2 was nevertheless fixed in 9ba168e and the thread remains resolved.

@kojiwakayama
kojiwakayama deleted the fix/issue-549-gemini-tool-result branch August 30, 2026 10:27
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