{"id":8810,"library":"agent-framework-bedrock","title":"Amazon Bedrock Integration for Microsoft Agent Framework","description":"The `agent-framework-bedrock` library provides an integration for the Microsoft Agent Framework to connect with Amazon Bedrock. It enables Agent Framework applications to leverage Bedrock's foundational models for tasks such as Chat Completion, Text Generation, and Text Embeddings. This package is part of Microsoft's broader Agent Framework, which aims to provide a unified, open-source SDK for building, orchestrating, and deploying AI agents and multi-agent workflows in Python and .NET. The current version, `1.0.0b260409`, is a beta release, indicating active development within the recently released 1.0 version of the main `agent-framework`.","status":"active","version":"1.0.0b260409","language":"en","source_language":"en","source_url":"https://github.com/microsoft/agent-framework","tags":["agent-framework","amazon-bedrock","ai","microsoft-agent-framework","bedrock","aws","connector"],"install":[{"cmd":"pip install agent-framework-bedrock","lang":"bash","label":"Install specific package"},{"cmd":"pip install agent-framework","lang":"bash","label":"Install main framework with all connectors (recommended for development)"}],"dependencies":[{"reason":"Core components of the Microsoft Agent Framework, which this package extends.","package":"agent-framework-core"},{"reason":"AWS SDK for Python, used for interacting with Amazon Bedrock APIs.","package":"boto3"}],"imports":[{"note":"The `BedrockChatClient` is found under `agent_framework.amazon` within the main `agent-framework` package, not directly within `agent_framework_bedrock`.","wrong":"from agent_framework_bedrock.services import BedrockChatClient","symbol":"BedrockChatClient","correct":"from agent_framework.amazon import BedrockChatClient"},{"note":"The core `Agent` class is imported directly from the `agent_framework` package.","symbol":"Agent","correct":"from agent_framework import Agent"}],"quickstart":{"code":"import asyncio\nimport os\nfrom agent_framework import Agent\nfrom agent_framework.amazon import BedrockChatClient\nfrom agent_framework.core.message import Message\n\nasync def main():\n    # Ensure AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)\n    # and AWS_REGION_NAME are set as environment variables or via AWS CLI config.\n    # Example Bedrock model ID, e.g., \"anthropic.claude-v2\" or \"amazon.titan-text-express-v1\"\n    bedrock_model_id = os.environ.get(\"BEDROCK_MODEL_ID\", \"anthropic.claude-v2\")\n    aws_region = os.environ.get(\"AWS_REGION_NAME\", \"us-east-1\")\n\n    if not all(os.environ.get(var) for var in [\"AWS_ACCESS_KEY_ID\", \"AWS_SECRET_ACCESS_KEY\", \"AWS_REGION_NAME\"]):\n        print(\"Warning: AWS credentials or region not fully configured via environment variables.\")\n        print(\"Please set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION_NAME.\")\n        # In a real application, you might raise an error or use a credential provider.\n\n    try:\n        # Initialize the Bedrock chat client\n        client = BedrockChatClient(region_name=aws_region, model=bedrock_model_id)\n\n        # Create an Agent Framework Agent with the Bedrock client\n        bedrock_agent = Agent(\n            client=client,\n            instructions=\"You are a helpful AI assistant that responds concisely.\",\n            name=\"BedrockAssistant\",\n        )\n\n        # Run a simple interaction\n        response_messages = await bedrock_agent.run(\"Tell me a fun fact about Python.\")\n\n        # Print the agent's response\n        for msg in response_messages:\n            print(f\"[{msg.author_name}]: {msg.text}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"Ensure AWS credentials and BEDROCK_MODEL_ID/AWS_REGION_NAME are correctly configured.\")\n        print(\"Also, verify that the specified Bedrock model is enabled in your AWS account and region.\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to initialize a `BedrockChatClient` and use it to create an `Agent` from the Microsoft Agent Framework. It assumes AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) and the AWS region (AWS_REGION_NAME) are configured in the environment, along with a specified Bedrock model ID (BEDROCK_MODEL_ID). The agent then processes a simple prompt and prints the response."},"warnings":[{"fix":"Refer to the latest Microsoft Agent Framework documentation and changelog, especially during upgrades, to identify and adapt to API changes. Pin exact versions for stability in production.","message":"As a beta package (`1.0.0b`), `agent-framework-bedrock` is subject to non-backward compatible changes. The underlying Microsoft Agent Framework itself has undergone breaking changes during its preview phase.","severity":"breaking","affected_versions":"All `1.0.0b` versions"},{"fix":"Thoroughly review and configure your AWS IAM policies and roles. Ensure the principal calling Bedrock has the required `bedrock` permissions and that the chosen model is enabled in your AWS account and region. Check AWS documentation for specific permissions.","message":"AWS IAM permissions are a common source of errors. The agent's execution role or your local credentials must have `bedrock:InvokeModel` and other necessary permissions (e.g., for `bedrock:InvokeAgentRuntime` if deploying agents).","severity":"gotcha","affected_versions":"All versions"},{"fix":"If manually parsing responses, ensure you iterate over the `EventStream` to extract chunks and decode the content. The `BedrockChatClient` in `agent-framework` should handle this abstraction, but it's a known lower-level issue to be aware of.","message":"When interacting with Amazon Bedrock Agents (especially at a lower level or through `boto3`), the 'completion' field in the response is often an `EventStream` object, not a direct JSON object, which can lead to parsing errors.","severity":"gotcha","affected_versions":"All versions when directly interacting with underlying Bedrock Agent APIs or `boto3`."},{"fix":"If encountering validation errors related to tool configuration when no tools are expected, check the `agent-framework` GitHub issues for patches or workarounds. This might require updating `agent-framework-bedrock` or the main `agent-framework` to a version where this specific bug is resolved.","message":"There have been reports (e.g., GitHub issue #5165 for `microsoft/agent-framework`) where `BedrockChatClient` might send `toolConfig.toolChoice` without `toolConfig.tools` when an agent has no tools configured, causing AWS Bedrock API validation errors.","severity":"gotcha","affected_versions":"Likely affecting `1.0.0b` versions where this bug exists."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the AWS IAM role or user associated with your credentials has an explicit `Allow` policy for `bedrock:InvokeModel` on the target Bedrock foundation model. Verify the region and model ARN are correct.","cause":"The AWS credentials used (either environment variables or configured profile) lack the necessary IAM permissions to invoke the specified Bedrock model in the given region.","error":"botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the InvokeModel operation: User: arn:aws:iam::xxxxxxxxxxxx:user/your-user is not authorized to perform: bedrock:InvokeModel on resource: arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-v2 with an explicit deny in an identity-based policy"},{"fix":"Check the AWS Bedrock documentation for supported model IDs and ensure the model is enabled in your AWS account and the specified `region_name`. Update the `BEDROCK_MODEL_ID` environment variable or the `model` parameter accordingly.","cause":"The `model` parameter passed to `BedrockChatClient` is not a valid Bedrock model ID or is not enabled for your AWS account/region.","error":"ValueError: Invalid Bedrock model_id 'invalid-model'. See https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html"},{"fix":"Ensure you have installed `agent-framework` (which includes connectors like `amazon`) or `agent-framework-bedrock` using `pip install agent-framework` or `pip install agent-framework-bedrock`. Verify the import statement is `from agent_framework.amazon import BedrockChatClient`.","cause":"The `agent-framework-bedrock` package or the main `agent-framework` is not installed correctly, or the import path is wrong.","error":"ModuleNotFoundError: No module named 'agent_framework.amazon'"}]}