Drug Interaction Agent
A medication-label review app that brings source passages and coverage gaps into one view, with a separate RAG chatbot for research.
Choose medications, inspect every pair, and follow the evidence back to its label. The interface distinguishes direct label mentions, shared ingredients, and incomplete source coverage.
Keep deterministic label review separate from generated explanations. A missing mention is displayed as a coverage result, never as proof that a combination is safe.
From medication list to source evidence
- Normalize the namesRxNorm terminology connects names with medication concepts.
- Retrieve matching labelsDailyMed label sampling checks active ingredients and retains source references.
- Inspect each pairShow label mentions, ingredient overlap, and missing coverage in a review matrix.
23,651 searchable terminology entries include brands and ingredient concepts; they are not 23,651 clinically validated medications. Pairwise review does not model higher-order interactions.
- Stateful LangGraph agent: resolves medications to RxNorm, retrieves label evidence per pair, and runs proposer → critic → judge review with self-correction. High-risk or unverifiable cases pause for a pharmacist at a checkpointed human-in-the-loop step and resume where they stopped; an n8n workflow routes each escalation ticket to an urgent or routine pharmacist queue.
- Trajectory evaluation: 127 scenarios (tool faults, prompt injection, misspellings, patient memory) scored on the path, not just the answer. Against a single pass, the critic loop fixed 4 failures and broke none, raised escalation recall to 0.88, and released no ungrounded findings; plain rules still scored highest on task success, which is why the safety checks stay deterministic.
- Memory, context and MCP: SQLite patient memory, evidence filtering plus a token-budgeted context builder that cut prompt evidence 79% versus top-k retrieval (filtering does most of it; compression mainly buys speed), and an MCP server exposing the agent's tools.
- Hybrid retrieval: BM25 + dense search with rank fusion and a cross-encoder reranker lifted MRR 25% at the deployed rerank depth (0.496 → 0.619; 0.652 at full depth) on a 600-query benchmark over 1,011 FDA label passages.
- Load-tested: Prometheus stage metrics exposed the reranker as the bottleneck; retuning cut p95 latency 84% (7.4 → 1.2 s) and raised throughput 4.9× under Locust.
- Model gateway: OpenAI-compatible routing to a self-hosted Llama 3.2 with API fallback and a circuit breaker; an outage drill kept every request served.
- Deployable: Kubernetes manifests (probes, HPA) and Terraform for AWS EKS with a GPU pool for vLLM, validated in CI; OpenTelemetry tracing and a Grafana dashboard.
Research and source-review tool, not a clinically validated interaction checker. It does not establish patient-specific safety or recommend changes to medication.
Architecture, evaluation, and scope
The public label-review path uses terminology matching and label text without an LLM or a generated severity score. Label sampling can miss relevant evidence, and a direct name mention may include a negated statement. Users must read the source passage.
The separate research chatbot combines retrieval and classification stages with an LLM explanation on the ordinary uncached API path. The classifier module uses isotonic calibration with three-fold cross-validation. Content-keyed caching returned a repeat query in 0.25 ms versus 5.8 s uncached on the hosted deployment (one-request smoke check).
On the authored 24-pair regression set, the evaluated path scored 24/24 severity accuracy, 97.9% management coverage and 91.7% citation accuracy. It excludes the final LLM explanation and is not a clinical validation. The expanded app also has 41 integration tests and six static-demo tests; those check software behavior, not medical accuracy.