-
Notifications
You must be signed in to change notification settings - Fork 19
Dhaval strands example #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shadhav
wants to merge
6
commits into
aws-samples:main
Choose a base branch
from
shadhav:dhaval-strands-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+1,278
−4
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added comprehensive Strands section to 5_agent_frameworks.ipynb - Includes basic Strands agent creation with LiteLLM integration - Demonstrates tool integration with built-in calculator and custom tools - Shows abstraction layer for platform interoperability - Updated introduction to mention CrewAI and Strands frameworks - Updated conclusion to reflect 3 implemented frameworks - Provides educational examples for students learning agent frameworks The Strands section follows the same pattern as LangChain and PydanticAI sections, showing how different frameworks can be used with consistent abstractions while maintaining their unique strengths.
Core Implementation: - strands_agent.py: Main agent wrapper integrating Strands with platform * Uses StrandsAgentWrapper class for platform abstraction * Integrates with MemoryGatewayClient for conversation management * Routes through LiteLLMGatewayClient for model access * Handles AgenticRequest/AgenticResponse format conversion * Supports tool integration and session management - strands_agent_controller.py: Request handling controller * Follows same pattern as existing DIY and PydanticAI agents * Lazy-loads agent instance for performance * Pre-configured with retrieval, weather, and calculator tools * Provides clean invoke() interface for FastAPI integration - server.py: FastAPI web server * Standard /invoke endpoint for agent requests * /health endpoint for Kubernetes health checks * Proper middleware and error handling * Follows exact same pattern as other agent servers - requirements.txt: Dependencies for Strands integration * strands-agents[litellm] for core framework * strands-agents-tools for built-in tools * FastAPI and uvicorn for web server - README.md: Comprehensive documentation * Architecture overview and usage instructions * Local development and EKS deployment guides * API endpoint documentation and configuration details This implementation ensures the Strands agent integrates seamlessly with the existing agentic platform while maintaining Strands' simplicity and native LiteLLM integration capabilities.
Docker Configuration: - docker/strands-agent/Dockerfile: Multi-stage container build * Uses Python 3.12.10-alpine3.21 base image for security and size * Builder stage installs dependencies from requirements.txt * Server stage copies source code with proper ownership * Non-root user (appuser) for security best practices * Exposes port 8000 for FastAPI server * PYTHONPATH configured for proper module resolution * CMD runs uvicorn server with Strands agent application Kubernetes Configuration: - k8s/helm/values/applications/strands-agent-values.yaml: Helm values * Follows exact same pattern as existing agent deployments * Configured for 'agentic-platform-strands-agent' container image * ClusterIP service with port 80 -> 8000 mapping * Ingress enabled with '/strands-agent' path routing * Resource limits: 100m CPU request, 256Mi-512Mi memory * Service account with IRSA configuration for AWS permissions * Environment variables for gateway endpoint discovery * Default endpoints for LiteLLM, Memory, and Retrieval gateways This deployment configuration enables the Strands agent to be deployed to EKS using the existing deployment scripts: - ./deploy/build-container.sh strands-agent - ./deploy/deploy-application.sh strands-agent --build The configuration ensures proper integration with the platform's service mesh, ingress routing, and AWS IAM permissions.
Test Infrastructure: - tests/strands_agent/__init__.py: Package initialization * Defines test suite version and metadata * Documents test categories and usage patterns - tests/strands_agent/test_strands_agent.py: Structural validation tests * test_file_structure(): Validates all required files exist * test_python_syntax(): Checks Python syntax validity using AST parsing * test_imports_structure(): Verifies required imports are present * test_class_structure(): Validates class methods and structure * test_docker_structure(): Checks Dockerfile configuration * test_requirements(): Validates dependencies in requirements.txt * All 6 tests pass, ensuring code structure integrity - tests/strands_agent/test_strands_api.py: Live API endpoint tests * test_health_endpoint(): Validates /health endpoint functionality * test_invoke_endpoint(): Tests /invoke with sample AgenticRequest * test_weather_tool(): Validates weather tool integration * Supports both local (localhost:8000) and remote URL testing * Comprehensive error handling and response validation - tests/strands_agent/run_tests.py: Automated test runner * Runs structural tests first (always required) * Auto-detects if agent is running for API tests * Supports remote URL testing for deployed agents * Provides detailed test summary and next steps * Smart skipping of unavailable tests with clear instructions - tests/strands_agent/README.md: Complete testing documentation * Comprehensive guide covering all testing scenarios * Local development, API testing, and EKS deployment testing * Troubleshooting guide for common issues * Usage examples and success criteria * Development workflow and maintenance instructions Test Coverage: ✅ Code structure and syntax validation ✅ Import statement verification ✅ Class method presence and structure ✅ Docker and Kubernetes configuration ✅ API endpoint functionality ✅ Tool integration testing ✅ Response format validation ✅ Deployment compatibility This test suite ensures the Strands agent maintains quality and compatibility with the existing platform while providing clear validation of all functionality before deployment.
Critical Fix for Production Deployment: - Changed from StrandsLiteLLMModel to OpenAIModel from strands.models.litellm - Prevents Bedrock model name conflicts when using LiteLLM proxy - Uses client_args with api_key and base_url for proper proxy routing - Removes bedrock/ prefix from model_id to avoid naming conflicts Technical Details: - The default LiteLLM SDK has name conflicts with the proxy - OpenAIModel type is preferred when calling the actual proxy - This approach has been tested and verified to work with the platform - Updated both agent implementation and notebook examples Updated Files: - strands_agent.py: Fixed model initialization with OpenAIModel - 5_agent_frameworks.ipynb: Updated notebook example - test_strands_agent.py: Updated import validation - requirements.txt: Kept strands-agents[litellm] dependency This fix ensures the Strands agent will work correctly with the actual LiteLLM proxy URL in production deployment.
- Remove duplicate README.md from agent directory - Keep comprehensive documentation in tests/strands_agent/README.md - Clean up implementation summary files - All tests passing (logic: 3/3, runtime: 4/4, structural: 6/6) - Production-ready with complete EKS deployment configuration - Dual proxy/SDK configuration support working correctly
tannermcrae
approved these changes
Aug 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
feat: Add Strands framework example to Lab 3 notebook
feat: Implement Strands agent core functionality
feat: Add Strands agent deployment infrastructure
feat: Add comprehensive test suite for Strands agent
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.