How awslabs/amazon-bedrock-agent-samples works
Project Type and Purpose
• This is an open-source sample repository showcasing Amazon Bedrock Agents in both single-agent and multi-agent collaboration scenarios.
• It provides:
• “examples/…”—dozens of ready-to-run demos (Python scripts, Jupyter notebooks, CDK/CloudFormation templates, React/Streamlit UIs)
• A core Python library “src/InlineAgent” for building inline and multi-agent workflows
• Reusable modules in “src/shared” (Action Groups, web-search, working memory, stock data)
• Utility wrappers in “src/utils” abstracting boto3 calls to Bedrock and other AWS services
Directory-Based Architectural Insights
• examples/agents & examples/multi_agent_collaboration: Presentation layer (scripts, notebooks) that drive various agent flows
• examples/agents_ux: UI demos (Streamlit, Flask, React via AWS Amplify)
• examples/sdk: Lambda-based SDK usage samples
• src/InlineAgent: Core library implementing agent orchestration (inline_agent, action_group, observability hooks, confirmation, ROC processing)
• src/shared: Packaged Action Groups deployed as AWS Lambda/Step Functions via CDK/CloudFormation
• src/utils: Higher-level Bedrock Agent helpers, knowledge base loaders, instrumentation wrappers
README Architecture Highlights
• Architecture.gif shows: Client apps → InlineAgent library → AWS Bedrock Agent API → Action Groups (Lambda) → Data stores/External APIs → Observability
• The README calls out: Boto3 SDK, AWS CDK (TypeScript & Python), multi-agent supervisor/routing modes, guardrails, traces
a. Main Components
• Developer Environment: IDE/CLI, Jupyter notebooks, Streamlit/Flask UIs, React front-end
• Example Drivers: Python scripts & notebooks under examples/agents & examples/multi_agent_collaboration
• Core Library: InlineAgent package (agent orchestration, confirmation, ROC processing, observability hooks)
• Shared Modules (Action Groups): Packaged Lambda functions & Step Functions in src/shared
• Utility Layer: src/utils for Bedrock Agent and knowledge base interactions
• AWS Cloud:
• Amazon Bedrock Agents API
• AWS Lambda & Step Functions (Action Groups)
• AWS CDK/CloudFormation stacks (in examples & src/shared/cfn_stacks)
• Data Stores: S3, Athena, DynamoDB, ClickHouse (in ECS Fargate example)
• Observability: OpenTelemetry agent, AWS X-Ray or custom trace provider
• Front-end Hosting: AWS Amplify, ECS Fargate, API Gateway
• External Services: Web search APIs, third-party services invoked via Action Groups
b. Component Interactions
1. Client/UI (notebook, Streamlit, React) invokes Example Driver
2. Example Driver imports & configures InlineAgent library
3. InlineAgent orchestrates calls to AWS Bedrock Agent via src/utils/bedrock_agent.py
4. InlineAgent routes to one or more Action Groups (Lambda or Step Functions) in src/shared
5. Action Groups perform tasks (web search, memory lookup, stock data) and return to agent
6. InlineAgent collects results, applies guardrails/confirmations, builds responses
7. Observability module instruments each call, emits spans/traces to OpenTelemetry collector
8. In multi-agent mode, a “supervisor agent” coordinates multiple agent roles via Bedrock routing API
c. Architectural Patterns and Principles
• Layered architecture: Presentation → Orchestration (InlineAgent) → Infrastructure as Code → Platform Services
• Modular “Action Group” pattern: discrete, deployable Lambda/Step Functions for extensibility
• Dependency inversion: high-level agent code depends on abstractions (src/utils, shared plugins)
• Infrastructure as code with CDK/CloudFormation templates next to examples for reproducibility
• Observability built-in: OpenTelemetry instrumentation within InlineAgent and Agent handlers
d. Key Technologies and Frameworks
• Python ecosystem: boto3, lambda, streamlit, flask, unittest/pytest
• AWS CDK (TypeScript & Python) & CloudFormation
• AWS Services: Bedrock Agent, Lambda, Step Functions, S3, Athena, DynamoDB, ECS Fargate, API Gateway, Amplify, X-Ray
• OpenTelemetry for agent instrumentation
• React + AWS Amplify for UX demos