
Building patient companion agents with LangChain on AWS
Learn how healthcare teams use LangGraph for durable state and clinician review gates, LangSmith for tracing and evaluation, and HIPAA-eligible AWS services to build agents that clinicians can trust.
Series: Global Startup Program Partner Blogs (1 article)
- 1Building patient companion agents with LangChain on AWS This article
By: Srimanth Tangedipalli, Partner Engineer, LangChain,
Karan Singh, Partnerships Lead, LangChain,
Gokhul Srinivasan, Sr. Partner Solutions Architect, AWS,
Nihita Sarma, AI Acceleration Architect, AWS,
Nneoma Okoroafor, Partner Solutions Architect, AWS
A member of a diabetes program sends a message at 9 p.m. to ask about a copay. Two lines later, they mention chest tightness. The first question can wait until business hours. The second cannot.
Healthcare and life sciences organizations are investing in patient companion agents to handle this mix. In a 2026 Deloitte survey of US healthcare technology executives , 61% said they are already building or implementing agentic AI, and 85% plan to increase that investment over the next two to three years. These agents stay with a member through a care program, answer coverage and program questions, check device readings against thresholds, and escalate clinical risk to a clinician.
LangChain, an AWS Partner, provides LangGraph, an open-source framework for building stateful agents, and LangSmith, its agent engineering platform for deployment, tracing, and evaluation. This post explores how healthcare and life sciences teams combine these tools with Amazon Web Services (AWS) to build companion agents that answer what they can, escalate what they should, and keep an auditable record of both.
The gap between messages
Care programs for physical therapy, diabetes, behavioral health, and weight management now run continuously in the app. Members log device readings, report symptoms, and ask questions between visits and as problems arise rather than during the appointment.
However, the clinical workforce has not grown to match this demand. Many messages that reach busy clinicians never need one: a copay question, a program step, a reading in range. They queue behind the ones that do, and that delay is where engagement decays.
The patient companion agent closes this gap. Working alongside the care team in the program's messaging app, it handles routine questions itself and hands anything that needs a human judgment to the care team: first line by default, escalating by design.
Why a good prompt is not enough
You might reasonably ask how this differs from a chatbot with a good prompt. The relationship is continuous, escalation is reversible, and screening runs before answering. Every message enters a LangGraph workflow that loads the member's relevant conversation and program context. LangGraph models that workflow as a graph of steps over shared state.
Durable state: LangGraph checkpoints preserve conversation and execution state, and a long-term store retains selected information across threads. With a persistent backend, conversations survive failures and deployments, and the agent recovers context months later. Because that history can contain protected health information (PHI), keeping it in the organization's own database puts it under the same access, backup, and retention controls as other clinical data.
Interrupts: A step can pause the graph, surface the context and proposed action, and wait for review. Because pending state is durable rather than an open connection, the clinical gate is structural: a path routed through the interrupt cannot proceed until someone resumes it.
Program scope: Eligibility rules, thresholds, and escalation criteria differ by program, so the agent uses instructions and tools scoped to the member's program. A new program needs a new scope, not a new workflow.
Two tiers of escalation
Tier one is crisis screening. The opening scenario is the case the system exists to catch, so screening runs on every message before the conversational path. The screener does not diagnose; it decides whether a clinician needs to see the message now. A positive classification triggers the program's clinician-defined emergency pathway and urgent human review, bypassing the routine queue. Pair the model classifier with deterministic checks, because this failure is silent: a classifier that stops firing looks like a quiet week.
Tier two is scope escalation. The program agent assesses whether a need exceeds what it should handle and routes it to a clinician. Tune it carefully: too eager rebuilds the queue you set out to relieve, and too reluctant lets the agent exceed its approved scope.
Both tiers use the same clinician review gate. The clinician works in the member's existing thread, inherits the context the agent gathered, takes over, and decides whether the agent should resume. Put the review queue inside the tool the care team already uses, because asking clinicians to leave their own system is an adoption tax.
Reference architecture on AWS
Figure 1: Patient companion agent reference architecture on AWS, shown with the LangSmith SaaS observability option. Click the diagram to view it full size.
LangGraph defines execution, state, and the human gate. LangSmith Deployment hosts the agent while LangSmith traces and evaluates it. AWS provides the foundation: compute, databases, retrieval, inference, and network controls.
Runtime: The agent runs on LangSmith Deployment in a hybrid model on Amazon Elastic Kubernetes Service (Amazon EKS) inside the customer's Amazon Virtual Private Cloud (Amazon VPC) . API servers and queue workers scale independently with message volume.
Agent state: Amazon Aurora PostgreSQL-Compatible Edition holds threads, runs, LangGraph checkpoints, and the long-term store, encrypted with AWS Key Management Service (AWS KMS) . Amazon ElastiCache handles coordination and streaming.
Retrieval: An ingestion process indexes approved documents from Amazon Simple Storage Service (Amazon S3) into an Amazon OpenSearch Service vector index. The agent then retrieves passages scoped to the member and program.
Models: Amazon Bedrock provides managed inference. Anthropic Claude Haiku handles classification and routine turns, and a more capable model, such as Claude Sonnet, handles complex conversations. Test each against your own screening accuracy, latency, and cost targets before committing. Amazon Bedrock Guardrails applies content and topic policies, while the clinical risk classifier decides when a human gets involved.
Where traces live: LangSmith offers two tracing options on AWS. With LangSmith SaaS, shown in Figure 1, redacted traces are exported from the VPC. With LangSmith Bring Your Own Cloud (BYOC), available on AWS for Enterprise customers, the data plane runs in the customer's own AWS account and VPC. Traces, datasets, and annotation queues stay inside the governed boundary while LangChain operates the deployment over AWS PrivateLink .
High availability: The critical failure is an escalation raised and never picked up. Design against it with durable handoff records, idempotent retries, acknowledgment tracking, alerts for overdue reviews, and Aurora replicas across Availability Zones. Delivering the referral is the application's job, not the interrupt's. Treat a dropped crisis referral as an incident.
Security and HIPAA considerations: Use HIPAA-eligible AWS services under a Business Associate Addendum (BAA) when processing PHI. Use VPC endpoints and AWS PrivateLink for private connectivity, and record API activity with AWS CloudTrail . A VPC alone does not establish HIPAA compliance.
Evaluation that holds up to review
A companion agent degrades quietly: the classifier drifts, the agent hedges, and containment slips while the logs stay clean. LangSmith is where that becomes visible, and where the record that legal, security, privacy, and clinical reviewers ask for gets built.
Tracing: Every run is captured as a tree of steps: the prompt, the program documents retrieved, each tool call, and the model's output. When a clinician asks why the agent answered the way it did, the trace is the answer. Mask PHI before traces leave the customer account, including metadata and tool payloads.
Evaluators: Clinicians define what a good answer looks like for their program, and those rubrics become evaluators: deterministic checks for hard rules, and LLM-as-judge evaluators, in which a separate model scores outputs against the rubric, for judgment calls. Clinicians review the evaluator's scores until they trust it to stand in for them. After that, it runs on every release.
Datasets and experiments: The test set comes from production: escalations a clinician confirmed, escalations they judged unnecessary, coverage questions with known answers, and near misses caught in review. Annotation queues route sampled traces to clinicians, so each disagreement becomes a new test case. Every prompt, model, or threshold change runs against that set before it reaches members, and the results stay with the release record.
Production monitoring: The same evaluators run on live traffic: every flagged crisis, a sample of routine conversations, and a slice of unflagged messages. The last group matters most, because a review set made only of flagged cases can never show the escalations the classifier missed.
Customer outcomes
Spring Health built a LangGraph agent, running on AWS, as a chat interface for its mental health platform - helping members before, during, and after therapy sessions. It matches members to providers, offers support when a member’s therapist isn’t available, and escalates to a human when needed. A guardrail screens every message for crisis. Clinicians define the rubrics that LangSmith evaluators and annotation queues check against, and non-technical staff run evaluations themselves. When a therapist reviewing conversations in LangSmith noticed a member pushing the agent past its boundaries, the team turned that into new monitoring metrics. Those metrics now flag members for outreach or escalation.
Conclusion
Companion agents succeed or fail on properties beyond model quality: whether context survives the program, whether a clinician can take a conversation over and give it back, whether risk signals reach a human, and whether a decision can be explained months later. LangGraph provides the runtime mechanisms, LangSmith makes behavior measurable, and AWS provides the secure, HIPAA-eligible foundation these organizations already run on.
Get started
LangSmith is available in AWS Marketplace as a SaaS , Bring Your Own Cloud (BYOC) , or self-hosted option, so teams can buy it through their existing AWS agreement. Read the LangSmith BYOC guide and the AWS Prescriptive Guidance overview of LangChain and LangGraph , or contact LangChain to scope a deployment.
Series: Global Startup Program Partner Blogs (1 article)
- 1Building patient companion agents with LangChain on AWS This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations

Loading article