AEGIS Project Story (Condensed) Inspiration Traditional safety monitoring systems are blind to context—they see but don't understand. Reading about preventable surgical errors and manufacturing accidents, I realized most incidents weren't from negligence but subtle protocol deviations that rule-based systems missed.
When Gemini 2.0's 2M token context window was announced, the solution became clear: build an AI safety auditor that actually comprehends what's happening by loading entire regulatory frameworks directly into context. No RAG needed, just pure understanding.
What it does AEGIS monitors high-stakes operations in real-time and prevents disasters through:
Real-time violation detection via WebSocket streaming Context-aware analysis using Gemini's 2M token window loaded with regulatory docs Proactive tool execution - automatically logs deviations and searches protocols Severity classification (LOW/MEDIUM/HIGH/CRITICAL) Instant alerts with actionable recommendations Demo: Type "unsafe instrument detected" → AEGIS analyzes severity, logs to database, provides recommendations—all in milliseconds.
How we built it Tech Stack: Django + Channels + Gemini 2.0 Flash Exp + WebSockets
Architecture (Sentinel Framework):
Massive Context Grounding - 2M token regulatory knowledge base Stateful Reasoning - Thought signatures track analysis chains Real-Time Feedback - WebSocket bidirectional streaming Operational Analytics - Auto-logging with severity ratings Key Components:
GeminiClient
- API wrapper with function calling AuditorOrchestrator
- Manages state and tool execution WebSocket consumer - Async real-time communication Cyberpunk dashboard - Live decision log with thought signatures Challenges we ran into Function call parsing - Gemini responses with function calls crashed when accessing .text. Fixed with defensive parsing checking function_call attribute first. Async/sync mixing - Django ORM is sync, WebSockets are async. Solved with careful sync_to_async wrappers. Inconsistent tool calling - Enhanced system instruction with explicit guidance: "Use tools proactively... Lives may depend on your analysis." Dramatically improved behavior. WebSocket stability - Django auto-reloader killed connections. Added reconnection logic and status indicators. Accomplishments that we're proud of ✅ Working real-time AI safety system with WebSocket streaming in under a week ✅ Full Sentinel Architecture implementation with all four pillars ✅ Proactive tool execution - Gemini logs violations automatically ✅ Zero-latency alerts - millisecond response times ✅ Production-ready Django Channels + ASGI architecture ✅ Clean hackathon codebase - no comments, single README, secure
What we learned Context windows change everything - With 2M tokens, skip RAG and load docs directly. Faster, more accurate, simpler.
Function calling needs detailed prompts - Treat declarations as part of the prompt, not just API config.
WebSockets + AI = magic - Real-time streaming creates fundamentally better UX than polling.
Thought signatures enable statefulness - Track reasoning chains across turns for coherent analysis.
Django Channels async patterns - Every ORM call needs sync_to_async or the event loop blocks.
What's next for AEGIS Near-term:
Real camera/microphone integration for live video analysis Context caching to reduce API costs Multi-stream monitoring for simultaneous operations Enhanced knowledge vault with actual document ingestion Advanced:
BigQuery time-series analytics for predictive alerts Mobile app with push notifications Custom fine-tuning on safety incident data Multi-agent orchestration for specialized domains Enterprise:
PostgreSQL + Redis for horizontal scaling OAuth2 authentication Immutable audit trails for compliance REST API for third-party integrations AEGIS proves that with Gemini's capabilities, we can build AI that doesn't just observe—it understands, reasons, and protects.
Built With
- channels==4.2.0
- daphne==4.1.2
- django==5.0.6
- djangorestframework==3.16.1
- google-generativeai==0.8.3
- python-dotenv==1.0.1
Log in or sign up for Devpost to join the conversation.