Skip to content

feat: add Bedrock Managed Knowledge Base support to RetrieveTool - #360

Open
PVidyadhar wants to merge 1 commit into
aws-samples:mainfrom
PVidyadhar:bmkb-managed-kb-support
Open

feat: add Bedrock Managed Knowledge Base support to RetrieveTool#360
PVidyadhar wants to merge 1 commit into
aws-samples:mainfrom
PVidyadhar:bmkb-managed-kb-support

Conversation

@PVidyadhar

Copy link
Copy Markdown

Issue #, if available:

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

Description of changes:

Added Bedrock Managed Knowledge Base support to the RetrieveTool. The tool now supports both MANAGED and VECTOR knowledge bases. When
knowledgeBaseType: "MANAGED" is passed, the tool uses managedSearchConfiguration and attempts AgenticRetrieveStream for intelligent query
decomposition and reranking. Existing VECTOR behavior is unchanged.

Changes:

  • RetrieveTool supports MANAGED KB type via knowledgeBaseType parameter (default: VECTOR)
  • Added managedSearchConfiguration support alongside existing vectorSearchConfiguration
  • Added AgenticRetrieveStream for MANAGED KBs with fallback to plain Retrieve
  • Updated README with managed KB callout and reranking options
  • 262 jest tests pass
  • Added BEDROCK_MANAGED_KB.md design doc
  • Existing VECTOR retrieval path unchanged

Testing:

  • Jest: ✅ 262 tests pass (8 suites)
  • Live E2E: ✅ managedSearchConfiguration returns results from managed KB
  • Live E2E: ✅ vectorSearchConfiguration correctly rejected on managed KB (clear error)
  • Live E2E: ✅ No config (API auto-detects) works for both types
  • Existing VECTOR path: ✅ Unchanged (default behavior)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@PVidyadhar
PVidyadhar force-pushed the bmkb-managed-kb-support branch 2 times, most recently from 35de2cc to a1a6ce9 Compare July 11, 2026 00:28
@PVidyadhar
PVidyadhar marked this pull request as ready for review July 13, 2026 17:51
@PVidyadhar
PVidyadhar force-pushed the bmkb-managed-kb-support branch 2 times, most recently from 5395830 to ac3fd78 Compare July 15, 2026 07:45
- RetrieveTool supports MANAGED KB type via knowledgeBaseType parameter (default: VECTOR)
- Added managedSearchConfiguration support alongside existing vectorSearchConfiguration
- Added AgenticRetrieveStream for MANAGED KBs with fallback to plain Retrieve
- Updated README with managed KB callout and reranking options
- 262 jest tests pass
- Added BEDROCK_MANAGED_KB.md design doc
- Existing VECTOR retrieval path unchanged
@PVidyadhar
PVidyadhar force-pushed the bmkb-managed-kb-support branch from ac3fd78 to 89371f8 Compare July 16, 2026 01:01
Comment on lines +225 to +240
retrievers: [
{
type: 'KNOWLEDGE_BASE',
knowledgeBaseConfiguration: {
knowledgeBaseId,
numberOfResults:
input.retrievalConfiguration?.managedSearchConfiguration?.numberOfResults ?? 5
}
}
],
agenticRetrieveConfiguration: {
foundationModelType: 'MANAGED',
rerankingConfiguration: { type: 'MANAGED' }
},
generateResponse
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retrievers and agenticRetrieveConfiguration shapes don't match the SDK
(@aws-sdk/client-bedrock-agent-runtime@3.1075.0) and will fail with a ValidationException

Comment on lines +252 to +255
retrievalResults: agenticResult.results || [],
...(generateResponse && agenticResult.generatedResponse
? { generatedAnswer: agenticResult.generatedResponse.answer }
: {})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AgenticRetrieveStreamResponse is { stream: AsyncIterable<AgenticRetrieveStreamResponseOutput> } — there is no top-level results or generatedResponse. You have to iterate the stream and read event.result.results / event.result.generatedResponse. As written, agenticResult.results is always undefined, so this silently returns an empty result set.

Comment on lines +66 to +70
async agenticRetrieveStream(props: any) {
const agentClient = createAgentRuntimeClient(this.context.store.get('aws'))
const command = new AgenticRetrieveStreamCommand(props)
const res = await agentClient.send(command)
return res

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns { stream: AsyncIterable } from the main process, but IPC uses structured clone — an AsyncIterable
event stream cannot be serialized across the main→preload/renderer boundary. The stream must be fully consumed and
aggregated into a plain object here in the main process before returning. As designed, the renderer receives
nothing usable even if the request were valid.

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.

2 participants