Skip to content

feat(bedrock): add Cohere Embed v4 model and improve credential handling (Fixes #11823)#11824

Draft
cscvenkatmadurai wants to merge 1 commit intoRooCodeInc:mainfrom
cscvenkatmadurai:feat/bedrock-cohere-v4-and-credentials
Draft

feat(bedrock): add Cohere Embed v4 model and improve credential handling (Fixes #11823)#11824
cscvenkatmadurai wants to merge 1 commit intoRooCodeInc:mainfrom
cscvenkatmadurai:feat/bedrock-cohere-v4-and-credentials

Conversation

@cscvenkatmadurai
Copy link

@cscvenkatmadurai cscvenkatmadurai commented Mar 2, 2026

Summary

Fixes #11823

Adds Cohere Embed v4 (cohere.embed-v4:0) support for Bedrock code indexing and fixes credential refresh for long-running indexing sessions on large codebases.

Changes

1. Cohere Embed v4 Support (Text-Only)

  • Added cohere.embed-v4:0 to Bedrock embedding model profiles with dimension 1536
  • Added v4-specific request format with embedding_types: ["float"] parameter
  • Added v4-specific response parsing for {embeddings: {float: [[...]]}} structure
  • v4 check placed before v3 in the if/else chain to prevent misrouting
  • Text-only for now; multimodal image support planned as follow-up

2. Credential Refresh Fix

  • Replaced fromEnv() with fromNodeProviderChain() as the default credential fallback when no AWS profile is specified
  • fromNodeProviderChain() supports all credential sources (env vars, SSO, INI, IMDS, ECS) with built-in memoization and auto-refresh
  • Fixes credential expiry during long-running indexing sessions (>1 hour) on large codebases

3. Tests

  • 5 new unit tests covering credential provider selection, Cohere v4 request/response handling, and v3 regression
  • All 143 related tests pass (30 bedrock + 113 service-factory/config-manager)

Files Changed (3 files)

  • src/services/code-index/embedders/bedrock.ts — Credential fix + Cohere v4 request/response
  • src/shared/embeddingModels.ts — New model profile entry
  • src/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."

Testing

  • ✅ 30/30 bedrock embedder tests pass
  • ✅ 113/113 service-factory + config-manager tests pass
  • ✅ TypeScript compiles cleanly
  • ✅ 14/14 packages lint clean
  • ✅ Cohere v4 API format validated with real Bedrock API call (LT-1)
  • ✅ Parsing logic validated with simulated responses (LT-4)

Related: aws-samples/bedrock-access-gateway#212

Interactively review PR in Roo Code Cloud

- Add cohere.embed-v4:0 (1536-dim) to Bedrock embedding model profiles
- Add v4-specific request format (embedding_types: ["float"]) and response
  parsing (embeddings.float[0]) in BedrockEmbedder
- Replace fromEnv() with fromNodeProviderChain() for default credential
  chain when no AWS profile is specified, supporting SSO, IMDS, ECS, and
  other credential sources with built-in memoization
- Add unit tests for Cohere v4 request/response handling, credential
  provider selection, and v3 regression coverage

Fixes RooCodeInc#11823
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Cohere Embed v4 support for Bedrock code indexing and fix credential refresh for long-running sessions

1 participant