feat: AI Support Triage Agent — BM25 RAG + Deterministic Safety Gate + Multi-Provider Cascade#35
Open
HarshavardhanVemali wants to merge 11 commits into
Open
feat: AI Support Triage Agent — BM25 RAG + Deterministic Safety Gate + Multi-Provider Cascade#35HarshavardhanVemali wants to merge 11 commits into
HarshavardhanVemali wants to merge 11 commits into
Conversation
…-Provider Cascade, API Rotator)
…, updated metrics charts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR delivers a terminal-based AI support triage agent for the HackerRank Orchestrate 2026 challenge. The system processes support tickets across three domains — HackerRank, Claude AI, and Visa — using a local BM25 corpus, a deterministic safety engine, and a multi-provider LLM cascade.
Final evaluation results:
All responses are grounded exclusively in the pre-built local corpus (
data/hackerrank,data/claude,data/visa). No live web requests are made during evaluation.Architecture
Key Components
1. Corpus Loader & BM25 Retrieval (
corpus/loader.py)The corpus is pre-built by scraping the three support sites offline. During evaluation, only the local
data/directory is used, no network calls..md,.json, and.txtcorpus files recursively.BM25Okapiindex in RAM at startup (~770 documents total).search()supports domain filtering and Intent Boosting (multiplying priority terms like "refund" or "mock" by 100x).unknown, infers the domain by majority vote over the top-5 retrieved documents.Design decision: BM25 was chosen over vector embeddings because the support corpus is keyword-heavy (technical terms, product names, URLs), retrieval is lightning fast (sub-5ms), and there is zero additional API cost.
2. Classifier (
agent/classifier.py)Zero-shot classification using the Gemini API with JSON mode enforced.
domain,request_type,product_area,confidence.response_mime_type: application/json.Classification(domain="unknown", confidence=0.0)on any API error, safely triggering escalation.3. Safety Gate (
agent/safety.py)Deterministic rule engine that runs before any LLM response generation. No API calls. First-match-wins ordered rules:
Catching English and French prompt injections was a deliberate design choice via strict regex patterns to prevent LLM manipulation.
4. Responder (
agent/responder.py)Generates corpus-grounded replies using the multi-provider cascade.
System prompt enforces strict grounding:
Post-generation PII & Hallucination check: Flags responses containing emails or phone numbers that do not lexically overlap with the retrieved corpus. Blocks unverified PII leaks to enforce strict data privacy.
5. Multi-Provider LLM Cascade & API Rotator (
utils/model_provider.py&utils/api_rotator.py)Three-tier cascade with automatic failover to handle extreme loads and prevent pipeline crashing:
GeminiRotatoris a thread-safe singleton that round-robins across multiple API keys loaded from the environment. Usesthreading.Lockfor safe concurrent access.6. Parallel Orchestration (
main.py)ThreadPoolExecutor(max_workers=8)for concurrent ticket processing.ticket_idfor deterministic, evaluable ordering.Design Decisions & Honest Tradeoffs
Files Changed
Environment Variables Required
See
code/.env.examplefor the required injection template: