Skip to main content

AWS Agent Refactoring - Complete ✅

Status: 🟢 In-use Category: Refactoring & Implementation Date: October 22, 2024

Summary

Successfully refactored the AWS agent to use BaseStrandsAgent and BaseStrandsAgentExecutor, reducing code duplication by ~330 lines and standardizing the Strands agent pattern.

Changes Made

1. Code Refactoring

  • ✅ Renamed utils/a2autils/a2a_common (avoid conflicts with a2a-sdk)
  • ✅ Enhanced BaseStrandsAgent to support BedrockModel
  • ✅ Refactored AWS agent from 734 → 541 lines
  • ✅ Refactored AWS executor from 160 → 21 lines
  • ✅ Updated all imports across codebase

2. Dependency Fixes

Added to ai_platform_engineering/agents/aws/pyproject.toml:

dependencies = [
...
"ai-platform-engineering-utils",
]

[tool.hatch.metadata]
allow-direct-references = true

Added to ai_platform_engineering/utils/pyproject.toml:

dependencies = [
...
"strands-agents>=0.1.0",
"mcp>=1.12.2",
]

3. Docker Configuration

Added to both agent-aws-slim and agent-aws-p2p in docker-compose.dev.yaml:

volumes:
- ./ai_platform_engineering/agents/aws/agent_aws:/app/agent_aws
- ./ai_platform_engineering/agents/aws/clients:/app/clients
- ./ai_platform_engineering/utils:/app/ai_platform_engineering/utils # ← NEW

4. Import Pattern

All agents now use direct imports:

# LangGraph-based agents (e.g., Komodor)
from ai_platform_engineering.utils.a2a_common.base_agent import BaseLangGraphAgent
from ai_platform_engineering.utils.a2a_common.base_agent_executor import BaseLangGraphAgentExecutor

# Strands-based agents (e.g., AWS)
from ai_platform_engineering.utils.a2a_common.base_strands_agent import BaseStrandsAgent
from ai_platform_engineering.utils.a2a_common.base_strands_agent_executor import BaseStrandsAgentExecutor

Next Steps

To Test the Changes:

  1. Rebuild the Docker containers:

    docker-compose -f docker-compose.dev.yaml build agent-aws-slim
  2. Start the AWS agent:

    docker-compose -f docker-compose.dev.yaml up agent-aws-slim
  3. Verify the agent starts without import errors

To Deploy:

  1. Ensure ai-platform-engineering-utils package is built and available
  2. Update any CI/CD pipelines to include utils dependencies
  3. Test with your target MCP servers enabled

Files Modified

  • ai_platform_engineering/utils/__init__.py - Simplified imports
  • ai_platform_engineering/utils/a2a_common/base_strands_agent.py - Enhanced for BedrockModel
  • ai_platform_engineering/agents/aws/agent_aws/agent.py - Refactored to extend BaseStrandsAgent
  • ai_platform_engineering/agents/aws/agent_aws/protocol_bindings/a2a_server/agent_executor.py - Simplified to extend BaseStrandsAgentExecutor
  • ai_platform_engineering/agents/aws/pyproject.toml - Added utils dependency
  • ai_platform_engineering/utils/pyproject.toml - Added strands dependencies
  • docker-compose.dev.yaml - Added utils volume mounts
  • ✅ Updated all import statements across the codebase

Benefits

  • 🎯 Code Reduction: ~330 lines eliminated
  • 🔧 Maintainability: Single source of truth for Strands patterns
  • 🚀 Consistency: All Strands agents follow the same pattern
  • No Conflicts: Renamed a2a → a2a_common to avoid SDK conflicts
  • 📦 Proper Dependencies: Utils package properly configured

Status: Ready for testing Date: $(date +%Y-%m-%d)