Command Line Interface for isA Agent API
Project description
isA Agent - Smart Agent Service
A production-ready, modular agent service built with LangGraph for intelligent conversation workflows, MCP tool integration, and comprehensive streaming capabilities.
๐ฏ Features
- ๐ค Smart Agent Architecture: LangGraph-based agent with reasoning, tool execution, and response nodes
- ๐ Real-Time Streaming: Server-Sent Events (SSE) streaming with comprehensive event types
- ๐ง MCP Integration: Full Model Context Protocol support for tool discovery and execution
- ๐ง Multi-Model Support: Flexible model integration via ISA Model service
- ๐ Durable Execution: PostgreSQL-backed conversation persistence and checkpointing
- ๐ Production Ready: API-first design with authentication, rate limiting, and health monitoring
- ๐ณ Docker Support: Optimized Docker images (API mode: ~400MB, Local mode: ~3GB)
- ๐ Service Discovery: Consul integration for automatic service registration
- ๐จ Multiple Graph Types: Specialized graphs for research, coding, and conversation workflows
- ๐ Hardware Integration: Support for IoT devices and sensor data processing
- ๐ฅ Human-in-Loop: Interactive approval and feedback system for critical decisions
- ๐ Advanced Tracing: Comprehensive tracing with LangSmith integration
- ๐ณ Billing Integration: Usage tracking and billing service support
- ๐๏ธ SDK Support: Client SDK for easy integration
๐๏ธ Architecture
isA_Agent/
โโโ app/ # Core application
โ โโโ api/ # API endpoints
โ โ โโโ auth/ # Authentication
โ โ โโโ chat.py # Chat endpoints
โ โ โโโ session.py # Session management
โ โ โโโ execution.py # Execution control
โ โ โโโ tracing.py # Tracing & observability
โ โ โโโ graphs.py # Graph management API
โ โโโ components/ # Service components
โ โ โโโ mcp_service.py # MCP integration
โ โ โโโ billing_service.py # Billing & usage
โ โ โโโ user_service.py # User management
โ โ โโโ consul_discovery.py # Service discovery client
โ โโโ graphs/ # LangGraph workflows
โ โ โโโ smart_agent_graph.py # Main agent graph
โ โ โโโ graph_config_service.py # Graph configuration
โ โ โโโ graph_registry_with_auth.py # Graph registry with permissions
โ โ โโโ base_graph.py # Base graph implementation
โ โ โโโ research_graph.py # Research-focused workflow
โ โ โโโ coding_graph.py # Code generation workflow
โ โ โโโ conversation_graph.py # Simple conversation workflow
โ โโโ nodes/ # Agent nodes
โ โ โโโ reason_node.py # Reasoning logic
โ โ โโโ tool_node.py # Tool execution
โ โ โโโ response_node.py # Response generation
โ โโโ services/ # Business logic
โ โ โโโ chat_service.py # Chat orchestration
โ โ โโโ hil_service.py # Human-in-loop
โ โ โโโ tracing_service.py # Tracing & metrics
โ โ โโโ hardware_service.py # Hardware device integration
โ โ โโโ durable_service.py # Durable execution service
โ โโโ core/ # Core utilities
โ โ โโโ config/ # Configuration
โ โ โโโ resilience/ # Circuit breakers, rate limiting
โ โโโ sdk/ # Client SDK
โ โโโ types/ # Type definitions
โ โโโ response_models.py # Response type definitions
โ โโโ hardware_types.py # Hardware device types
โโโ deployment/ # Deployment configurations
โ โโโ dev/ # Development environment
โ โโโ test/ # Testing environment
โ โโโ staging/ # Staging environment
โ โโโ production/ # Production environment
โ โโโ scripts/ # Deployment scripts
โ โ โโโ start_agent_service.sh # Service starter
โ โ โโโ docker_build.sh # Docker build script
โ โ โโโ register_consul.py # Consul registration
โ โโโ Dockerfile.agent # Production Dockerfile
โ โโโ README.md # Deployment guide
โโโ main.py # Entry point
๐ Quick Start
Development Mode
# Install dependencies with UV (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
source .venv/bin/activate
# Start development server
./deployment/scripts/start_agent_service.sh -e dev start
# Or manually
uv pip install -r deployment/dev/requirements.txt
uvicorn main:app --reload --port 8080
Docker Deployment
# Build lightweight API mode image (~400MB)
./deployment/scripts/docker_build.sh -m api -t isa-agent:v1.0.0
# Build local mode with embedded model (~3GB)
./deployment/scripts/docker_build.sh -m local -e cloud -t isa-agent:local
# Run container
docker run -p 8080:8080 \
-e ISA_MODE=api \
-e ISA_API_URL=http://model-service:8082 \
-e MCP_SERVER_URL=http://mcp-service:8081 \
isa-agent:v1.0.0
Environment Configuration
Copy the example environment file:
cp deployment/env.example deployment/dev/.env
Key configurations:
# ISA Model Configuration
ISA_MODE=api # api (connects to external service) or local (embedded model)
ISA_API_URL=http://localhost:8082 # ISA Model service URL (when ISA_MODE=api)
# MCP Server Configuration
MCP_SERVER_URL=http://localhost:8081 # MCP server URL
# API Server
API_HOST=0.0.0.0
API_PORT=8080
# Consul Service Discovery
CONSUL_HOST=localhost
CONSUL_PORT=8500
SERVICE_NAME=agents
๐ API Usage
Health Check
curl http://localhost:8080/health
Send Message (Streaming)
curl -N http://localhost:8080/api/v1/agents/chat/stream \
-H "Content-Type: application/json" \
-d '{
"message": "What is the weather in San Francisco?",
"user_id": "user123"
}'
Send Message (Non-Streaming)
curl -X POST http://localhost:8080/api/v1/agents/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Hello!",
"user_id": "user123",
"thread_id": null
}'
Graph Management
# List available graphs for user
curl http://localhost:8080/api/v1/graphs/available/user123
# Select a specific graph
curl -X POST http://localhost:8080/api/v1/graphs/select \
-H "Content-Type: application/json" \
-d '{
"user_id": "user123",
"graph_type": "research"
}'
# Auto-select graph based on task
curl -X POST http://localhost:8080/api/v1/graphs/auto-select \
-H "Content-Type: application/json" \
-d '{
"user_id": "user123",
"task_description": "Help me research quantum computing"
}'
Human-in-Loop Interaction
# Get pending approvals
curl http://localhost:8080/api/v1/execution/pending/user123
# Approve/reject an action
curl -X POST http://localhost:8080/api/v1/execution/approve \
-H "Content-Type: application/json" \
-d '{
"thread_id": "thread123",
"approved": true
}'
Interactive API Documentation
Visit http://localhost:8080/docs for Swagger UI
๐ง Core Components
Smart Agent Graph
The agent uses a LangGraph workflow with the following nodes:
- Reason Node: Analyzes user input and determines actions
- Tool Node: Executes MCP tools and external function calls
- Response Node: Generates final responses
- Failsafe Node: Handles errors and edge cases
- Guardrail Node: Safety checks and content filtering
Specialized Graph Types
Research Graph
- Optimized for deep research and information gathering
- Enhanced search capabilities and source tracking
- Multi-step reasoning for complex queries
Coding Graph
- Specialized for code generation and debugging
- Integration with development tools
- Code review and optimization features
Conversation Graph
- Simple, fast conversational interface
- No tool execution for basic chat
- Optimized for low-latency responses
ISA Modes
API Mode (Recommended for Production)
- Connects to external ISA Model service
- Lightweight deployment (~400MB Docker image)
- Scalable and flexible
Local Mode
- Embedded ISA Model with
[cloud]or[all]extras - Standalone deployment (~3-8GB Docker image)
- No external model service required
MCP Integration
- Automatic tool discovery from MCP servers
- Dynamic tool binding to LangGraph agent
- Support for multiple MCP servers
- Health monitoring and circuit breakers
- Composio tool integration support
Hardware Integration
- Support for IoT device contexts
- Sensor data processing and automation
- Device command execution
- Real-time device status monitoring
๐ณ Docker Images
Build Options
# API mode (lightweight)
docker build -f deployment/Dockerfile.agent \
--build-arg ISA_MODE=api \
-t isa-agent:api .
# Local mode with cloud extras
docker build -f deployment/Dockerfile.agent \
--build-arg ISA_MODE=local \
--build-arg ISA_MODEL_EXTRAS=cloud \
-t isa-agent:local-cloud .
# Local mode with all extras
docker build -f deployment/Dockerfile.agent \
--build-arg ISA_MODE=local \
--build-arg ISA_MODEL_EXTRAS=all \
-t isa-agent:local-full .
Image Sizes
- API mode: ~400MB (base + agent dependencies)
- Local mode [cloud]: ~3GB (includes lightweight ML)
- Local mode [all]: ~8GB (includes full ML stack)
๐ Service Discovery
The agent service automatically registers with Consul when available:
# Check service registration
curl http://localhost:8500/v1/health/service/agents?passing=true
# Service tags
- sse # Server-Sent Events support
- agent # Smart Agent service
- ai # AI service
- streaming # Streaming responses
- chat # Chat functionality
๐งช Testing
Run Tests
# All tests
pytest
# Specific test file
pytest tests/test_chat_service.py
# With coverage
pytest --cov=app tests/
Manual Testing
# Test streaming endpoint
curl -N http://localhost:8080/api/v1/agents/chat/stream \
-H "Content-Type: application/json" \
-d '{"message": "Hello!", "user_id": "test"}'
# Test session management
curl http://localhost:8080/api/v1/agents/sessions?user_id=test
๐ Monitoring & Observability
Metrics Endpoints
/health- Service health check/api/v1/agents/stats- Agent statistics/api/v1/agents/sessions- Active sessions/api/v1/graphs/stats- Graph usage statistics/api/v1/tracing/active- Active traces
Tracing
- LangSmith integration for execution tracing
- Structured logging with configurable levels
- Circuit breaker metrics
- Request/response correlation tracking
- Performance metrics per graph type
Loki Integration (Optional)
LOKI_URL=http://localhost:3100
LOKI_ENABLED=true
๐ Security Features
- API Key Authentication: Master key and user-specific keys
- Rate Limiting: Per-user request limits
- Circuit Breakers: Automatic failure protection
- Connection Limiting: Resource protection
- Input Validation: Pydantic-based validation
- Graph Access Control: Permission-based graph access
- Human-in-Loop: Manual approval for sensitive operations
- Audit Logging: Comprehensive action tracking
๐ข Deployment
Development
./deployment/scripts/start_agent_service.sh -e dev start
Production
# Using Docker
docker run -d \
--name isa-agent \
-p 8080:8080 \
--env-file deployment/production/.env.production \
isa-agent:v1.0.0
# Using deployment script
./deployment/scripts/start_agent_service.sh -e production start
Scaling
- Deploy multiple instances behind a load balancer
- Use external PostgreSQL for shared state
- Connect all instances to the same Consul cluster
๐ Configuration
See deployment/env.example for all available configuration options.
Environment-Specific Configs
deployment/dev/.env- Developmentdeployment/test/.env.test- Testingdeployment/staging/.env.staging- Stagingdeployment/production/.env.production- Production
๐ Troubleshooting
Service Won't Start
- Check if ports are available:
lsof -i :8080 - Verify environment variables:
./deployment/scripts/start_agent_service.sh -e dev status - Check logs:
tail -f logs/app.log
MCP Connection Issues
- Verify MCP server is running:
curl http://localhost:8081/health - Check MCP_SERVER_URL configuration
- Review circuit breaker status at
/healthendpoint
Docker Build Issues
- Ensure Docker is running:
docker info - Clean build cache:
docker builder prune - Use
--no-cacheflag for clean build
๐ License
[Your License Here]
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
isA Agent - Production-ready AI agent service ๐
๐ป CLI Interface
Installation
pip install -e .
Available Commands
After installation, you can use:
isa-chat- Primary CLI commandisa-agent- Alternative commandisachat- Short version
Quick CLI Usage
# Check API health
isa-chat --health
# Interactive chat
isa-chat
# Single message
isa-chat "Hello, what can you help me with?"
# Synchronous mode
isa-chat --sync "What is 2+2?"
# Custom API endpoint
isa-chat --api-url "https://api.example.com" --api-key "your-key" "Hello"
Quick Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file isa_agent_cli-1.0.0.tar.gz.
File metadata
- Download URL: isa_agent_cli-1.0.0.tar.gz
- Upload date:
- Size: 227.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31344f90170ac0dd54c80c975261bd692df689f9a56104bcf1007c7db7a0a576
|
|
| MD5 |
e677183af6eb0c113bdd4c65c697c3f3
|
|
| BLAKE2b-256 |
0f759672d76ee07d5d513035c2cff9312c2dfdd4ba8926be4265dac3996c8955
|
File details
Details for the file isa_agent_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: isa_agent_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 258.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d3f87161417f67b8bca3c4d42c752f085e60e5a93a9d310260f6d3dfa383f9b
|
|
| MD5 |
cecb044279eb3c433585511a7c806e51
|
|
| BLAKE2b-256 |
b3b97f88a0f1ef271909c149d63b6549eafd4205c2568193166a504bf5375b76
|