← Back to PRs

#12624: feat: add google-vertex embedding provider for Vertex AI ADC auth

by swseo92 open 2026-02-09 12:02 View on GitHub →
agents stale
## Summary - Adds `google-vertex` as a new embedding provider, enabling Vertex AI users to use embeddings with their existing service account (ADC) authentication — no separate Google AI Studio API key needed - Implements OAuth2 token exchange (SA JSON → JWT → access token) using Node.js built-in `crypto` — zero new npm dependencies - Supports `embedQuery` (single text, `RETRIEVAL_QUERY`) and `embedBatch` (multiple texts, `RETRIEVAL_DOCUMENT`) with the Vertex AI `predict` endpoint ## Changes | File | Change | |------|--------| | `src/memory/embeddings-vertex.ts` | **New** — Core provider: token exchange, predict API, caching | | `src/memory/embeddings-vertex.test.ts` | **New** — 11 unit tests (URL, auth, request/response, batch, edge cases) | | `src/memory/embeddings.ts` | Wire `google-vertex` into provider factory + auto-selection | | `src/memory/manager.ts` | Add `google-vertex` to type unions and fallback logic | | `src/config/types.tools.ts` | Add `google-vertex` to provider/fallback type unions | | `src/config/zod-schema.agent-runtime.ts` | Add `google-vertex` to Zod validation schema | | `src/agents/memory-search.ts` | Add `google-vertex` config defaults and model resolution | ## Configuration ```yaml # openclaw.json — memory search config memorySearch: provider: google-vertex model: text-embedding-005 # default, can be omitted ``` Required environment variables: - `GOOGLE_CLOUD_PROJECT` — GCP project ID (required) - `GOOGLE_CLOUD_LOCATION` — Region (optional, defaults to `us-central1`) - `GOOGLE_APPLICATION_CREDENTIALS` — Path to SA JSON key (optional, falls back to `gcloud auth`) ## Test plan - [x] All 11 new unit tests pass (`pnpm test src/memory/embeddings-vertex.test.ts`) - [x] Existing embedding tests unaffected (`pnpm test src/memory/embeddings.test.ts`) - [x] Full test suite passes (89 tests, 0 failures) - [x] TypeScript type check passes (`pnpm typecheck`) - [x] E2E verified: real Vertex AI API calls return 768-dim embeddings from Docker container 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a new `google-vertex` embedding provider and wires it through memory-search config, types, and runtime Zod validation. The provider implements Vertex AI embeddings via the `predict` endpoint using ADC-style auth (service account JSON → JWT → OAuth2 token, with a `gcloud` fallback) and adds unit tests covering URL formation, headers, request shapes, batch embeddings, and model/location normalization. <h3>Confidence Score: 3/5</h3> - This PR is mergeable after fixing the auto-provider selection hard-fail and the provider-key cache collision for google-vertex. - The core provider wiring and tests look solid, but two behavior issues likely impact real users: `provider:auto` can throw immediately in non-GCP environments due to google-vertex init errors not being treated as 'missing creds', and the embedding cache key does not include Vertex project/location, which can cause cross-project cache collisions. - src/memory/embeddings.ts, src/memory/manager.ts <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs