This is a fully functional, working example that demonstrates practical implementation patterns from 00_IMPLEMENTATION_PATTERNS.md.
What This Demonstrates:
- ✅ RESTful API architecture (no external AI libraries)
- ✅ In-memory caching (simplified)
- ✅ Problem analysis workflow
- ✅ Health checks and metrics
- ✅ Production-ready structure
Note: This is a simplified demo version. For production with LangChain integration, see implementation patterns.
# Docker (recommended)
docker-compose up
# Local testing (optional)
python3 -m pip install http.server
# No external dependencies required!# Option 1: Docker (recommended)
docker-compose up
# Option 2: Local development
python3 examples/simple-agent-system/agents/simple_agent.pyThe agent will start on http://localhost:8000
curl http://localhost:8000/healthExpected response:
{
"status": "healthy",
"agent_type": "simple-agent",
"version": "1.0.0",
"redis": "connected"
}curl -X POST http://localhost:8000/analyze \
-H "Content-Type: application/json" \
-d '{"problem": "How do I design a scalable microservices architecture?"}'Expected response:
{
"problem": "How do I design a scalable microservices architecture?",
"composition": [
"How do I design a scalable microservices architecture?"
],
"components_identified": 1,
"logical_analysis": [
{
"component": 1,
"text": "How do I design a scalable microservices architecture?",
"complexity": "medium",
"type": "question",
"key_terms": ["architecture", "design", "scalable", "microservices"]
}
],
"conclusions": [
"Problem decomposed into 1 components",
"Identified 0 high-complexity components"
],
"recommendations": [
"Analyze each component independently",
"Consider edge cases and error handling",
"Validate assumptions with testing",
"Document analysis process for reproducibility"
],
"confidence": 90.0
}curl http://localhost:8000/statusExpected response:
{
"agent_type": "simple-agent",
"total_analysis_performed": 1,
"cache_size": 1,
"status": "operational",
"dependencies": {
"redis": "localhost:6379",
"connected": true
}
}Root endpoint with API documentation
Response:
{
"service": "Simple Agent Demo",
"version": "1.0.0",
"endpoints": {
"GET /health": "Health check",
"GET /status": "Agent status and metrics",
"POST /analyze": "Analyze problem systematically"
"GET /": "API documentation"
},
"note": "Simplified demo version - see 00_IMPLEMENTATION_PATTERNS.md for production LangChain integration"
}Analyze a problem systematically.
Request Body:
{
"problem": "Your problem here"
}Response (full analysis structure):
problem- The problem textcomposition- Array of sentences from problem decompositioncomponents_identified- Number of components identifiedlogical_analysis- Array of component analyses with:component- Component numbertext- Component textcomplexity- low/medium/hightype- question/statement/imperative/declarativekey_terms- Technical terms identified
conclusions- Summary of findingsrecommendations- Actionable next stepsconfidence- Confidence score (80-95 for structured analysis)
Health check endpoint.
Response:
{
"status": "healthy",
"agent_type": "simple-agent",
"version": "1.0.0",
"redis": "connected",
"cache": "in-memory"
}Get current agent status and metrics.
Response:
{
"agent_type": "simple-agent",
"total_analysis_performed": <count>,
"cache_size": <number_of_cached_analyses>,
"status": "operational",
"dependencies": {
"redis": "<host>:<port>",
"connected": true/false
}
} ┌─────────────────────────────┐
│ SIMPLE AGENT SYSTEM │
├─────────────────────────────┤
│ │
┌─────────┐ │ ┌─────────────────┐ │
│ Client │ │ │ HTTP Server │ │
│ (curl) │ │ │ (Python) │ │
└─────────┘ │ └─────────────────┘ │
│ │
▼ ▼
│ ┌─────────────────┐ │
│ │ Agent Handler │ │
│ │ (Simple Logic) │ │
│ └─────────────────┘ │
│ │
▼ ▼
┌───────────────────────────────┐ │
│ In-Memory Cache │ │
│ (Python dict) │ │
└───────────────────────────────┘ │
│ │
Key Features:
- ✅ No external dependencies (works with Python 3.11+)
- ✅ In-memory caching with 5-minute TTL
- ✅ JSON API with proper error handling
- ✅ Systematic problem decomposition
- ✅ Health checks for monitoring
- ✅ Metrics endpoint for observability
This example demonstrates patterns from 00_IMPLEMENTATION_PATTERNS.md:
- Implemented: RESTful API with single agent
- Pattern Reference: See "Agent Architecture" section
- Not Implemented: No message broker in this demo
- Pattern Reference: See "Mycorrhizal Communication" section
- Implemented: In-memory cache (simplified version of Redis)
- Pattern Reference: See "Distributed State Management" section
- Implemented: Health checks and status endpoint
- Pattern Reference: See "Observability & Monitoring" section
- Implemented: Docker Compose with multi-service architecture
- Pattern Reference: See "Deployment & Scaling" section
To move from this demo to production implementation:
-
Add External AI Integration
- Integrate LangChain with Claude/GPT APIs
- Implement actual reasoning chains
- Add agent configuration management
-
Add Message Broker
- Integrate RabbitMQ or NATS
- Implement Celery workers
- Add distributed task queue
-
Add Persistent State
- Replace in-memory cache with Redis
- Add database layer for long-term storage
- Implement state backup and recovery
-
Add Comprehensive Testing
- Unit tests with pytest
- Integration tests
- Load testing with locust
- CI/CD pipeline with GitHub Actions
-
Add Advanced Monitoring
- Prometheus metrics collection
- Grafana dashboards
- OpenTelemetry tracing
- Distributed tracing with Jaeger
# Check if port is in use
netstat -tulnp | grep 8000
# Kill process if needed
pkill -f simple_agent
# Try starting again
python3 examples/simple-agent-system/agents/simple_agent.py# Check if Redis is running
docker-compose ps redis
# Check Redis logs
docker-compose logs redis
# Restart services
docker-compose restart redisMIT License - Feel free to use and modify for learning purposes.
- 00_IMPLEMENTATION_PATTERNS.md - Production patterns with real tools
- 00_CONCEPTUAL_FRAMEWORKS.md - Theoretical models
- 000_foundations/UPGRADE_COMPLETE.md - Full upgrade summary