Skip to content

feat: add Bedrock Knowledge Base Retriever to @ai-sdk/amazon-bedrock#16973

Draft
PVidyadhar wants to merge 1 commit into
vercel:mainfrom
PVidyadhar:bmkb-managed-kb-support
Draft

feat: add Bedrock Knowledge Base Retriever to @ai-sdk/amazon-bedrock#16973
PVidyadhar wants to merge 1 commit into
vercel:mainfrom
PVidyadhar:bmkb-managed-kb-support

Conversation

@PVidyadhar

Copy link
Copy Markdown

Background

Amazon Bedrock recently launched Managed Knowledge Bases, which handle embedding, storage, and retrieval automatically — no external vector store
needed. The @ai-sdk/amazon-bedrock package currently supports model invocation via Converse API but has no native KB retrieval capability. This
PR adds a retriever that enables AI SDK users to query Bedrock Knowledge Bases directly.

Summary

Created bedrockKnowledgeBaseRetriever factory function in @ai-sdk/amazon-bedrock that:

  • Supports MANAGED (default) and VECTOR knowledge base types
  • Uses managedSearchConfiguration for managed KBs, vectorSearchConfiguration for vector KBs
  • Attempts AgenticRetrieveStream (query decomposition + managed reranking) with fallback to plain Retrieve
  • Parses multi-type locations (S3, Web, Confluence, SharePoint, Custom)
  • Added @aws-sdk/client-bedrock-agent-runtime dependency
  • Updated README with KB retrieval section, reranking options, and doc links
  • Added BEDROCK_MANAGED_KB.md design doc
  • Unit tests included

Manual Verification

  • Live E2E tested against managed KB in us-west-2
  • managedSearchConfiguration: ✅ 3 results returned with content and scores
  • AgenticRetrieveStream: ✅ 10 agentic results with source URIs
  • No config (API auto-detects): ✅ 5 results returned
  • vectorSearchConfiguration on MANAGED KB: ✅ Correctly rejected with clear error message

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Future Work

  • Add dedicated rerankingModelType parameter for convenience (currently configurable via raw config passthrough)
  • Integration with AI SDK's RAG pipeline utilities (if/when available)
  • Streaming retrieval results for large result sets

Related Issues

N/A — new feature addition for AWS Bedrock Managed Knowledge Base GA launch.

- Created bedrockKnowledgeBaseRetriever factory function
- Supports MANAGED (default) and VECTOR knowledge base types
- AgenticRetrieveStream with fallback to plain Retrieve
- managedSearchConfiguration for managed KBs
- Multi-type location parsing (S3, Web, Confluence, SharePoint, Custom)
- Updated README with KB retrieval section, reranking options, and doc links
- Added @aws-sdk/client-bedrock-agent-runtime dependency
- Added BEDROCK_MANAGED_KB.md design doc
- Unit tests included
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.

1 participant