Skip to content

fix(google): support stable Gemini Embedding 2 request contracts - #128716

Merged
steipete merged 5 commits into
mainfrom
codex/issue-120662-gemini-stable
Aug 24, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/issue-120662-gemini-stable

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Support Google's stable gemini-embedding-2 model in the owning Google memory plugin while preserving gemini-embedding-001 and the existing preview identifier.
  • Honor Google's actual stable-model contract: omit unsupported taskType, apply documented task instructions for all seven existing task modes, and preserve asymmetric query/document instructions across direct, synchronous-batch, and asynchronous-batch requests.
  • Keep multimodal content intact, validate returned dimensions before direct or batch vectors enter memory, and retain existing current-main destination-ownership and credential behavior.
  • Document deliberate index rebuilds with non-mutating memory status --deep inspection, and correct Gemini-supported image/audio formats.

Closes #120662.
Supersedes #120665, preserving all four original contributor commits. Thank you @fr-meyer for the original implementation, tests, documentation, and authenticated provider proof.

Why the additional repair is necessary

Google's embedding documentation explicitly states that the stable gemini-embedding-2 model does not support task_type; task instructions belong in text-only content instead. The original PR sent the unsupported field on direct requests and both batch paths. The Google plugin now owns one canonical, model-aware request builder and removes its redundant text-only wrapper.

  • Retrieval queries use task: search result | query: ....
  • Retrieval documents use title: none | text: ....
  • Explicit semantic similarity, classification, clustering, question answering, and fact verification use Google's documented task instructions.
  • Question-answering and fact-verification document requests retain the required asymmetric document format.
  • Existing preview and legacy-model request payloads remain unchanged; structured multimodal content is not rewritten.

Existing stable-model indexes already change identity because this fix starts resolving their previously omitted output dimensions. Operators therefore inspect first and explicitly rebuild rather than silently mixing incompatible vectors.

Real-provider verification

Two authenticated requests against the live Google Gemini API verified the corrected stable-model contract without exposing credentials, changing configuration, or mutating a memory index:

{
  "model": "gemini-embedding-2",
  "query": {
    "httpStatus": 200,
    "taskTypeSent": false,
    "instruction": "task: search result | query: ...",
    "requestedDimensions": 768,
    "receivedDimensions": 768,
    "finiteValues": true
  },
  "document": {
    "httpStatus": 200,
    "taskTypeSent": false,
    "instruction": "title: none | text: ...",
    "requestedDimensions": 768,
    "receivedDimensions": 768,
    "finiteValues": true
  },
  "configurationChanged": false,
  "memoryIndexChanged": false,
  "credentialsRedacted": true
}

The original contributor additionally verified an authenticated stable-model 768-dimensional request and an existing live memory search returning three results without mutating its index; see #120665.

Focused regression coverage

  • Stable direct query, synchronous document batch, and asynchronous document batch verify exact transmitted content and absence of taskType.
  • Explicit question-answering and fact-verification overrides verify asymmetric query/document payloads.
  • Existing semantic-similarity and multimodal cases preserve the correct content contract.
  • Preview requests retain the existing taskType field.
  • Direct, synchronous-batch, and asynchronous-batch vectors reject mismatched dimensions before caching or indexing.
  • Current-main destination ownership, query-parameter handling, provider credentials, and owner headers remain intact after the contributor-commit rebase.
  • Changed-file formatting and structured independent review passed; exact-head hosted CI will provide focused and full test execution.

Production delta: +78/-51 (net +27), justified by stable-model support, provider-required request semantics, and vector-dimension integrity. Test delta: +232/-28.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: google size: M maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 12:24
@steipete
steipete merged commit e30279f into main Aug 24, 2026
224 checks passed
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 24, 2026
@steipete
steipete deleted the codex/issue-120662-gemini-stable branch August 24, 2026 12:38
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 24, 2026, 8:31 AM ET / 12:31 UTC.

ClawSweeper review

What this changes

The PR adds stable Gemini Embedding 2 request construction and dimension validation, preserves the preview identifier, and updates memory-index rebuild and multimodal documentation.

Merge readiness

⚠️ Ready for maintainer review - 6 items remain

Keep this maintainer-authored PR open: its new stable-model documentation lists four media formats, but the enabled runtime still admits the broader shared format set and sends those files to Gemini.

Priority: P1
Reviewed head: 9179a98ba3e690dc0cf4840249307ba05f399632
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The provider trace and focused coverage are useful, but the documented stable media contract is not enforced by the runtime.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR includes redacted live-provider output for stable text query and document requests, but the remaining finding concerns media-format admission rather than ordinary contributor proof.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR includes redacted live-provider output for stable text query and document requests, but the remaining finding concerns media-format admission rather than ordinary contributor proof.
Evidence reviewed 6 items Stable model is enabled for all shared multimodal extensions: The changed adapter returns true for stable Gemini Embedding 2; core uses that boolean to permit multimodal indexing.
Shared intake remains broader than the new documentation: The shared classifier still accepts WebP, GIF, HEIC/HEIF, OGG, Opus, M4A, AAC, and FLAC; accepted files are converted to inline MIME data before provider calls.
Changed documentation narrows the advertised set: The PR changes the Gemini memory reference from the shared format set to JPG/JPEG/PNG and MP3/WAV only without adding corresponding runtime admission logic.
Findings 1 actionable finding [P2] Reject formats the stable model cannot embed
Security None None.

Live Verification

Command: pnpm openclaw memory status --help

Result: PASS (completed)

pnpm openclaw memory status --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128716-r1T9iT/target$ pnpm openclaw memory status --help
$ node scripts/run-node.mjs memory status --help
pnpm openclaw memory status --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 112.94 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.5s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4440ms (slowest: built plugin control-plane loads 3666ms)
│
◇

OpenClaw 2026.8.1 (9179a98) — All your chats, one OpenClaw.

Usage: openclaw memory status [options]

Show memory search index status

Options:
  --agent ‹id›  Agent id (default: default agent)
  --deep        Probe embedding provider availability
  --fix         Repair stale recall locks and normalize promotion metadata
  -h, --help    Display help for command
  --index       Reindex if dirty (implies --deep)
  --json     
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw memory status

How this fits together

Memory search classifies extra-path media, asks the Google plugin whether the chosen embedding model supports multimodal input, then sends inline media to Gemini and stores vectors in the memory index. This PR changes the Google plugin’s model-specific request and capability behavior.

flowchart LR
  A[Extra memory files] --> B[Shared media classifier]
  B --> C[Google model capability]
  C --> D[Embedding request builder]
  D --> E[Gemini API]
  E --> F[Memory index]
Loading

Decision needed

Question Recommendation
Should stable Gemini Embedding 2 enforce its narrower media-format contract before indexing while preview configurations retain the shared format set? Enforce stable-model formats: Confirm the provider contract and add model-aware media admission so unsupported stable files are rejected before a Gemini request, while preview support remains explicit.

Why: The current capability seam is boolean-only, so aligning runtime behavior with the newly narrowed documentation requires an intentional provider-capability and compatibility direction.

Before merge

  • Reject formats the stable model cannot embed (P2) - The changed docs say stable Gemini supports only JPG/JPEG/PNG and MP3/WAV, but the changed capability enables every shared multimodal extension. Core will classify formats such as WebP, GIF, OGG, and FLAC and forward their MIME data to Gemini, so either enforce the stable format boundary before I/O or retain documentation that matches the accepted runtime set.
  • Resolve merge risk (P1) - Stable-model multimodal configuration will still admit shared formats that the changed documentation calls unsupported, allowing an avoidable provider-side failure after setup succeeds.
  • Resolve merge risk (P1) - Existing stable-model indexes intentionally acquire a new identity and pause vector search until rebuild; the PR documents this, but its live proof does not show the upgrade path.
  • Resolve merge risk (P1) - Production code grows by 27 net lines; the canonical request builder and dimension invariant justify it only once model-specific media admission is made coherent.
  • Complete next step (P2) - A maintainer must choose the durable stable-versus-preview media compatibility contract before a mechanical repair can safely proceed.

Findings

  • [P2] Reject formats the stable model cannot embed — docs/reference/memory-config.md:439
Agent review details

Security

None.

PR surface

Source +27, Tests +204, Docs +13. Total +244 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 78 51 +27
Tests 3 232 28 +204
Docs 2 17 4 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 327 83 +244

Review metrics

Metric Value Why it matters
Production versus test delta production +78/-51 (net +27); tests +232/-28 The added canonical request builder and vector validation are substantive bug-fix growth and need the remaining media-policy boundary resolved.
Stable-index upgrade path 1 provider identity behavior changed Existing stable-model indexes move from an omitted dimension to resolved dimensions and must pause for an explicit rebuild.

Stored data model

Persistent data-model change detected: serialized state: extensions/google/embedding-batch.test.ts, unknown-data-model-change: extensions/google/embedding-provider.test.ts, unknown-data-model-change: extensions/google/embedding-provider.ts, unknown-data-model-change: extensions/google/memory-embedding-adapter.test.ts, vector/embedding metadata: docs/concepts/memory-search.md, vector/embedding metadata: extensions/google/embedding-batch.test.ts, and 5 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #120662
Summary: This PR is the active candidate repair for the stable Gemini Embedding 2 memory-provider defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Align stable media admission (recommended)
    Confirm the stable Gemini media contract and enforce it before provider I/O so the new documentation and accepted files agree.
  2. Keep the shared media contract
    Retain the broader runtime behavior only with provider evidence and documentation that accurately describes it.

Technical review

Best possible solution:

Confirm Google’s stable media contract, then make the plugin/core admission boundary reject only the unsupported stable formats before provider I/O while retaining preview behavior and documenting the exact upgrade path.

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

Yes: enable multimodal memory with stable Gemini Embedding 2 and place a shared-format file such as WebP or OGG under an extra path; source shows it is admitted and forwarded despite the changed documentation excluding it.

Is this the best way to solve the issue?

No: the request builder is the right owner for stable text contracts, but the PR leaves media admission inconsistent with its own supported-format contract.

Full review comments:

  • [P2] Reject formats the stable model cannot embed — docs/reference/memory-config.md:439
    The changed docs say stable Gemini supports only JPG/JPEG/PNG and MP3/WAV, but the changed capability enables every shared multimodal extension. Core will classify formats such as WebP, GIF, OGG, and FLAC and forward their MIME data to Gemini, so either enforce the stable format boundary before I/O or retain documentation that matches the accepted runtime set.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 03658a99a950.

Labels

Label changes:

  • add P1: The PR repairs a currently broken stable Google embedding workflow used by configured memory search.
  • add merge-risk: 🚨 compatibility: It changes request semantics, multimodal capability, and upgrade behavior for existing Gemini embedding configurations.
  • add merge-risk: 🚨 session-state: The changed provider identity deliberately invalidates existing memory-vector indexes until they are rebuilt.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR includes redacted live-provider output for stable text query and document requests, but the remaining finding concerns media-format admission rather than ordinary contributor proof.

Label justifications:

  • P1: The PR repairs a currently broken stable Google embedding workflow used by configured memory search.
  • merge-risk: 🚨 compatibility: It changes request semantics, multimodal capability, and upgrade behavior for existing Gemini embedding configurations.
  • merge-risk: 🚨 session-state: The changed provider identity deliberately invalidates existing memory-vector indexes until they are rebuilt.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR includes redacted live-provider output for stable text query and document requests, but the remaining finding concerns media-format admission rather than ordinary contributor proof.

Evidence

What I checked:

  • Stable model is enabled for all shared multimodal extensions: The changed adapter returns true for stable Gemini Embedding 2; core uses that boolean to permit multimodal indexing. (extensions/google/memory-embedding-adapter.ts:24, 9179a98ba3e6)
  • Shared intake remains broader than the new documentation: The shared classifier still accepts WebP, GIF, HEIC/HEIF, OGG, Opus, M4A, AAC, and FLAC; accepted files are converted to inline MIME data before provider calls. (packages/memory-host-sdk/src/host/multimodal.ts:6, 03658a99a950)
  • Changed documentation narrows the advertised set: The PR changes the Gemini memory reference from the shared format set to JPG/JPEG/PNG and MP3/WAV only without adding corresponding runtime admission logic. Public docs: docs/reference/memory-config.md. (docs/reference/memory-config.md:439, 9179a98ba3e6)
  • Existing Embedding 2 ownership history: Current-main blame attributes the original preview-only model set, adapter capability, and batch output handling to the initial Google embedding integration. (extensions/google/embedding-provider.ts:55, 1f1d0e9d8f2b)
  • Release provenance: The affected integration is on current main after the latest supplied release; no stable tag contains its introducing commit, so this is current-main behavior rather than a shipped-release finding. (03658a99a950)
  • Provider-contract signal and limitation: The PR body explicitly relies on Google’s embedding documentation; direct inspection was attempted but this review environment could not resolve ai.google.dev, so the supplied text-only live trace does not establish the new media-format boundary.

Likely related people:

  • steipete: Current-main history attributes the original Google embedding files to this author, and the PR head contains the stable-contract repair. (role: introduced and recently maintained the Google embedding integration; confidence: high; commits: 1f1d0e9d8f2b, 9179a98ba3e6; files: extensions/google/embedding-provider.ts, extensions/google/embedding-batch.ts, extensions/google/memory-embedding-adapter.ts)

Rank-up moves

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

  • Make stable-media admission and documentation agree while preserving preview compatibility.
  • Add a redacted stable-media provider trace or focused boundary proof for accepted and rejected formats.
  • Show the existing-index mismatch and explicit rebuild flow on the final head.

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.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 25, 2026
…nclaw#128716)

* fix(memory): support stable Gemini Embedding 2

* fix(memory): validate async Gemini batch dimensions

* docs(memory): explain stable Gemini index rebuild

* docs(memory): cover explicit-dimension rebuilds

* fix(google): honor stable Gemini embedding task contracts

Co-authored-by: Franck MEYER <[email protected]>

---------

Co-authored-by: Codex OpenClaw Migration <noreply@local>
Co-authored-by: Franck MEYER <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: google maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: stable gemini-embedding-2 is not recognized by memory search

2 participants