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:

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
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

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
“you use it to convert your natural language, your English question to a structured object which is the payload.”transcript, stated
“payload. And that payload is then passed on to an API which queries the database and then you get your answer. For the next slides, I'm going to represent this as this. You can see the little chain in the middle. That's my sort of drawings with my mouse on PowerPoint. Um, so you”transcript, stated
“Um, we used the supervisor as an agent. That was so important because this allowed us to handle user questions that weren't expected.”transcript, stated
“still come for from the tools. I still want my tools to have to to be the source of truth. I want my my users to really see the data that comes from my database and not that comes from the the LM. I have a new arrow which is the output from the”transcript, stated

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
“And uh the issue with this with this this solution is that quickly it felt too rigid too too constrained. Um, if the user and asks for something that is not possible in this diagram, then what happens? Either the LLM still directs through to uh a route to a workflow and”transcript, stated
“They can answer answer questions uh that weren't uh uh anticipated. It's fault to tolerant and self-correcting, but it's costly and slow.”transcript, stated
“complex and uh useful every time we can have deterministic codes we have deterministic code essentially it's finding a balance between this where you have the router which uh where you have lots of control, lots of trust and something that is”transcript, stated
“box and so on. React agents only where needed because um there's an overhead uh cost time uh blackbox and there's one thing I didn't mention but I just say here I'm just going to go back through slides. What you can see here is that my um answer arrows all”transcript, stated

Models used: Claude Sonnet · foundation models · fine-tuned models · embedding models

Scale

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.

“how many patients were diagnosed with hypertention in Florida last year then it's going to be much more complicated and uh the LM won't know out of the box”transcript, stated
“or maybe we'll hallucinate something so how do we fix this we can first solution is would be to chain the LM call with a tool execution. So you have your LM”transcript, stated

Router-only architecture with predefined workflows

Rejected because: It gave control and trust, but unsupported questions were routed poorly or rejected without a workaround.

“And uh the issue with this with this this solution is that quickly it felt too rigid too too constrained. Um, if the user and asks for something that is not possible in this diagram, then what happens? Either the LLM still directs through to uh a route to a workflow and”transcript, stated
“Either the LLM still directs through to uh a route to a workflow and then you get an answer that is sort of okay but does not exactly answer”transcript, stated

Pure nested multi-agent supervisor architecture

Rejected because: It handled complex tasks but became too slow, costly, autonomous, and black-box for production.

“spoiler this didn't work either. Why? Because agents are great. They can handle extremely complex task. They can answer answer questions uh that weren't uh uh anticipated. It's”transcript, stated
“This this pattern was so so slow because every time we asked a question, it went through through multiple uh inner thoughts.”transcript, stated

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.

“foundation models perfect for agents of course um you need an agent that LLM that is capable of reasoning and you don't you don't want to fine tune it this time you want it to be really capable of understanding your system prompts and the tools that it has to use”transcript, stated
“this time you want it to be really capable of understanding your system prompts and the tools that it has to use and that's this uh that's out of the box no fine chaining problem is you're prompt engineering and prompt engineering I think that's the wrong”transcript, stated

Ask the LLM alone to normalize medical codes

Rejected because: The model returns common codes but misses rare valid codes needed for comprehensive analysis.

“heard someone said ask the model. So the model will come up with a good list of codes. However, it will come up with the most common ones. So you will never get the 300 codes for diabetes. So it it's good for but it's not good enough for our use case. So we want to be sure that”transcript, stated
“most common ones. So you will never get the 300 codes for diabetes. So it it's good for but it's not good enough for our use case. So we want to be sure that we have all of those even the rare codes that people don't necessarily use but”transcript, stated

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.

“Um, we used the supervisor as an agent. That was so important because this allowed us to handle user questions that weren't expected.”transcript, stated
“React agents only where needed because um there's an overhead uh cost time uh blackbox”transcript, stated

structured-output-contract (generation)

The assistant converts user language into structured payloads and tests those JSON-like tool inputs directly.

“you use it to convert your natural language, your English question to a structured object which is the payload.”transcript, stated
“test the tool output which is the structured re JSON JSON here.”transcript, stated

tool-use-orchestration (agents)

LLMs and agents call APIs/tools for database access, rendering, and medical-code handling, while deterministic code performs supported actions.

“the AI this time actually calls the tools. So, it creates the tool create cohort with the same structured object”transcript, stated
“all of those tools have a layer of authentication and authorization which is not handled at all by the LLM.”transcript, stated

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.

“We have some in our system prompt where we uh tell the the yeah give give some basic rules.”transcript, stated
“our design with the tools that give the answer is already a garail in itself.”transcript, stated

safety-policy-enforcement (safety)

Authentication and authorization are enforced by APIs/tools, so the LLM cannot grant data access outside code-level policy.

“Authorization and authentication was handled by code not the LM.”transcript, stated
“If for some reason the the user has no access to the data, the API the tool will return an answer like four or three uh unauthorized”transcript, stated

eval-driven-development (evaluation)

Komodo builds automated tests over structured tool outputs and uses evaluation datasets for both fine-tuning and prompt engineering.

“I can build um automatic tests on this.”transcript, stated
“you also need a data set for prompt engineering to evaluate your models.”transcript, stated

observability-tracing (operations)

The team monitors token counts, latency, tool-call counts, execution graphs, and production feedback using LLM observability tooling.

“what's very important is to understand the number of tokens the latency number of tool calls”transcript, stated
“we tried both lang and langfuse because we're in Python”transcript, stated

fine-tuning-adaptation (models)

Earlier router/chaining versions used fine-tuned models, but the team later learned fine-tuning could memorize unintended dataset artifacts.

“When we had this design, we used fine tune agents because it really it was it was it we really improved the performance”transcript, stated
“our training data set contained this glitch for 60s. Um and the model actually learned that.”transcript, stated

latency-optimization (operations)

Komodo limits ReAct agents to complex cases and uses deterministic code where possible because nested agent reasoning created unacceptable latency.

“This this pattern was so so slow because every time we asked a question, it went through through multiple uh inner thoughts.”transcript, stated
“every time we can have deterministic codes we have deterministic code”transcript, stated

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.

“the arrow the out arrow is not coming out from the LLM it's coming out from the tool.”transcript, stated
“here you are sure that there are no hallucination because we're in healthcare so that's important”transcript, stated

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.

“we only used sub sub aents agents uh react agents in in the sub aents only when necessary only when it was really complex and uh useful”transcript, stated
“essentially it's finding a balance between this where you have the router which uh where you have lots of control, lots of trust”transcript, stated

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.

“foundation models perfect for agents of course um you need an agent that LLM that is capable of reasoning”transcript, stated
“and globally this is a choice to be based on architecture choice and tasks.”transcript, stated

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.

“all of those tools have a layer of authentication and authorization which is not handled at all by the LLM.”transcript, stated
“The LM has no knowledge of this. It does not know what are the roles and permissions of the user.”transcript, stated

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.

“You don't you don't need uh a framework unless unless you really need to because uh all of those frameworks, they come really at a cost.”transcript, stated
“if you're doing something complex really don't reinvent the wheel and use use tooling”transcript, stated

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.

“the issue with this with this this solution is that quickly it felt too rigid too too constrained.”transcript, stated
“Um, we used the supervisor as an agent. That was so important because this allowed us to handle user questions that weren't expected.”transcript, stated

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.

“This this pattern was so so slow because every time we asked a question, it went through through multiple uh inner thoughts.”transcript, stated
“of course you have less control because it's a complete black box.”transcript, stated

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.

“our training data set contained this glitch for 60s. Um and the model actually learned that.”transcript, stated
“even if we wanted the the LM to only learn the pattern learn the format it still learned something from our example that we didn't want it to learn.”transcript, stated

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.

“It's not diabetes in the database. It's completely normalized.”transcript, stated
“So you will never get the 300 codes for diabetes. So it it's good for but it's not good enough for our use case.”transcript, stated

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.

“we're almost certain like 99% certain that they changed the model behind the endpoint without telling us.”transcript, stated
“changing the model actually means testing everything again.”transcript, stated

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.

“let's have our current platform right but just in a chat that was like everyone everyone was doing this last year.”transcript, stated
“it's always faster to click on a few buttons than uh uh have your just write things.”transcript, stated

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
“test the tool output which is the structured re JSON JSON here. Um, and that's that's going to be our automatic test.”transcript, stated
“We can do that for each sub agent or we can that do that for the whole system.”transcript, stated
“understand the number of tokens the latency number of tool calls because this is going to be both your cost and also the user experience.”transcript, stated

Outcomes

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.

4 supporting quotes
“So that's an actual architecture that we had and it at one point it ran in production.”transcript, stated
“In the end, this is what worked for us.”transcript, stated
“you are sure that there are no hallucination because we're in healthcare so that's important”transcript, stated
“the unauthorized data access and modification. Um if you remember what I just showed you, you had the LM that called tools”transcript, stated