Skip to content

Python: feat: add Amazon Bedrock Knowledge Base tool and context provider#7066

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

Python: feat: add Amazon Bedrock Knowledge Base tool and context provider#7066
PVidyadhar wants to merge 1 commit into
microsoft:mainfrom
PVidyadhar:bmkb-managed-kb-support

Conversation

@PVidyadhar

@PVidyadhar PVidyadhar commented Jul 11, 2026

Copy link
Copy Markdown

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 with async run() + get_tool_definition() for agents to call on-demand
    • BedrockKnowledgeBaseProviderContextProvider subclass with before_run() for automatic context injection on every agent invocation
    • Both support managed search (managedSearchConfiguration) and agentic retrieval with fallback
  • What is the impact of these changes?

    • Additive only — new files in python/packages/tools/, no existing code modified
    • Users get two integration patterns: explicit tool calling or automatic context injection
  • What do you want reviewers to focus on?

    • Whether the tool/provider pattern matches the framework's conventions
    • The ContextProvider integration with before_run()

Related Issue

N/A — new feature adding Amazon Bedrock Knowledge Base integration.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change.

Testing

  • Tool.run() returned 5 results from live managed KB in us-west-2
  • Provider._retrieve() returned 5 passages
  • _format_context() produced 7399 chars of formatted context
  • SDK requirement: boto3 >= 1.43
  • Microsoft CLA: pre-approved (cla.opensource.microsoft.com)

Copilot AI review requested due to automatic review settings July 11, 2026 02:30
@giles17 giles17 added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Jul 11, 2026
@github-actions github-actions Bot changed the title feat: add Amazon Bedrock Knowledge Base tool and context provider Python: feat: add Amazon Bedrock Knowledge Base tool and context provider Jul 11, 2026

Copilot AI left a comment

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.

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 BedrockKnowledgeBaseTool with async 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.

Comment thread python/packages/tools/agent_framework_tools/BEDROCK_MANAGED_KB.md Outdated
Comment thread python/packages/tools/agent_framework_tools/BEDROCK_MANAGED_KB.md Outdated
Comment thread python/packages/tools/agent_framework_tools/bedrock_knowledge_base_provider.py Outdated
Comment thread python/packages/tools/agent_framework_tools/bedrock_knowledge_base_provider.py Outdated
Comment thread python/packages/tools/tests/test_bedrock_knowledge_base.py Outdated
Comment thread python/packages/tools/tests/test_bedrock_knowledge_base.py Outdated
Comment thread python/packages/tools/tests/test_bedrock_knowledge_base.py Outdated
Comment thread python/packages/tools/tests/test_bedrock_knowledge_base.py Outdated
@PVidyadhar PVidyadhar force-pushed the bmkb-managed-kb-support branch 3 times, most recently from 7a373b1 to 38ddc1e Compare July 13, 2026 22:21
@PVidyadhar

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Amazon"

@PVidyadhar PVidyadhar force-pushed the bmkb-managed-kb-support branch 3 times, most recently from 51c68e8 to 207c30a Compare July 14, 2026 03:38
- 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
@PVidyadhar PVidyadhar force-pushed the bmkb-managed-kb-support branch from 207c30a to c23c13a Compare July 14, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants