AI-Powered Healthcare: Building Reliable Care Agents in Production

sword_health · Healthcare · 2025 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Healthcare AI for remote physical therapy

Sword Health needed to ship LLM-powered patient and therapist support in a regulated healthcare setting where Phoenix could help patients during and outside sessions while preserving clinical safety, reliability, and compliance.

Constraints:

Architecture

Sword Health built Phoenix as an AI care agent around a layered safety and learning loop. Patient and therapist interactions pass through task-specific input/output guardrails, with medical-advice guardrails constrained by clinician-authored guidelines. For domain questions, the system retrieves knowledge articles from a vector database and places them in the prompt. Development is governed by evaluation loops: offline evals, live checks, subject-matter-expert review in an internal Gondola tool, LLM-as-judge alignment, A/B tests, product metrics, manual audits, and repeated production-data review. Clinical recommendations remain human-gated by physical therapists.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  phoenix-care-agent["phoenix-care-agent"] --> input-guardrails["input-guardrails"]
  input-guardrails --> phoenix-care-agent
  phoenix-care-agent --> rag-knowledge-retriever["rag-knowledge-retriever"]
  rag-knowledge-retriever --> vector-database["vector-database"]
  rag-knowledge-retriever --> knowledge-article-store["knowledge-article-store"]
  phoenix-care-agent --> output-guardrails["output-guardrails"]
  output-guardrails --> clinical-guidelines["clinical-guidelines"]
  phoenix-care-agent --> physical-therapist-back-office["physical-therapist-back-office"]
  physical-therapist-back-office --> gondola-human-review["gondola-human-review"]
  evaluation-suite["evaluation-suite"] --> gondola-human-review
  evaluation-suite --> llm-as-judge-evaluator["llm-as-judge-evaluator"]
  monitoring-and-audits["monitoring-and-audits"] --> evaluation-suite
  phoenix-care-agent --> memory-system["memory-system"]
  memory-system --> vector-database
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
phoenix-care-agent Patient-facing and therapist-facing AI care agent for session feedback, non-clinical tasks, and therapist co-pilot recommendations. input-guardrails, output-guardrails, rag-knowledge-retriever, physical-therapist-back-office, memory-system
input-guardrails Pre-model controls for prompt injection, jailbreaking, and unsafe input. phoenix-care-agent
output-guardrails Post-model controls for content safety, structural validity, and medical-advice boundaries. phoenix-care-agent, clinical-guidelines
clinical-guidelines Clinician-authored constraints that bound what Phoenix may advise in unsupervised conversations. output-guardrails, physical-therapist-back-office
rag-knowledge-retriever Retrieves the most similar support articles for domain questions and inserts them into the prompt. vector-database, phoenix-care-agent, knowledge-article-store
knowledge-article-store Human-support articles used as the chunk unit for RAG. rag-knowledge-retriever
vector-database Stores embedded production examples and knowledge articles for dynamic in-context learning and RAG. rag-knowledge-retriever, memory-system
evaluation-suite Offline and live evaluation process for prompt/model iterations, regression checks, and release decisions. gondola-human-review, llm-as-judge-evaluator, monitoring-and-audits
gondola-human-review Internal Streamlit tool where physical therapists score model outputs before release. evaluation-suite, physical-therapist-back-office
llm-as-judge-evaluator Model-based evaluator aligned against human judgments for scalable output review. evaluation-suite
memory-system MySQL/vector persistence for current-user history, past healthcare data, peer decisions, and learned interaction context. phoenix-care-agent, vector-database
physical-therapist-back-office Human clinical control point where therapists approve, reject, or change clinical recommendations. phoenix-care-agent, clinical-guidelines, gondola-human-review
monitoring-and-audits Product metrics, manual audits, dashboards, data review apps, and tracing tools used to inspect production behavior after release. evaluation-suite

Data flow

A patient interacts with Phoenix during or outside a rehab session. Input guardrails filter unsafe or adversarial content before the model; RAG retrieves relevant knowledge articles when domain knowledge is needed; the model generates a response or recommendation; output and medical-advice guardrails constrain what can reach the patient. For clinical recommendations, Phoenix acts as a therapist co-pilot: the physical therapist reviews, accepts, rejects, or changes the suggestion in the back office. Those reviewed outputs, user feedback, manual audits, and eval results feed future guardrails, prompts, datasets, and monitoring.

5 supporting quotes
“Phoenix creates a seamless support system for the patient during his rehabilitation program. During the session, Phoenix delivers a true one-on-one experience by providing real-time feedback”article, implied
“Input guardrails prevent unwanted content from reaching the model. Prompt injection, jailbreaking, content safety are just an example of some.”article, stated
“we retrieve the top and most similar articles from the knowledge base or from the vector database, and then we include those articles in the prompt and generate an answer to the user.”article, stated
“The PTs have access to a large back office of where they can control everything that's going on with their patients, and where we provide the recommendations and PTs can accept them or reject them or change them.”article, implied
“By collecting this feedback, we can build high-quality datasets that can be used for things such as guardrails, evaluations, few-shot learning, and fine-tuning.”article, implied

Why this architecture

The architecture separates generation, clinical control, evaluation, and data review because healthcare failures are high-impact and LLM outputs are non-deterministic. Guardrails bound unsafe input/output, RAG supplies domain knowledge without fine-tuning, human review protects clinical decisions, and repeated eval/feedback loops keep the system improving after release. Sword also keeps memory and production-data review close to the product because Phoenix needs patient context over time and new failure modes appear only in real use.

5 supporting quotes
“shipping these products in highly regulated industries presents unique challenges in ensuring safety, consistency, and reliability.”article, implied
“Guardrails are essentially for highly regulated industries, such as healthcare. They act as safety controls between the user and the model”article, implied
“When you want to improve the domain knowledge of the model, RAG is likely the best next step.”article, stated
“For everything that's clinical related, we always have the physical therapist reviewing or accepting the recommendation or changing it if they do not agree with it.”article, implied
“by regularly reviewing the outputs and the inputs, you can understand new patterns and failure modes and easily mitigate them.”article, implied

Models used: large language models · Claude 3.5 Sonnet · GPT-4.0

Scale

Alternatives considered (roads not taken)

Let Phoenix provide clinical feedback directly to patients

Rejected because: Sword keeps clinical recommendations under physical-therapist review for legal and safety reasons.

“We don't have clinical decisions or clinical feedback being provided to the patient without a human in the loop.”article, stated

Use only online guardrails in real-time conversations

Rejected because: Real-time guardrails added latency, so Sword optimized online checks and used offline post-conversation analysis where streaming remains hard.

“For streaming, like I mentioned, for real-time use cases, like in the conversation that Phoenix has with the patient at the end of the session, having online guardrails was a problem”article, stated
“we resorted to offline guardrails. Some of the examples that I've shown cover that.”article, stated

Use the model's long context window instead of retrieval

Rejected because: Sword observed lost-in-the-middle behavior and treats RAG as the better path for adding domain knowledge.

“we noticed that when you placed instructions either at the top or at the bottom of the input context, the performance was best than when the information was placed at the middle of the prompt.”article, stated

Jump straight to fine-tuning for every quality problem

Rejected because: Sword starts with prompt engineering and uses RAG when the model needs knowledge; fine-tuning is for behavior/tone/instruction-following gaps.

“prompt engineering is the best place to start and can be pretty much the best place to finish.”article, stated
“Context optimization helps you with what the model needs to know, and it's achieved through retrieval-augmented generation.”article, stated

Rely on a single evaluation style

Rejected because: Human, non-LLM, and LLM-based ratings cover different tasks and failure modes.

“Choosing the right rating approach is important, and each rating approach is suited for a different type of task.”article, stated

Patterns

guardrails-io-filtering (governance)

Phoenix uses input guardrails for prompt injection/jailbreak/content safety and output guardrails for content safety, structure, and medical-advice boundaries.

“We can consider two types of guardrails, input guardrails and output guardrails. Input guardrails prevent unwanted content from reaching the model.”article, stated
“output guardrails prevent unwanted content from reaching the user. As well, content safety, structural wellness, and medical advice are just an example”article, stated

human-in-the-loop-gate (governance)

Clinical recommendations are held behind physical-therapist review before they affect the patient.

“For everything that's clinical related, we always have the physical therapist reviewing or accepting the recommendation or changing it if they do not agree with it.”article, stated

rag-retrieval (retrieval)

Sword embeds support articles, retrieves the top similar articles, and includes them in the prompt for patient-support answers.

“We embedded the same article that are used by our human support agent into a vector database.”article, stated
“we retrieve the top and most similar articles from the knowledge base or from the vector database, and then we include those articles in the prompt”article, stated

eval-driven-development (evaluation)

Prompt/model iterations move through offline evaluations, live checking, human expert review, A/B testing, and monitoring before promotion.

“You start by creating a test set, either by asking subject matter experts to provide ideal outputs, or by using real data from production when available.”article, stated
“Once that happens, you then ask for human expert evaluation, and then refine the system until the human evaluation is positive. Finally, once the human evaluation is positive, you can A/B test”article, stated

llm-as-judge (evaluation)

Sword uses LLM-based rating as a middle ground between human review and deterministic metrics, with alignment checks against humans.

“The final rating approach is LLM based. This is a middle ground between human-based and non-LLM based.”article, stated
“you can measure the agreement between both, between the human and the model, and if they disagree to a high extent, you know that you have to improve your evaluation.”article, stated

agent-memory (context)

Phoenix stores current-user history, past healthcare data, peer decisions, and learned context across MySQL and vector databases.

“it has all the memory from the current user, everything that the user has done so far within our interaction with our products. Also, we have access to past healthcare data”article, stated
“Our memory system, it's currently composed of MySQL databases, vector databases.”article, stated

data-quality-loop (data-pipeline)

Sword repeatedly reviews production inputs/outputs to discover new failure modes, build datasets, and improve guardrails/evals/prompts.

“Although these models have very strong zero-shot capabilities, they can still fail in very unpredictable ways.”article, stated
“by regularly reviewing the outputs and the inputs, you can understand new patterns and failure modes and easily mitigate them.”article, stated

Tradeoffs

Keep clinical recommendations under therapist control.

Chose Phoenix as a physical-therapist co-pilot with accept/reject/change review over autonomous clinical feedback delivered directly to patients.

Rationale: The human gate preserves legal accountability and clinical safety while still allowing Phoenix to draft recommendations.

“Phoenix acts as the physical therapist co-pilot. A bit like writing code, like when we are using an IDE and we are writing code.”article, stated
“The PTs have access to a large back office of where they can control everything that's going on with their patients, and where we provide the recommendations and PTs can accept them or reject them or change them.”article, stated

Use task-specific guardrails instead of one generic safety threshold.

Chose product/context-specific guardrail thresholds and medical-advice rules over generic safety filters applied uniformly across healthcare products.

Rationale: Generic filters can create false positives in legitimate pelvic-health language, while medical advice needs narrower clinical constraints.

“Regarding task specificity, guardrails must be task specific.”article, stated
“for Bloom, our pelvic health product, we needed to adjust the threshold for content safety, as it is usual in this context to use sexual terms.”article, stated

Choose optimization path by failure mode.

Chose prompt engineering first, RAG for missing knowledge, fine-tuning for behavior over a single linear prompt-to-RAG-to-fine-tune progression.

Rationale: Different methods solve different problems: prompt engineering establishes the target, RAG adds knowledge, and model optimization changes behavior/tone.

“Most guys paint it as a linear flow. You start with prompt engineering, then go with few-shot learning, retrieval-augmented generation, and then finally use fine-tuning.”article, stated
“However, each one of these approaches solves for different things, and to solve the right problem, you need to choose the right approach.”article, stated

Use RAG rather than dumping knowledge into long context.

Chose article-level retrieval from a vector database over relying on the model's large context window.

Rationale: Sword observed lost-in-the-middle behavior and treats retrieval quality as separately measurable.

“using the model's large context window, which is only increasing with newest releases, might be a good option and a good place to start.”article, stated
“This issue is known as lost in the middle.”article, stated

Mix evaluation approaches instead of standardizing on one evaluator.

Chose human, non-LLM, and LLM-based ratings over only human review or only automated evaluation.

Rationale: Human review captures nuance but is slow; deterministic metrics scale but miss subjectivity; LLM judges sit between them and must be aligned to humans.

“This evaluation excels in evaluating things such as tone, factuality, and reasoning. However, it is very time consuming and can be extremely costly, especially at scale.”article, stated
“The main advantages are, of course, speed and scalability. However, it fails to evaluate things that are nuanced and subjective.”article, stated

Gotchas (what bit them)

Guardrails can add too much latency for real-time patient feedback.

Root cause: Online safety checks sit in the response path for time-sensitive Phoenix conversations.

Resolution: Optimize online guardrails and move some checks into offline post-conversation analysis when streaming makes online checks impractical.

“When adding online guardrails for Phoenix, we observed an increase in latency of around 30%. As a result, we needed to optimize the online guardrails to improve latency.”article, stated
“having online guardrails was a problem and it's not a solved problem for now. Basically, we resorted to offline guardrails.”article, stated

Guardrails can block valid healthcare content through false positives.

Root cause: Generic content-safety thresholds misread domain-specific language, especially in pelvic health.

Resolution: Make guardrails task-specific and tune thresholds per product context.

“when building guardrails for Bloom, our pelvic health product, we needed to adjust the threshold for content safety, as it is usual in this context to use sexual terms.”article, stated
“guardrails can also trigger false positives, thus preventing good content from reaching the user.”article, stated

LLM releases regress unpredictably without evaluation suites.

Root cause: Large language models are non-deterministic, so prompt/model changes do not behave like deterministic software changes.

Resolution: Treat evals as LLM unit tests and run offline checks, expert review, A/B tests, and ongoing monitoring before/after release.

“How do you deliver consistently without regressions? This is something that is very hard to do with large language models, given their non-deterministic nature.”article, stated
“We can see model evals as unit tests of LLMs. Prompting is often seen as an art, but when paired with evaluations, you can treat it as a software delivery.”article, stated

RAG can fail because retrieval misses or pollutes the needed context.

Root cause: Generation quality depends on retrieval relevance, context precision/recall, and whether the answer exists in the knowledge base.

Resolution: Evaluate generation and retrieval separately with RAGAS-style metrics and use query rewriting or clarification when similarity is low.

“When building retrieval-augmented generation systems, you need to think about evaluation. You need to consider not only metrics related with generation, but also metrics related with retrieval”article, stated
“Something that helped us improve this is query rewriting, so using world knowledge to rewrite the query.”article, stated

Sensitive healthcare data can make hands-on debugging and inspection hard.

Root cause: Regulated patient data raises HIPAA/GDPR-style access and anonymization concerns for developers.

Resolution: Use legal allowances for care improvement, explore anonymization, and promote safe data-review tooling and culture.

“when working in a highly regulated industry, looking at GDPR, sensitive data can be prohibitive for developers.”article, stated
“we have to abide with HIPAA, which is a law regarding healthcare data.”article, stated

Evaluation

Sword evaluates LLM features through test sets, offline evaluations, live checks, subject-matter-expert review, LLM-as-judge alignment, A/B tests, product metrics, manual audits, and repeated production-data review.

Metrics: human 1-to-5 or binary ratings · BLEU · ROUGE · Sequence Matcher score · LLM-human agreement · RAGAS faithfulness · RAGAS relevance · context precision · context recall · acceptance metrics · product metrics · manual audit findings

3 supporting quotes
“This is usually the flow that we follow when developing with evaluations. You start by creating a test set”article, stated
“This is an example where we have used a sequence matcher algorithm that evaluates the similarity between two sentences, providing a score between 0 and 1”article, stated
“A framework that's usually used to evaluate retrieval-augmented systems is the RAGAS score. It is composed of four metrics, two that measure generation and two that measure retrieval.”article, stated

Outcomes

The source reports three product lines, a 30% latency hit from online guardrails, a 10 percentage-point model-switch gain in one example, and memory built from current-user data, past healthcare data, peer decisions, MySQL databases, and vector databases.

3 supporting quotes
“Throughout the last few years, we have shipped and iterated on many LLM-powered features, such as features that support the patient during the session”article, stated
“Phoenix acts as a co-pilot, allowing the physical therapist to focus on what truly matters, building a relationship with the patient.”article, stated
“To wrap up, the main learnings are, start by building guardrails. They are extremely important to ensure safety and reliability.”article, stated