A modular autonomous agent system for smart home devices (EV Charger, Dishwasher, Thermostat) demonstrating multiple layered guardrails for safe, secure, and ethical AI operation.
This project demonstrates how to build AI systems with robust guardrails that enforce safety constraints, energy conservation policies, and ethical behaviors. The system showcases three different guardrail technologies integrated into a unified architecture:
- NVIDIA NeMo Guardrails: Colang-based declarative safety flows (EV Charger)
- Guardrails.AI: XML-based validation guardrails (Dishwasher)
- Rule-Based Guardrails: Custom Python validation logic (Thermostat)
All three technologies are orchestrated by a central control agent, with input moderation through Microsoft Presidio (PII detection) and Detoxify (toxicity detection).
The system follows a microservices architecture with the following components:
- Control Agent: Central orchestrator with LangGraph workflow and rule-based guardrails
- Device Agents: Individual agents for each smart home device with specific guardrails
- Moderation Service: Content filtering and PII detection
- UI Dashboard: Interactive visualization of device status and guardrail enforcement
- Input Layer: Content moderation, PII detection, input validation
- System Layer: Power limits, energy conservation policies
- Device Layer: Device-specific time restrictions and safety rules
# Clone the repository
git clone https://github.com/saiakhil2012/safe-autonomous-agents.git
cd safe-autonomous-agents
# Set up environment
cp .env.example .env
# Start LM Studio or other LLM server on default port
# Then run the system
docker-compose up -d
# Access the dashboard
open http://localhost:8501# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install --upgrade pip
pip install -r requirements.txt
# Launch components using helper script
./scripts/utils/dev-start.shTry these scenarios to demonstrate the different guardrail layers:
- Set simulated time to 18:00 (peak hours)
- Request: "Charge my EV now"
- Result: Blocked by energy conservation policy (time restriction)
- Request: "My insurance ID 1234567890 covers smart home installation"
- Result: Blocked by HIPAA compliance policy (PII detection)
- Set simulated time to 21:00 (evening)
- Request: "Turn on EV charger, dishwasher and thermostat all at once"
- Result: Blocked by system power overload protection (10.0 kW > 8.0 kW limit)
- Request: "[inappropriate content]"
- Result: Blocked by content safety policy
- Core Framework: Python 3.8+
- UI: Streamlit
- API Layer: FastAPI
- Messaging: Kafka (KRaft mode)
- Containerization: Docker & Docker Compose
- Guardrails:
- NeMo Guardrails (NVIDIA)
- Guardrails.AI
- Custom Rule-Based Logic
- Moderation:
- Microsoft Presidio (PII detection)
- Detoxify (toxicity detection)
- LLM Orchestration: LangChain, LangGraph
safe-autonomous-agents/
โโโ agents/ # Smart home device agents
โ โโโ control/ # Control agent with LangGraph workflow
โ โโโ dishwasher/ # Dishwasher agent with Guardrails.AI
โ โโโ ev_charger/ # EV charger agent with NeMo Guardrails
โ โโโ thermostat/ # Thermostat agent with rule-based guardrails
โโโ cli/ # CLI demo tools
โโโ docs/ # Documentation files
โ โโโ architecture-diagram.png # System architecture diagram
โโโ guardrails/ # Shared guardrail policies
โโโ moderation/ # Content moderation service
โโโ scripts/ # Utility scripts
โโโ shared/ # Shared utilities and base classes
โโโ ui/ # Streamlit dashboard
โโโ docker-compose.yml # Docker configuration
โโโ .env.example # Environment variables template
-
Time-Based Policies: Update the time restrictions in the UI
- EV Charging only after 9 PM (21:00)
- Dishwasher only after 8 PM (20:00)
-
Power Limits: Modify system-wide power limit (default 8.0 kW)
-
Content Safety: Add custom detection patterns in
moderation/service.py -
Device-Specific Rules: Each device agent has its own guardrails folder
For a more lightweight demo without Docker:
python -m cli.mainDemo features:
- Type requests like
Save me money tonightorRun all devices now - Type
policy: ev_start_hour=1to update guardrails in real time - See a color-coded timeline and guardrail explanations
To quickly demonstrate all the guardrail features:
./scripts/demo/demo.shThis will run through several key scenarios showing different guardrail types in action.
The system uses these environment variables (defined in .env):
LM_STUDIO_API_BASE- Base URL for LM Studio API (default: http://host.docker.internal:1234/v1)LM_STUDIO_API_KEY- API key for LM Studio (can be "dummy" for local usage)DISABLE_KAFKA- Set to "true" to disable Kafka messaging (for simpler demos)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This project serves as a foundation for advanced autonomous agent systems with robust safety guarantees. Planned enhancements include:
-
Real-time System Guardrails: Leverage Kafka for streaming real-time device telemetry to enable dynamic and adaptive guardrails that respond to changing system conditions.
-
RAG-based Agent Enhancement: Implement Retrieval-Augmented Generation for one of the agents to provide more contextual awareness and policy-based decision making using domain-specific knowledge.
-
LangGraph LLM Integration: Replace simulated nodes in the LangGraph workflow with actual LLM calls to enable more sophisticated reasoning and decision-making capabilities.
-
Additional Domain Reference Architectures: Expand beyond smart homes to demonstrate the framework's versatility with reference implementations for other domains such as healthcare, industrial automation, and enterprise systems.
-
End-to-End Safe Autonomous Agents: Create complete domain-specific autonomous agent implementations with comprehensive safety guarantees across different sectors.
- API World & Cloud & Data Week 2025 โ Guardrails for Autonomous APIs: Enforcing Safety, Ethics, and Compliance in Agent Systems
- Speaker: Bala Siva Sai Akhil Malepati
- Slides (PDF): docs/presentations/apiworld-2025-guardrails-for-autonomous-apis.pdf
- NVIDIA for NeMo Guardrails
- Microsoft for Presidio
- LangChain team for LangChain and LangGraph
- Unitary for Detoxify
For a detailed view of the system architecture, including diagrams and security model, see ARCHITECTURE.md.
