feat: add Bedrock Managed Knowledge Base support to RetrieveTool - #360
feat: add Bedrock Managed Knowledge Base support to RetrieveTool#360PVidyadhar wants to merge 1 commit into
Conversation
35de2cc to
a1a6ce9
Compare
5395830 to
ac3fd78
Compare
- 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
ac3fd78 to
89371f8
Compare
| retrievers: [ | ||
| { | ||
| type: 'KNOWLEDGE_BASE', | ||
| knowledgeBaseConfiguration: { | ||
| knowledgeBaseId, | ||
| numberOfResults: | ||
| input.retrievalConfiguration?.managedSearchConfiguration?.numberOfResults ?? 5 | ||
| } | ||
| } | ||
| ], | ||
| agenticRetrieveConfiguration: { | ||
| foundationModelType: 'MANAGED', | ||
| rerankingConfiguration: { type: 'MANAGED' } | ||
| }, | ||
| generateResponse | ||
| }) |
There was a problem hiding this comment.
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
| retrievalResults: agenticResult.results || [], | ||
| ...(generateResponse && agenticResult.generatedResponse | ||
| ? { generatedAnswer: agenticResult.generatedResponse.answer } | ||
| : {}) |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
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 usesmanagedSearchConfigurationand attempts AgenticRetrieveStream for intelligent querydecomposition and reranking. Existing VECTOR behavior is unchanged.
Changes:
knowledgeBaseTypeparameter (default: VECTOR)managedSearchConfigurationsupport alongside existingvectorSearchConfigurationTesting:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.