Skip to main content

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 - Development
  • deployment/test/.env.test - Testing
  • deployment/staging/.env.staging - Staging
  • deployment/production/.env.production - Production

๐Ÿ› Troubleshooting

Service Won't Start

  1. Check if ports are available: lsof -i :8080
  2. Verify environment variables: ./deployment/scripts/start_agent_service.sh -e dev status
  3. Check logs: tail -f logs/app.log

MCP Connection Issues

  1. Verify MCP server is running: curl http://localhost:8081/health
  2. Check MCP_SERVER_URL configuration
  3. Review circuit breaker status at /health endpoint

Docker Build Issues

  1. Ensure Docker is running: docker info
  2. Clean build cache: docker builder prune
  3. Use --no-cache flag for clean build

๐Ÿ“„ License

[Your License Here]

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. 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 command
  • isa-agent - Alternative command
  • isachat - 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isa_agent_cli-1.0.0.tar.gz (227.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

isa_agent_cli-1.0.0-py3-none-any.whl (258.1 kB view details)

Uploaded Python 3

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

Hashes for isa_agent_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 31344f90170ac0dd54c80c975261bd692df689f9a56104bcf1007c7db7a0a576
MD5 e677183af6eb0c113bdd4c65c697c3f3
BLAKE2b-256 0f759672d76ee07d5d513035c2cff9312c2dfdd4ba8926be4265dac3996c8955

See more details on using hashes here.

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

Hashes for isa_agent_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d3f87161417f67b8bca3c4d42c752f085e60e5a93a9d310260f6d3dfa383f9b
MD5 cecb044279eb3c433585511a7c806e51
BLAKE2b-256 b3b97f88a0f1ef271909c149d63b6549eafd4205c2568193166a504bf5375b76

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page