Skip to content

Architecture

The Bedrock Swarm is a framework for building multi-agent systems using Amazon Bedrock. It provides a flexible architecture that enables direct agent-to-agent communication and tool execution.

Core Components

Agency

The central orchestrator that: - Manages communication between agents - Handles request processing - Manages shared memory and event tracing - Coordinates tool execution and responses

Agents

Autonomous agents that: - Process user requests directly - Execute tools within their capabilities - Communicate with other agents as needed - Maintain their own context and memory

Tools

Reusable components that: - Provide specific functionality to agents - Handle input validation and processing - Return structured outputs - Can be shared across agents

Communication Flow

sequenceDiagram
    participant User
    participant Agency
    participant Agent1
    participant Agent2
    participant Tools

    User->>Agency: process_request()
    Agency->>Agent1: handle_request()

    Note over Agent1: Processes request and<br/>determines needed tools/agents

    Agent1->>Tools: execute_tool()
    Tools-->>Agent1: tool_result

    Agent1->>Agent2: request_assistance()
    Agent2->>Tools: execute_tool()
    Tools-->>Agent2: tool_result
    Agent2-->>Agent1: assistance_response

    Agent1-->>Agency: final_response
    Agency-->>User: formatted_response

Request Processing Flow

  1. Request Handling
  2. User sends request to Agency
  3. Agency routes to appropriate agent
  4. Agent processes request and determines actions

  5. Execution Phase

  6. Agent executes necessary tools
  7. Communicates with other agents if needed
  8. Maintains context through memory system
  9. Events are traced for debugging

  10. Response Phase

  11. Agent formulates response
  12. Agency formats and returns to user

Memory and State Management

The system uses a flexible memory system that allows: - Per-agent memory storage - Shared memory across agents - Persistent context maintenance - Event history tracking

Event Tracing

The Agency includes comprehensive event tracing:

[timestamp] request_received - Agency
[timestamp] agent_processing - Agent: agent1
[timestamp] tool_execution - Agent: agent1, Tool: calculator
[timestamp] agent_communication - From: agent1, To: agent2
[timestamp] response_complete - Agency

Best Practices

  1. Agent Design
  2. Define clear agent responsibilities
  3. Implement proper error handling
  4. Use appropriate memory management
  5. Document agent capabilities

  6. Tool Implementation

  7. Validate inputs thoroughly
  8. Return structured outputs
  9. Include helpful error messages
  10. Document expected behavior

  11. Memory Management

  12. Use appropriate memory types
  13. Clean up unused memory
  14. Handle memory conflicts
  15. Document memory patterns