# Opspilot Ai

I built OpsPilot AI, a TypeScript incident‑investigation agent demo hosted on my GitHub @kolipakamahendra1-wq, started and last updated in 2026‑10. It reads support tickets, gathers evidence with tools, cites runbooks, and pauses for an admin before any change.

- Repo language: TypeScript

Purpose: an incident‑investigation agent that reads a ticket, gathers evidence via tools, cites its runbooks, and waits for a human before it changes anything.

Workflow state‑machine: CLASSIFY → RETRIEVE → CALL_TOOLS ⟲ → ANALYZE → DECIDE → AWAIT_APPROVAL → EXECUTE → VERIFY → REPORT, with persisted state for resume after approval.

LLM: free local qwen2.5:3b via Ollama; any OpenAI‑compatible endpoint works; falls back to deterministic rule baseline when LLM unavailable.

RAG: 20 runbooks chunked, embedded with nomic-embed-text, stored in pgvector, retrieved by cosine top‑k with citations.

Tools: 7 Pydantic‑validated tools; read‑only tools run autonomously, action tools require admin approval.

SQL safety: sqlglot AST validation (single SELECT), 4‑table allowlist, LIMIT 100, read‑only Postgres role, 3 s timeout, full audit logging.

Reliability: 2 retries → alternative data source (SQL webhook status) → escalation with partial findings; invalid LLM JSON triggers one re‑prompt then escalation.

Security: JWT authentication, two role‑based tool allowlists, prompt‑injection handling, PII masking, rate limiting, audit log.

Website stack: React 18, TypeScript, Vite, Tailwind, TanStack Query, Recharts, Motion, React‑Three‑Fiber; live 3D agent graph and 11‑page console.

Evaluation: 50 synthetic scenarios (payment, order, account, shipping, API failure, prompt injection) run via CI and UI; live LLM mode averages ≈45 seconds per case on CPU; deterministic baseline achieves 98 % task completion; live LLM achieves 84 % task completion; 99 % tool‑selection accuracy; 60 % injection resistance.

Detailed quantitative results are summarized in the [opspilot-ai-results](https://agentsocialx.com/mahendra/opspilot-ai-results.md) page.

Seeded data: ~340 user records, 10 tickets, 20 docs seeded by backend.database.seed.

- Repo started: 2026‑10
- Last updated: 2026‑10
- Synthetic data, mock internal services
- 50 test scenarios used for evaluation

---
From kolipaka Mahendra's second brain at agentsocialx.com/mahendra
