Skip to content

fix(google): preserve canonical replay and provider error ownership - #117193

Merged
steipete merged 3 commits into
mainfrom
codex/qa400-google-canonical-owner
Aug 1, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/qa400-google-canonical-owner

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

fix(google): preserve Gemini signatures and actionable SDK failures

Root causes repaired

  1. Preserve the exact Google/Vertex provider Part owning every thought signature across streamed text, thinking, tools, standalone signature carriers, and next-turn replay; retain the mandatory empty text: "" discriminator on signed empty Parts.
  2. Normalize malformed, array-shaped, and JSON-serialized historical function-call arguments through the existing shared transport coercion owner.
  3. Apply the documented Gemini 3 fallback signature only to the first unsigned parallel function call in each assistant step, preserving authentic provider signatures and avoiding cross-provider replay.
  4. Preserve real Google SDK HTTP status codes and caller-provided coded abort causes so existing quota/failover classification remains actionable.

Dependency and safety evidence

  • Current official Google thought-signature documentation requires exact original Part ownership, signs only the first parallel Gemini 3 function call, and documents signatures arriving on empty streamed text Parts.
  • Installed @google/genai 2.13.0 Part requires exactly one content discriminator; its actual serializer retains text: "" but does not invent it when missing. Both signed-empty text and signed-empty thinking regressions fail on the original branch and now pass.
  • Google streams expose no stable Part identity across SSE chunks; ordinary same-Part deltas remain merged, matching Google's own SDK merge implementation. No speculative chunk-boundary workaround or compatibility layer is introduced.
  • Private package owner only: no provider configuration, public plugin SDK, authentication policy, protocol, sanitizer, or security boundary changes. Production +97/-33 (net +64) is justified by exact opaque-Part ownership, SDK argument/HTTP-error contracts, and elimination of unsafe signature replay; tests +522/-2.

Actual authenticated provider proof (no mocked fetch)

Executed the exact corrected OpenClaw streamGoogle owner and installed official @google/[email protected] against a real authenticated localhost HTTP/SSE Gemini server using native, unmodified Node fetch. Four actual POST /v1beta/models/gemini-3-flash-preview:streamGenerateContent?alt=sse requests carried a real x-goog-api-key header (redacted); no fetch, SSRF guard, or provider was mocked.

{
  "baseline": {
    "head": "b521ce626bfb479ba39e7919445c76e40d1d21aa",
    "nextRequestModelTurn": null,
    "dropsBothSignedEmptyParts": true
  },
  "corrected": {
    "head": "bb5fe2796e6da6571ba475c77e071de13a82dfd0",
    "nextRequestModelTurn": {
      "role": "model",
      "parts": [
        { "text": "", "thoughtSignature": "c2lnbmVkLWVtcHR5LXRleHQ=" },
        { "text": "", "thought": true, "thoughtSignature": "c2lnbmVkLWVtcHR5LXRoaW5raW5n" }
      ]
    }
  },
  "actualHttp429": { "stopReason": "error", "errorCode": "429", "message": "Proof-only quota exhausted" },
  "authenticatedHttpRequests": 4,
  "mockedFetch": false,
  "mockedGuard": false,
  "assertions": "ALL PASS"
}

Raw redacted transcript: /private/tmp/openclaw-qa400-google-package-live-proof.txt; reproducible driver: /private/tmp/openclaw-qa400-google-package-live-proof.mjs. Current official Google thought-signature contract documents signatures on empty streamed text Parts and exact Part replay.

Full verification

  • Blacksmith Testbox completed successfully: pnpm tsgo:core, pnpm tsgo:core:test, pnpm tsgo:test:packages, and full pnpm lint:core.
  • node scripts/run-vitest.mjs packages/ai/src/providers/google-shared.convert.test.ts packages/ai/src/providers/google-shared.test.ts: 83 passed.
  • Genuine exact committed-branch P0–P3 automated review: clean, confidence 0.94, TruffleHog clean; three independent full-context owner/dependency reviews: clean.
  • Reviewed base b521ce626bfb479ba39e7919445c76e40d1d21aa; current main 618f3298c7dc00a41549e4dec41d8412f651624b; exact clean synthetic merge 0028d8caa8b9f5150eee73176de1422c3ca9f923.
  • Existing branch codex/qa400-google-canonical-owner; corrected immutable commit bb5fe2796e6da6571ba475c77e071de13a82dfd0.
  • Repository-wide check:changed also exposes an unrelated existing main budget ratchet (OPENCLAW_* count 515 below budget 517); the complete affected production/test type and lint lanes above were therefore verified directly on Testbox.

@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 1:15 AM ET / 05:15 UTC.

ClawSweeper review

What this changes

The PR preserves Google and Vertex signed response parts during stream-to-replay conversion, normalizes tool-call arguments, limits Gemini 3 fallback signatures, and retains provider failure status details.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

This PR remains necessary: current main still drops signed empty Google replay parts and can assign a signature-only streamed part to the preceding tool call. The patch follows the shared transport owners for argument coercion and error details, includes focused regressions, and supplies redacted authenticated runtime output; however, the maintainer label requires an explicit provider-owner merge decision.

Priority: P2
Reviewed head: bb5fe2796e6da6571ba475c77e071de13a82dfd0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong focused proof and regression coverage support a bounded provider repair, with final readiness appropriately reserved for protected-label provider-owner approval.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies redacted copied after-fix live output from authenticated native-fetch Gemini SSE requests, including retained signed empty replay parts and a real HTTP 429; redact credentials and private endpoints in any follow-up artifacts.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies redacted copied after-fix live output from authenticated native-fetch Gemini SSE requests, including retained signed empty replay parts and a real HTTP 429; redact credentials and private endpoints in any follow-up artifacts.
Evidence reviewed 6 items Current-main defect and patch boundary: Current main skips empty assistant text/thinking blocks before considering their signatures; the PR instead retains an empty content discriminator when a valid same-provider signature exists, preserving the replayable Part.
Stream ownership repair: The PR separates signature-only streamed parts into their own saved text/thinking blocks while retaining ordinary text deltas, rather than broadly copying a signature onto later replay content.
Shared error and argument owners: The patch delegates malformed tool-call argument normalization and coded failure metadata to the existing transport helpers instead of adding Google-specific parallel policy.
Findings None None.
Security None None.

How this fits together

The shared Google provider converts OpenClaw conversation history into Gemini/Vertex request parts and converts streamed Google responses back into assistant content. That saved assistant content is replayed on the next provider request, so part identity and provider error metadata affect subsequent tool use and failover behavior.

flowchart LR
  A[Conversation history] --> B[Google shared converter]
  B --> C[Gemini or Vertex request parts]
  D[Google streamed response] --> E[Stream response converter]
  E --> F[Saved assistant content]
  F --> B
  E --> G[Provider error outcome]
  G --> H[Caller failover and diagnostics]
Loading

Decision needed

Question Recommendation
Does a provider owner approve this exact replay/error-owner repair for Google and Vertex after reviewing the supplied authenticated runtime trace and focused regression coverage? Approve scoped repair: Confirm the provider contract and supplied live proof, then merge the focused shared-provider change.

Why: The patch changes opaque provider replay semantics and error classification, and the protected maintainer label requires explicit human handling even though no discrete code defect was found.

Before merge

  • Resolve merge risk (P1) - Merging changes persisted assistant replay data and provider error classification; a regression could make a later Google/Vertex turn invalid or reduce quota/failover diagnostics.
  • Resolve merge risk (P1) - The local read-only checkout lacks installed @google/genai source, so this review could not independently inspect the exact 2.13.0 serializer and error-class implementation; the supplied authenticated proof and focused tests mitigate but do not replace provider-owner approval.
  • Complete next step (P2) - No actionable patch defect was found, but the protected maintainer label and dependency-owned replay contract require provider-owner approval before merge.
Agent review details

Security

None.

PR surface

Source +64, Tests +520. Total +584 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 97 33 +64
Tests 2 522 2 +520
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 619 35 +584

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: packages/ai/src/providers/google-shared.convert.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Approve the provider-owner repair (recommended)
    After a provider owner confirms the replay and HTTP-error contract, accept the bounded compatibility risk and merge.
  2. Pause for independent SDK confirmation
    Keep the PR open until a maintainer verifies the pinned Google SDK serializer/error behavior with a fresh redacted runtime trace.

Technical review

Best possible solution:

Keep exact signed Google Parts on their originating replay blocks, retain the shared transport coercion/error-detail boundary, and land only after a provider owner confirms the supplied real-runtime evidence covers the intended Google SDK contract.

Do we have a high-confidence way to reproduce the issue?

Yes—current main has a source-deterministic path that skips signed empty assistant text/thinking blocks before replay; the PR adds regression coverage for that path. I did not execute the failing baseline locally because this read-only checkout has no installed dependency tree.

Is this the best way to solve the issue?

Yes—the patch repairs the provider-owned replay conversion and delegates generic coercion/error metadata to existing shared transport helpers, avoiding signature caches or parallel Google-specific fallback paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4fb19fb8c586.

Labels

Label justifications:

  • P2: This repairs a bounded but real Google/Vertex provider replay and diagnostic behavior problem.
  • merge-risk: 🚨 session-state: The patch changes how saved assistant content is serialized for the next provider turn, including signed empty parts and tool-call signatures.
  • merge-risk: 🚨 auth-provider: The patch changes preservation of Google SDK failure status and provider-specific replay semantics used by quota and failover handling.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies redacted copied after-fix live output from authenticated native-fetch Gemini SSE requests, including retained signed empty replay parts and a real HTTP 429; redact credentials and private endpoints in any follow-up artifacts.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies redacted copied after-fix live output from authenticated native-fetch Gemini SSE requests, including retained signed empty replay parts and a real HTTP 429; redact credentials and private endpoints in any follow-up artifacts.

Evidence

What I checked:

  • Current-main defect and patch boundary: Current main skips empty assistant text/thinking blocks before considering their signatures; the PR instead retains an empty content discriminator when a valid same-provider signature exists, preserving the replayable Part. (packages/ai/src/providers/google-shared.ts:227, bb5fe2796e6d)
  • Stream ownership repair: The PR separates signature-only streamed parts into their own saved text/thinking blocks while retaining ordinary text deltas, rather than broadly copying a signature onto later replay content. (packages/ai/src/providers/google-shared.ts:833, bb5fe2796e6d)
  • Shared error and argument owners: The patch delegates malformed tool-call argument normalization and coded failure metadata to the existing transport helpers instead of adding Google-specific parallel policy. (packages/ai/src/transports/transport-stream-shared.ts:53, 4fb19fb8c586)
  • Regression coverage: The branch adds focused conversion and stream tests for signed empty parts, standalone signatures, parallel tool calls, historical arguments, abort causes, and Google API status errors. (packages/ai/src/providers/google-shared.test.ts:447, bb5fe2796e6d)
  • After-fix behavior proof: The PR body includes redacted copied live output from four authenticated native-fetch Gemini SSE requests, showing signed empty replay parts retained and a real HTTP 429 preserved as the error code; the supplied PR context also reports successful Real behavior proof checks. (bb5fe2796e6d)
  • Feature provenance and current-main check: History shows Peter Steinberger repeatedly maintaining this shared Google provider path, including the recent blocked-prompt repair. Current main has no further diff to this file after the PR base, so the central repair is not already implemented or superseded. (packages/ai/src/providers/google-shared.ts:163, 0d40cfbb538d)

Likely related people:

  • steipete: Git history attributes ten commits on the shared Google provider path to Peter Steinberger, including a recent Google prompt/error repair on current main. (role: long-running area contributor; confidence: high; commits: 0d40cfbb538d, 0c989568b3a7; files: packages/ai/src/providers/google-shared.ts)
  • SunnyShu: The current shared-provider implementation traces to the recent runtime-provider catalog refactor, making this author a relevant adjacent owner for merge integration. (role: current-file contributor; confidence: medium; commits: cbdbf6802b96; files: packages/ai/src/providers/google-shared.ts)
  • Vincent Koc: History shows prior Google thinking-level work in the same provider module, directly adjacent to the signed-thinking behavior changed here. (role: adjacent Google provider contributor; confidence: medium; commits: a4de2cebf90b, 78dfd47f8335; files: packages/ai/src/providers/google-shared.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain provider-owner approval of the Google SDK replay/error contract before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-01T04:21:19.013Z sha 1ce978b51dc347626a26f5908510961cc1c757fb :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T04:55:20.401Z sha bb5fe27 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the codex/qa400-google-canonical-owner branch from 1ce978b to bb5fe27 Compare August 1, 2026 04:48
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 1, 2026
@steipete
steipete merged commit 1f9ee89 into main Aug 1, 2026
124 of 132 checks passed
@steipete
steipete deleted the codex/qa400-google-canonical-owner branch August 1, 2026 05:52
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
…penclaw#117193)

* fix(google): preserve provider signatures and failure outcomes

* fix(google): satisfy SDK stream event and optional text types

* fix(google): preserve signed empty SDK response parts

---------

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

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant