Building a Multi-Agent Healthcare Analytics Assistant with LLM-Powered Natural Language Queries
komodo_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 analytics natural-language assistant
Komodo Health needed an AI assistant that lets users ask natural-language healthcare analytics questions over proprietary patient-event data, while keeping analytical outputs trustworthy, authorized, testable, and maintainable as user requests grew beyond predefined workflows.
Constraints:
- company-specific cohort questions require proprietary database access, not model knowledge
- healthcare analytics users must trust raw data outputs and avoid hallucinated analytical results
- router workflows were controllable but too rigid for unexpected user questions
- pure multi-agent ReAct systems were too slow, costly, autonomous, and opaque for production
- authentication and authorization must be enforced by code and APIs, not by the LLM
Architecture
Komodo evolved from a single LLM call to chained natural-language-to-structured-payload workflows, then router-based workflows, and finally a hybrid multi-agent system. The production architecture uses a ReAct supervisor for flexible routing, typo correction, explanations, and unexpected questions, while sub-agents use ReAct only when truly complex. Deterministic workflows and APIs still produce the raw database outputs, and those tool outputs remain the final answer users trust.
Diagram confidence: reconstructed (reconstructed from prose).
flowchart LR healthcare-analytics-assistant["Healthcare analytics assistant"] --> supervisor-agent["Supervisor agent"] healthcare-analytics-assistant --> user-feedback["User feedback"] supervisor-agent --> router["Router"] supervisor-agent --> sub-agents["Sub-agents"] supervisor-agent --> deterministic-workflows["Deterministic workflows"] router --> deterministic-workflows deterministic-workflows --> structured-payload["Structured payload"] structured-payload --> tool-apis["Tool APIs"] sub-agents --> tool-apis tool-apis --> medical-events-database["Medical events database"] tool-apis --> result-renderer["Result renderer"] result-renderer --> healthcare-analytics-assistant structured-payload --> automated-tests["Automated tests"] automated-tests --> observability-stack["Observability stack"] observability-stack --> user-feedback observability-stack --> healthcare-analytics-assistant
Components
| Component | Role | Interacts with |
|---|---|---|
Healthcare analytics assistant |
Chat interface for natural-language cohort and healthcare analytics questions. | Supervisor agent, Deterministic workflows, User feedback |
Supervisor agent |
ReAct-style agent that handles unexpected questions, routing, typo correction, explanations, and error handling. | Healthcare analytics assistant, Router, Sub-agents, Deterministic workflows, Tool APIs |
Router |
Intent-detection layer that directs known query types to workflows. | Supervisor agent, Deterministic workflows |
Deterministic workflows |
Controlled code paths that translate supported requests into structured payloads and call database APIs. | Router, Tool APIs, Structured payload |
Sub-agents |
Specialized ReAct agents used only for complex tasks where deterministic code is insufficient. | Supervisor agent, Tool APIs |
Structured payload |
JSON-like object produced from user language and used as a deterministic API input. | Deterministic workflows, Tool APIs, Automated tests |
Tool APIs |
Authenticated services that query databases, enforce authorization, and return raw analytical results. | Structured payload, Medical events database, Result renderer, Supervisor agent, Sub-agents |
Medical events database |
Komodo's proprietary database of anonymized American patient medical events and standardized healthcare codes. | Tool APIs |
Result renderer |
Formats raw tool/database output into user-friendly cohort cards while preserving the tool as source of truth. | Tool APIs, Healthcare analytics assistant |
Automated tests |
Compares structured tool outputs against expected JSON payloads for sub-agent and whole-system evaluation. | Structured payload, Observability stack |
Observability stack |
LangSmith or Langfuse-style monitoring for tokens, latency, tool calls, and execution graphs. | Automated tests, Healthcare analytics assistant, User feedback |
User feedback |
Thumbs-up/thumbs-down production feedback reviewed for LLM issues, unsupported use cases, and bugs. | Healthcare analytics assistant, Observability stack |
Data flow
A user asks an analytics question in natural language. The supervisor agent decides whether the question can go through a deterministic workflow or needs a sub-agent. The selected workflow or agent converts the request into a structured payload, calls authenticated APIs/tools that query Komodo's database, receives raw database output, renders the result as a user-facing card, and optionally adds explanation or error-handling text from the supervisor. The LLM never serves as the authorization boundary or source of analytical truth.
4 supporting quotes
Why this architecture
Komodo chose a hybrid architecture because neither rigid routers nor fully autonomous nested agents worked alone. Routers gave control and trust but failed on unexpected questions. Pure multi-agent ReAct gave flexibility but was slow, costly, black-box, and harder to trust. The final design keeps the supervisor agent for flexibility, deterministic code for routine paths, sub-agents only for complexity, and tool/database output as the trusted analytical result.
4 supporting quotes
Models used: Claude Sonnet · foundation models · fine-tuned models · embedding models
Scale
- The assistant project started about two years before the talk and had one year of production operation.“this AI assistant has been uh I think the first it started about two years ago um and it went to production uh last year.”transcript, stated
- Komodo has about 20 employees in Europe.“essentially because uh it's American and we're 20 employees in Europe. Um so Komodo uh has this huge database um where we store medical events of American”transcript, stated
- A representative analytics query asks for male patients above age 59 with diabetes or psoriasis.“what is the number of patients with diabetes or with psoriasis uh who are male and who uh are above 59 for example.”transcript, stated
- The test suite can contain hundreds of structured-output tests.“test. And we can have like hundreds of those and then at the end give a number. And we can do that differently in different ways. We can do that for each sub agent or we can that do that for the whole system.”transcript, stated
- The team changed model families three times over two years.“Um I I think in so in two years we changed like three times of model family. um we were using uh different different models. Um and every time we really change the model family, it's because we change the model the the architecture, the whole”transcript, stated
- Medical-code normalization can involve several hundred diabetes-related codes.“if you look for diabetes, you're going to get so 300 600, I can't remember. Several hundreds of related codes.”transcript, stated
Alternatives considered (roads not taken)
Single LLM prompt answering from model knowledge
Rejected because: The model cannot know proprietary database counts and may hallucinate company-specific analytics answers.
Router-only architecture with predefined workflows
Rejected because: It gave control and trust, but unsupported questions were routed poorly or rejected without a workaround.
Pure nested multi-agent supervisor architecture
Rejected because: It handled complex tasks but became too slow, costly, autonomous, and black-box for production.
Fine-tuned models for the agentic architecture
Rejected because: Agents needed broad reasoning, long prompt understanding, and tool-use capabilities that fit foundation models better.
Ask the LLM alone to normalize medical codes
Rejected because: The model returns common codes but misses rare valid codes needed for comprehensive analysis.
Patterns
multi-agent-orchestration (agents)
Komodo uses a supervisor pattern where the top-level agent handles unexpected questions and delegates to sub-agents only when complex tasks justify ReAct overhead.
structured-output-contract (generation)
The assistant converts user language into structured payloads and tests those JSON-like tool inputs directly.
tool-use-orchestration (agents)
LLMs and agents call APIs/tools for database access, rendering, and medical-code handling, while deterministic code performs supported actions.
guardrails-io-filtering (safety)
Komodo treats tool outputs and prompt rules as guardrails, with the most important guardrail being that analytical answers come from authenticated tools rather than generated text.
safety-policy-enforcement (safety)
Authentication and authorization are enforced by APIs/tools, so the LLM cannot grant data access outside code-level policy.
eval-driven-development (evaluation)
Komodo builds automated tests over structured tool outputs and uses evaluation datasets for both fine-tuning and prompt engineering.
observability-tracing (operations)
The team monitors token counts, latency, tool-call counts, execution graphs, and production feedback using LLM observability tooling.
fine-tuning-adaptation (models)
Earlier router/chaining versions used fine-tuned models, but the team later learned fine-tuning could memorize unintended dataset artifacts.
latency-optimization (operations)
Komodo limits ReAct agents to complex cases and uses deterministic code where possible because nested agent reasoning created unacceptable latency.
Tradeoffs
Final answer source
Chose tool/database outputs as the source of truth over LLM-generated analytical results.
Rationale: Healthcare analytics users need trust and no hallucinated counts; the LLM can translate and explain, but the data card should come from the tool.
Production agent architecture
Chose hybrid supervisor plus deterministic workflows over pure autonomous multi-agent execution.
Rationale: The hybrid design preserves flexibility for unexpected questions without paying ReAct cost, latency, and black-box overhead on every path.
Model customization
Chose foundation models for agentic workflows over fine-tuned models for the supervisor/sub-agent architecture.
Rationale: Agents need reasoning, long context, prompt adherence, and tool-calling more than narrow learned formatting behavior.
Security boundary
Chose authenticated APIs/tools enforce authorization over LLM-mediated access control.
Rationale: The LLM does not know user roles and cannot bypass an API returning unauthorized/no-data results.
Framework usage
Chose use frameworks for complex multi-agent systems over frameworks for simple API-call cases or fully reinventing complex orchestration.
Rationale: Framework abstractions add cost for simple work, but established tools help once the architecture is genuinely complex.
Gotchas (what bit them)
Router workflows were trustworthy but too rigid.
Root cause: Unsupported questions had to be forced through a known route or rejected.
Resolution: Komodo added an agentic supervisor for unexpected questions while keeping deterministic workflows for known paths.
Pure nested ReAct agents were too slow and hard to control.
Root cause: Each request triggered multiple rounds of inner thoughts, agent calls, tool calls, and autonomous black-box decisions.
Resolution: The production system uses ReAct sub-agents only when the task is really complex and useful.
Fine-tuned models learned accidental training-data glitches.
Root cause: The model learned unintended examples, not just the desired date-range formatting pattern.
Resolution: The team treated fine-tuning as architecture-dependent and moved agentic workloads toward foundation models plus evaluation datasets.
Medical-code normalization was harder than asking the model for disease codes.
Root cause: Natural-language disease names map to hundreds of standardized codes, synonyms, and quality issues outside Komodo's control.
Resolution: The team explored combinations such as model suggestions, graph RAG/entity matching, vectorization, and domain-aware embeddings with explicit tradeoffs.
Provider and model behavior changed under the team.
Root cause: The LLM ecosystem is new, and even providers may change model behavior or endpoints without clear communication.
Resolution: Komodo avoids chasing every model, retests when changing model families, and evolves model, prompt, and architecture together.
A chat interface alone did not create product value.
Root cause: Replacing existing UI clicks with natural-language text can be slower than buttons if the assistant does not improve the workflow.
Resolution: The team iterated toward use cases where natural language, tools, and analytics genuinely changed the user workflow.
Evaluation
Komodo evaluates structured JSON/tool outputs with automated tests at sub-agent and whole-system levels, tracks operational metrics such as tokens, latency, tool calls, and execution graphs, and reviews thumbs-up/thumbs-down feedback for root cause.
Metrics: structured JSON payload correctness · hundreds of automated tests · sub-agent performance · whole-system performance · token count · latency · number of tool calls · execution graph · thumbs-up/thumbs-down feedback
3 supporting quotes
Outcomes
- The assistant evolved through single-prompt, chained, router, pure-agent, and hybrid supervisor architectures.
- The production system preserves raw tool/database outputs as the trusted analytical answer while using the supervisor for flexibility and explanations.
- Automated structured-output tests and observability make the system more measurable than free-form answer generation.
- Security testing found behavior manipulation could happen, but unauthorized data access was blocked by API authorization.
The project had one year of prototyping and one year in production, changed model families three times over two years, supports proprietary medical-event analytics, and uses hundreds of structured tests for measurable evaluation.