This is the continuation of Blog 1 - https://dev.to/aws-builders/building-a-proactive-ai-travel-agent-on-aws-my-journey-with-bedrock-agentcore-part-1-36c7 and Blog 2- https://dev.to/aws-builders/building-a-proactive-ai-travel-agent-on-aws-my-journey-with-bedrock-agentcore-part-2-199i After successfully building a multi-agent travel planning system locally, I faced the next challenge: integrating it with AWS Bedrock AgentCore for cloud deployment. This post covers the technical journey of wrapping existing Python agents with AgentCore and the lessons learned along the way.
The Challenge: From Local to Cloud-Ready
I had a working travel agent system with multiple components:
- Orchestrator: Main coordination logic
- Planning Agent: AI-powered trip planning
- Booking Tools: Flight and hotel search capabilities
- Travel Tools: External API integration
The goal was to integrate this with AWS Bedrock AgentCore without completely rewriting the existing architecture.
Architecture Overview
My local system used a clean multi-agent pattern:
class Orchestrator:
def __init__(self):
self.planning_agent = PlanningAgent()
self.travel_tool = TravelTool()
def handle_user_request(self, user_input: str) -> str:
# Coordinate between agents and tools
plan = self.planning_agent.create_plan(user_input)
# Execute based on plan...
The AgentCore Integration Journey
Step 1: Installing the Right Packages
The key was identifying the correct AgentCore packages:
pip install bedrock-agentcore
pip install strands-agents
pip install bedrock-agentcore-starter-toolkit
Step 2: Creating the AgentCore Wrapper
Rather than rewriting my agents, I created a thin wrapper that bridges my existing code with AgentCore:
from bedrock_agentcore import BedrockAgentCoreApp
from orchestrator import Orchestrator
app = BedrockAgentCoreApp()
orchestrator = Orchestrator()
@app.entrypoint
def invoke(payload):
user_message = payload.get("message", "")
response = orchestrator.handle_user_request(user_message)
return {
"result": response,
"status": "success",
"powered_by": "AWS Bedrock AgentCore"
}
if __name__ == "__main__":
app.run()
Step 3: Debugging Import Issues
Initially encountered import errors with the Strands framework:
ImportError: cannot import name 'Tool' from 'strands.tools'
The solution was understanding Strands uses lowercase tool
decorator, not Tool
class:
from strands import tool # Not from strands.tools import Tool
Step 4: Handling Class Name Mismatches
My wrapper initially looked for TravelOrchestrator
but my class was named Orchestrator
. The fix was straightforward:
# Instead of:
from orchestrator import TravelOrchestrator
orchestrator = TravelOrchestrator()
# Use:
from orchestrator import Orchestrator
orchestrator = Orchestrator()
Testing the Integration
Once the wrapper was working, testing locally revealed the integration was successful:
python app.py
# Server starts on http://localhost:8080
# Test flight search
curl -X POST http://localhost:8080/invocations \
-H "Content-Type: application/json" \
-d '{"message": "Find flights from NYC to Tokyo"}'
Response:
{
"result": "Flight Search Results:\nSkyWings Flight F101: NYC → Tokyo\nPrice: $349.99",
"session_id": "default",
"status": "success",
"agent": "orchestrator",
"powered_by": "AWS Bedrock AgentCore"
}
AWS Configuration and Infrastructure
AgentCore's configuration process is streamlined:
agentcore configure -e app.py
This automatically:
- Detected my
requirements.txt
- Set up IAM execution roles
- Configured ECR repository
- Generated Docker files for deployment
The configuration summary showed everything was ready:
- Region: us-west-2
- Auto-created execution role and ECR repository
- IAM authorization configured
Deployment Challenges
Attempted cloud deployment with:
agentcore launch
The deployment successfully:
- Created ECR repository in us-west-2
- Set up IAM execution roles
- Configured CodeBuild roles
However, encountered SSL certificate validation issues due to corporate network restrictions:
SSL validation failed for https://bedrock-agentcore-codebuild-sources-*.s3.amazonaws.com/
certificate verify failed: unable to get local issuer certificate
Key Technical Insights
1. Wrapper Pattern Works Well
Rather than rewriting existing agents, the thin AgentCore wrapper approach preserved the original architecture while adding cloud capabilities.
2. Import Debugging Strategy
When facing import errors:
- Check exact class/function names in your modules
- Verify framework-specific import patterns
- Use debugging to see what's actually available in modules
3. AgentCore's Infrastructure Automation
The agentcore configure
and agentcore launch
commands handle significant infrastructure setup automatically:
- IAM role creation with proper policies
- ECR repository setup
- CodeBuild project configuration
- ARM64 container building in the cloud
Architecture Benefits Achieved
The integration maintained the original multi-agent benefits while adding:
- Scalability: Ready for AWS cloud deployment
- Standardization: Uses AgentCore patterns for consistency
- Monitoring: Built-in health checks and logging
- Production-Ready: Automatic infrastructure provisioning
Next Steps
With the local AgentCore integration working, the next phase involves:
- Adding AgentCore Memory for user preference persistence
- Implementing proactive monitoring capabilities
- Completing cloud deployment from a non-restricted network
- Integrating real-time APIs to replace mock data
Code Repository
The complete implementation is available with:
- Original multi-agent system
- AgentCore wrapper integration
- Configuration files for deployment
- Testing commands and examples
Conclusion
Migrating existing Python agents to AWS Bedrock AgentCore doesn't require a complete rewrite. The wrapper pattern allows preserving existing architecture while gaining cloud deployment capabilities. The main challenges were understanding framework-specific imports and navigating network restrictions rather than fundamental architectural issues.
The result is a production-ready travel agent that maintains its original multi-agent design while being deployable on AWS infrastructure with auto-scaling, monitoring, and enterprise-grade security features.
This post is part of my journey building AI agents for the AWS Bedrock AgentCore challenge. Previous posts covered the initial multi-agent architecture and planning system design.
Top comments (0)