A hybrid deterministic + LLM-powered incident analysis system designed to improve incident triage reliability while reducing hallucination risk in production environments.
This system combines:
- Deterministic log parsing
- Structured metrics extraction
- Constrained LLM reasoning
- Strict schema validation (Pydantic)
The goal is to balance reliability with contextual intelligence.
- JSON-only output instruction
- Pydantic schema validation before rendering
- Low temperature (0.2) for reduced variability
- Controlled log truncation to manage context size
- Output rejection on validation failure
2024-01-15 09:13:22 ERROR Failed to acquire database connection from
pool
2024-01-15 09:13:24 ERROR Timeout while waiting for database connection
2024-01-15 09:13:50 ERROR Service degraded: high response latency
detected
2024-03-02 14:05:15 WARN High memory usage detected: 85%
2024-03-02 14:15:44 WARN High memory usage detected: 92%
2024-03-02 14:18:30 ERROR Process killed due to OutOfMemory
2024-03-02 14:18:31 ERROR Container restarted automatically
This service requires an OpenAI API key.
Copy the example file:
.env.example → .env
Inside .env:
OPENAI_API_KEY=your_openai_api_key_here
- The
.envfile is excluded from version control. - API keys must never be committed to the repository.
- In production environments, environment variables should be injected
via:
- Cloud secret manager
- CI/CD pipeline secrets
- Container environment configuration
Environment variables are loaded using python-dotenv.
Install dependencies:
pip install -r requirements.txt
Start the server:
uvicorn app.main:app --reload
Open:
- Malformed JSON from LLM
- Missing structured fields
- Overconfident confidence scoring
- Truncated context hiding deeper root causes
- Increased inference latency
- Logs are truncated to control token usage
- Deterministic preprocessing reduces prompt size
- Low temperature reduces retry frequency
- Future improvement: hash-based caching layer
- FastAPI
- Async OpenAI SDK
- Pydantic
- Jinja2
- Python 3.10+
This project demonstrates:
- Applied LLM system design
- Guardrailed AI integration
- Structured output enforcement
- Reliability-focused AI engineering
- Cost-aware prompt orchestration


