Python: feat: add Amazon Bedrock Knowledge Base tool and context provider#7066
Draft
PVidyadhar wants to merge 1 commit into
Draft
Python: feat: add Amazon Bedrock Knowledge Base tool and context provider#7066PVidyadhar wants to merge 1 commit into
PVidyadhar wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Amazon Bedrock Knowledge Base retrieval capabilities to the Python tools package, enabling both explicit tool-based retrieval and automatic context injection via a ContextProvider.
Changes:
- Introduces
BedrockKnowledgeBaseToolwithasync run()+get_tool_definition()for on-demand KB retrieval. - Introduces
BedrockKnowledgeBaseProvider(ContextProvider.before_run) to inject KB context automatically per agent invocation. - Adds a design/usage doc plus unit tests for the new tool/provider.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 17 comments.
| File | Description |
|---|---|
| python/packages/tools/agent_framework_tools/bedrock_knowledge_base.py | Adds the Bedrock Knowledge Base tool implementation and tool definition metadata. |
| python/packages/tools/agent_framework_tools/bedrock_knowledge_base_provider.py | Adds a context provider that retrieves and injects KB passages before runs. |
| python/packages/tools/tests/test_bedrock_knowledge_base.py | Adds unit tests covering tool retrieval, default config behavior, and provider retrieval. |
| python/packages/tools/agent_framework_tools/BEDROCK_MANAGED_KB.md | Adds documentation describing usage, configuration, and permissions. |
7a373b1 to
38ddc1e
Compare
Author
|
@microsoft-github-policy-service agree company="Amazon" |
51c68e8 to
207c30a
Compare
- Created BedrockKnowledgeBaseTool with async run() + get_tool_definition() - Created BedrockKnowledgeBaseProvider (ContextProvider subclass) with before_run() - Two integration points: standalone tool + automatic context injection - Supports managed search and agentic retrieval with fallback - Unit tests included - Added BEDROCK_MANAGED_KB.md design doc
207c30a to
c23c13a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add Amazon Bedrock Knowledge Base tool and context provider
Motivation & Context
Enables Agent Framework agents to retrieve context from Amazon Bedrock Knowledge Bases. This adds RAG capabilities using AWS's managed infrastructure without requiring users to manage their own vector stores or embedding pipelines.
Description & Review Guide
What are the major changes?
BedrockKnowledgeBaseTool— standalone tool withasync run()+get_tool_definition()for agents to call on-demandBedrockKnowledgeBaseProvider—ContextProvidersubclass withbefore_run()for automatic context injection on every agent invocationmanagedSearchConfiguration) and agentic retrieval with fallbackWhat is the impact of these changes?
python/packages/tools/, no existing code modifiedWhat do you want reviewers to focus on?
ContextProviderintegration withbefore_run()Related Issue
N/A — new feature adding Amazon Bedrock Knowledge Base integration.
Contribution Checklist
Testing
Tool.run()returned 5 results from live managed KB in us-west-2Provider._retrieve()returned 5 passages_format_context()produced 7399 chars of formatted contextboto3 >= 1.43