Skip to content
· Afraz Khan

Case study: one conversational API over four clinical AI agents

A healthcare product (OphyCare) had grown a pile of scattered, single-purpose endpoints: one for clinical notes, one for insurance eligibility, one for record lookups, another for routing. Clinicians had to know which tool did what. We replaced that with a single conversational API. Here is how.

The challenge

Let a clinician type a natural-language request and have the system do the right thing, whether that meant drafting a note, checking insurance eligibility, retrieving prior-visit data, or optimizing a route, without exposing the underlying tangle of services, and without the wrong answers that make clinicians distrust AI.

What we built

A LangGraph ReAct Master Orchestrator over GPT-4o that routes each request to one of four specialized sub-agents:

  • clinical notes (structured visit notes from transcripts and templates)
  • insurance eligibility (real-time coverage checks)
  • medical-records RAG (grounded Q&A over current and historical appointments)
  • route optimization

Each agent is small, testable and owns one job. The orchestrator decides who handles what.

Under the hood

  • RAG with a strict citation contract. The medical-records agent runs on PostgreSQL/pgvector with a config-driven ingestion pipeline. A strict citation contract means it answers only from grounded records and eliminated “not available” hallucinations on existing prior-visit data.
  • Real insurance eligibility. An end-to-end X12 270/271 pipeline in Python: a wire-format-identical EDI request builder, a full 271 parser, and a clearinghouse client with tenant-scoped AES-256-GCM credential decryption, verifying coverage in real time.
  • Persistent memory. LangGraph’s AsyncPostgresSaver with a thread-per-user model gives each clinician conversation memory that survives restarts and scales horizontally.
  • Production hardening. We refactored a 770-line monolithic service into seven single-responsibility modules behind a ~150-line API (an 80% reduction, zero contract changes), and stood up observability (structlog, Langfuse, LangSmith) and CI/CD via GitHub Actions, Docker and AWS.

The results

  • Four specialized agents unified into one conversational API.
  • Zero citation hallucinations on existing prior-visit data, thanks to the citation contract.
  • 80% code reduction in the autofill refactor, with no contract changes.

What made it work

  • Multi-agent only where it earned its place. One request genuinely spanned four distinct jobs; a single prompt would have been brittle.
  • Grounding over guessing. In healthcare, a confident wrong answer is worse than “not available.”
  • Treating it as software, not a demo. Memory, observability and CI/CD are what let it run in front of clinicians.

EpochC builds production multi-agent systems on LangGraph. Start a project or hire on Upwork.