Skip to content

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

Merged
hannesrudolph merged 1 commit intoRooCodeInc:mainfrom
cscvenkatmadurai:feat/bedrock-cohere-v4-and-credentials
Mar 6, 2026
Merged

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

Conversation

@cscvenkatmadurai
Copy link
Contributor

@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
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 6, 2026
@hannesrudolph hannesrudolph merged commit 0892455 into RooCodeInc:main Mar 6, 2026
23 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

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

2 participants