← Back to PRs

#20191: feat(memory): add Amazon Bedrock embedding provider (Nova 2)

by gabrielkoo open 2026-02-18 16:46 View on GitHub →
size: M
## Summary Adds native support for Amazon Bedrock embeddings via `AWS_BEARER_TOKEN_BEDROCK`, starting with `amazon.nova-2-multimodal-embeddings-v1:0`. No new npm dependencies — uses the same Bearer token + native `fetch` pattern as the existing OpenAI and Voyage providers. ## Changes ### New files - `src/memory/embeddings-bedrock.ts` — provider implementation with a model registry for future extensibility - `src/memory/embeddings-bedrock.test.ts` — 14 unit tests ### Modified files - `src/memory/embeddings.ts` — add `"bedrock"` to `EmbeddingProviderId`, `EmbeddingProviderResult`, and `REMOTE_EMBEDDING_PROVIDER_IDS` - `src/config/zod-schema.agent-runtime.ts` — add `"bedrock"` to `provider` and `fallback` unions ## How it works **Auth:** reads `AWS_BEARER_TOKEN_BEDROCK` from env (or `remote.apiKey` override). Throws a helpful error with setup instructions if missing. **Region:** resolved from `models.providers.amazon-bedrock.region` config → `AWS_REGION` → `AWS_DEFAULT_REGION` → `us-east-1`. **Endpoint:** `POST https://bedrock-runtime.{region}.amazonaws.com/model/{modelId}/invoke` **Nova 2 request:** ```json { "schemaVersion": "nova-multimodal-embed-v1", "taskType": "SINGLE_EMBEDDING", "singleEmbeddingParams": { "embeddingPurpose": "GENERIC_INDEX", "embeddingDimension": 1024, "text": { "truncationMode": "END", "value": "..." } } } ``` **Config example:** ```json { "agents": { "defaults": { "memorySearch": { "provider": "bedrock", "model": "amazon.nova-2-multimodal-embeddings-v1:0" } } } } ``` ## Extensibility Adding a new Bedrock embedding model only requires adding an entry to `BEDROCK_MODEL_REGISTRY` in `embeddings-bedrock.ts` — no changes needed elsewhere. ## Test coverage ``` ✓ src/memory/embeddings-bedrock.test.ts (14 tests) ✓ src/memory/embeddings.test.ts (16 tests) ✓ src/memory/embeddings-voyage.test.ts (4 tests) ``` ## Notes - Bearer tokens from IAM Identity Center expire (~1h). Users need to refresh via `aws sso login`. - `embedBatch` fans out to individual `/invoke` calls — Bedrock has no batch embedding endpoint for Nova 2. - `bedrock` is added last in `REMOTE_EMBEDDING_PROVIDER_IDS` so auto-detection only picks it up when `AWS_BEARER_TOKEN_BEDROCK` is set. <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds a new Amazon Bedrock embedding provider (Nova 2) to the memory search system, following the same Bearer token + native `fetch` pattern as existing providers. The implementation is clean and well-tested with 14 unit tests. - **Type compilation issue**: Adding `"bedrock"` to `EmbeddingProviderId` widens `EmbeddingProviderRequest` and `EmbeddingProviderResult.fallbackFrom`, but `manager.ts` and `manager-sync-ops.ts` use hardcoded narrower string unions that don't include `"bedrock"`. This will cause TypeScript compilation errors. These files need corresponding updates to add the `bedrock` type, field, and assignment. - **Missing manager wiring**: `manager.ts` doesn't import `BedrockEmbeddingClient`, declare a `bedrock` field, or assign `params.providerResult.bedrock`. Similarly, `manager-sync-ops.ts:activateFallbackProvider` doesn't propagate `fallbackResult.bedrock`. - The new provider correctly falls through to standard (non-batch) embedding in `manager-embedding-ops.ts`, which is appropriate since Bedrock has no batch embedding endpoint. - The model registry pattern and region resolution chain (config → `AWS_REGION` → `AWS_DEFAULT_REGION` → `us-east-1`) are well designed for extensibility. <h3>Confidence Score: 2/5</h3> - This PR introduces a TypeScript compilation error in downstream manager files that must be fixed before merging. - The Bedrock provider implementation itself is well-written and thoroughly tested. However, adding "bedrock" to `EmbeddingProviderId` widens the type, causing compilation failures in `manager.ts` and `manager-sync-ops.ts` which use hardcoded narrower string unions. These files need to be updated to include "bedrock" in their type unions, add the `BedrockEmbeddingClient` field, and wire up the assignment from `EmbeddingProviderResult`. Without these changes, TypeScript strict checking will fail. - `src/memory/embeddings.ts` (type widening causes downstream compilation issues), `src/memory/manager.ts` and `src/memory/manager-sync-ops.ts` (not in PR but need matching updates) <sub>Last reviewed commit: 6cbdb7a</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs