A production-ready AI agent for handling customer returns and refunds, built with Amazon Bedrock AgentCore Runtime.
This project demonstrates a complete end-to-end implementation of an enterprise-grade AI agent with:
- π§ Memory Integration - Persistent conversation history and user preferences
- π Gateway Integration - External API calls via Lambda functions
- π Knowledge Base - Document retrieval for policy information
- π οΈ Custom Tools - Business logic for eligibility and refund calculations
- βοΈ Production Deployment - Serverless on AgentCore Runtime
- π Full Observability - CloudWatch Logs, X-Ray traces, GenAI dashboards
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AgentCore Runtime β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Returns & Refunds Agent β β
β β β’ Memory (Preferences, History, Summaries) β β
β β β’ Gateway (Order Lookup via Lambda) β β
β β β’ Knowledge Base (Policy Documents) β β
β β β’ Custom Tools (Eligibility, Refund Calc) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
AgentCore AgentCore Lambda Function
Memory Gateway (Order Lookup)
- AWS Account with appropriate permissions
- Python 3.10+
- AWS CLI configured
- Bedrock model access (Claude Sonnet 4.5)
git clone https://github.com/arvind-narain/returns-refunds-agent.git
cd returns-refunds-agentpip install -r requirements.txt# Create Memory
python3 src/infrastructure/03_create_memory.py
python3 src/infrastructure/04_seed_memory.py
# Setup Authentication
python3 src/infrastructure/08_create_cognito.py
# Create IAM Roles
python3 src/infrastructure/09_create_gateway_role.py
python3 src/infrastructure/16_create_runtime_role.py
# Setup Gateway
python3 src/infrastructure/10_create_lambda.py
python3 src/infrastructure/11_create_gateway.py
python3 src/infrastructure/12_add_lambda_to_gateway.py# Deploy to AgentCore Runtime
python3 scripts/19_deploy_agent.py
# Check deployment status
python3 scripts/20_check_status.py
# Test the agent
python3 scripts/21_invoke_agent.pycd src/ui
./run_streamlit.shAccess at: http://localhost:8501
returns-refunds-agent/
βββ src/
β βββ agents/ # Agent implementations
β β βββ 01_returns_refunds_agent.py
β β βββ 06_memory_enabled_agent.py
β β βββ 14_full_agent.py
β β βββ 17_runtime_agent.py
β βββ infrastructure/ # AWS infrastructure setup
β β βββ 03_create_memory.py
β β βββ 04_seed_memory.py
β β βββ 08_create_cognito.py
β β βββ 09_create_gateway_role.py
β β βββ 10_create_lambda.py
β β βββ 11_create_gateway.py
β β βββ 12_add_lambda_to_gateway.py
β β βββ 13_list_gateway_targets.py
β β βββ 16_create_runtime_role.py
β βββ tests/ # Test scripts
β β βββ 02_test_agent.py
β β βββ 05_test_memory.py
β β βββ 07_test_memory_agent.py
β β βββ 15_test_full_agent.py
β βββ ui/ # User interface
β βββ streamlit_app.py
β βββ run_streamlit.sh
βββ scripts/ # Deployment & operations
β βββ 19_deploy_agent.py
β βββ 20_check_status.py
β βββ 21_invoke_agent.py
β βββ 22_get_dashboard.py
β βββ 23_get_logs_info.py
βββ docs/ # Documentation
βββ agentcore-mcp-server/ # MCP server implementation
βββ requirements.txt
βββ requirements_streamlit.txt
βββ LICENSE
βββ README.md
The agent includes three custom business logic tools:
- check_return_eligibility - Validates return eligibility based on purchase date and category
- calculate_refund_amount - Calculates refund based on price, condition, and return reason
- format_policy_response - Formats policy information in a customer-friendly way
python3 scripts/22_get_dashboard.pypython3 scripts/23_get_logs_info.pyaws logs tail /aws/bedrock-agentcore/runtimes/returns_refunds_agent-* --follow# Test original agent
python3 src/tests/02_test_agent.py
# Test memory integration
python3 src/tests/07_test_memory_agent.py
# Test full agent with all features
python3 src/tests/15_test_full_agent.py# Invoke deployed agent
python3 scripts/21_invoke_agent.py- OAuth 2.0 authentication via Cognito
- IAM roles with least-privilege permissions
- Secure credential management via environment variables
- Configuration files excluded from version control
- β Memory - Persistent conversation history and preferences
- β Gateway - External API integration via Lambda
- β Knowledge Base - Document retrieval for policies
- β Custom Tools - Business logic implementation
- β Streaming - Real-time response streaming
- β Authentication - OAuth 2.0 with Cognito
- β Observability - CloudWatch Logs, X-Ray traces
- β Auto-scaling - Serverless with automatic scaling
- β Error Handling - Comprehensive error handling and logging
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Amazon Bedrock AgentCore
- Powered by Strands Agents Framework
- UI built with Streamlit
For questions or support, please open an issue on GitHub.
Built with β€οΈ using Amazon Bedrock AgentCore Runtime