-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Problem
When indexing large codebases with the Bedrock embedding provider, two issues arise:
-
Missing model: Cohere Embed v4 (
cohere.embed-v4:0) is now available on AWS Bedrock but isn't supported as an embedding model for code indexing. It offers 1536-dimensional embeddings with 128k context — a significant upgrade over Cohere v3. -
Credential expiry on large codebases: The
BedrockEmbedderusesfromEnv()as the credential fallback when no AWS profile is specified.fromEnv()only reads static environment variables and doesn't support auto-refresh. For large codebases where indexing takes >1 hour, temporary AWS credentials (from SSO, STS, orcredential_processlikeada) expire mid-session, causing indexing failures.
User Benefit
- Access to the latest Cohere Embed v4 model for higher quality code embeddings via Bedrock
- Reliable credential auto-refresh during long-running indexing sessions, supporting AWS SSO, IAM Identity Center, ECS, EC2 IMDS, and
credential_process-based profiles - No more indexing failures on large codebases due to expired credentials
Proposed Solution
1. Add Cohere Embed v4 (cohere.embed-v4:0)
- Add model to Bedrock embedding profiles with dimension 1536
- Add v4-specific request format (
embedding_types: ["float"]) - Add v4-specific response parsing (
embeddings.float[0]instead ofembeddings[0]) - Text-only support initially; multimodal image support planned as follow-up
2. Fix credential fallback
- Replace
fromEnv()withfromNodeProviderChain()— the AWS SDK v3 default credential chain fromNodeProviderChain()checks env vars first (backward compatible), then SSO, INI, IMDS, ECS, etc.- Includes built-in memoization for efficient credential caching with auto-refresh
Files Changed (3 files, ~10 lines production code + tests)
src/services/code-index/embedders/bedrock.ts— Credential fix + Cohere v4 request/responsesrc/shared/embeddingModels.ts— New model profile entrysrc/services/code-index/embedders/__tests__/bedrock.spec.ts— 5 new tests
Roadmap Alignment
This aligns with: "Expand robust support for a wide variety of AI providers and models."