Skip to content

Coordinator

The Coordinator is a specialized agent that manages task planning and delegation within the Bedrock Swarm system.

Role and Responsibilities

The Coordinator: 1. Receives user requests 2. Creates structured execution plans 3. Delegates tasks to appropriate specialists 4. Manages dependencies between steps 5. Formats final responses

Plan Creation

Plan Structure

{
  "steps": [
    {
      "step_number": 1,
      "description": "Calculate 15 * 7",
      "specialist": "calculator"
    },
    {
      "step_number": 2,
      "description": "Calculate time {MINUTES} minutes from now",
      "specialist": "time_expert",
      "requires_results_from": [1]
    }
  ],
  "final_output_format": "In {MINUTES} minutes, it will be {TIME}"
}

Plan Validation

The Coordinator validates: - Step numbering is sequential - Dependencies are valid - Specialists exist - Steps are atomic - Descriptions are clear

Task Delegation

  1. Specialist Selection
  2. Matches tasks to specialist capabilities
  3. Ensures specialists have required tools
  4. Handles missing specialist errors

  5. Dependency Management

  6. Tracks step dependencies
  7. Ensures prerequisites are met
  8. Passes results between steps

  9. Error Handling

  10. Validates specialist responses
  11. Manages execution failures
  12. Provides clear error messages

Response Formatting

The Coordinator: 1. Collects results from all steps 2. Applies the specified format 3. Creates natural language responses 4. Maintains conversation context

Example Usage

from bedrock_swarm.agency import Agency
from bedrock_swarm.agents import BedrockAgent
from bedrock_swarm.tools import CalculatorTool, CurrentTimeTool

# Create specialists
calculator = BedrockAgent(
    name="calculator",
    model_id="us.anthropic.claude-3-5-sonnet-20241022-v2:0",
    tools=[CalculatorTool()]
)

time_expert = BedrockAgent(
    name="time_expert",
    model_id="us.anthropic.claude-3-5-sonnet-20241022-v2:0",
    tools=[CurrentTimeTool()]
)

# Create agency (coordinator is created automatically)
agency = Agency(specialists=[calculator, time_expert])

# Process request (coordinator handles planning)
response = agency.process_request("What time will it be 15 * 7 minutes from now?")

Best Practices

  1. Plan Design
  2. Keep steps atomic
  3. Use clear descriptions
  4. Specify dependencies explicitly

  5. Specialist Management

  6. Define clear specialist roles
  7. Provide focused tools
  8. Handle missing specialists

  9. Error Handling

  10. Validate inputs thoroughly
  11. Provide helpful error messages
  12. Handle edge cases gracefully

  13. Response Formatting

  14. Use clear format templates
  15. Include all relevant information
  16. Maintain natural language flow