Skip to main content
JA jansher.aquib
Linea Care 2025–present

Internal Multi-Agent Orchestration Framework

Distributed multi-agent system coordinating patient scheduling, insurance verification, clinical documentation, and follow-ups with deterministic guardrails.

LLM Orchestration Node.js TypeScript Postgres GitHub Actions

Context

In an Accountable Care Organization (ACO) setting, managing patient journeys requires coordination across multiple distinct domain boundaries: referral intake, eligibility and insurance benefits verification, appointment booking, pre-visit screening questionnaires, clinical encounter documentation, and post-encounter care follow-ups.

Problem

Building isolated one-off AI scripts leads to fragmented prompt engineering, uncoordinated tool calls, uncontrolled token expenditures, and zero shared observability. In healthcare workflows, non-deterministic model hallucinations or unvalidated mutations are completely unacceptable.

The platform required a cohesive, extensible multi-agent framework capable of executing complex multi-step workflows while enforcing strict schema validation, state persistence, and cost/latency budgets.

What I Built

  • Multi-Agent Orchestration Engine: Built an in-house agent framework where specialized agents handle specific phases of the patient lifecycle: Intake Documentation Agent, Benefits Verification Agent, Scheduling Agent, and Post-Visit Engagement Agent.
  • Deterministic Guardrails & Tool Calling: Implemented JSON-schema-validated tool execution preventing ungrounded mutations and ensuring model responses strictly conform to EHR API contracts.
  • Distributed State & Background Workers: Decoupled long-running workflows into asynchronous job queues with persistent state snapshots and resume-on-failure guarantees.
  • Cost & Latency Telemetry: Instrumented per-task token accounting, model routing (evaluating when to invoke lightweight vs reasoning models), and distributed tracing from day one.
  • Shared Backend Patterns: Standardized retrieval over historical patient data, prompt template management, and worker patterns across the entire engineering organization.

Architecture

  1. Workflow Coordinator: Receives incoming triggers (patient referrals, EHR webhooks, or scheduled follow-ups) and initializes an isolated execution state machine.
  2. Specialized Agent Pool: Dispatches subtasks to dedicated agents, each loaded with specialized system prompts, scoped toolsets, and validation rules.
  3. Guardrail Layer: Validates agent tool parameters against strict Zod/JSON schemas prior to executing external database or practice-management mutations.
  4. Audit & Event Bus: Emits lifecycle events over event queues for asynchronous tracking, audit logging, and downstream triggering.

Stack

  • Core Runtime: Node.js, TypeScript, Python
  • Orchestration & LLMs: OpenAI, Gemini, In-house Orchestration State Machines
  • Persistence & Queues: PostgreSQL, Redis, Cloud Tasks
  • Infrastructure & CI/CD: Docker, GitHub Actions, AWS / GCP

Outcome

  • Unified disparate clinical administrative workflows into an automated, auditable agentic pipeline.
  • Enforced strict schema validation and deterministic guardrails across all tool calls prior to executing practice-management mutations.
  • Streamlined referral intake, scheduling, benefits verification, and follow-ups with comprehensive observability and cost/latency tracking from day one.
  • Established foundational backend patterns adopted across all subsequent AI features at Linea Care.