Building AI for health coaches: why I ended up with five shapes instead of one agent
Coachwise is a platform for health coaches. A coach runs an intake with a new client, sets goals, builds a protocol, and then follows the client through check-ins, messages, and calls. Every one of these steps produces text that a coach has to read and answer. That is where AI helps. It is also where AI can do real damage: it handles health data, it talks to clients on behalf of a coach, and a coach's reputation depends on every answer.
So the question was never "how do we add an agent". It was "which AI shape fits which step, and how do we keep every one of them safe".
One service, one entry point
The first decision was structural. All AI work runs in a separate Python service, not inside the main API. Callers name a task, and a single function, run_task, does the same steps every time: validate the input, build the run context (practice, client, acting coach, limits), record the run, execute the task's LangGraph graph inside a LangSmith trace, and validate the output.
Putting everything behind one door means the guardrails are not optional. A new task gets tracing, token limits, redaction, and consent checks for free, because there is no other way to call a model.
Different tasks, different shapes
I did not build one agent that does everything. Each task gets the simplest shape that works:
- Client messages are a workflow. Hard rules first, then a small local model as a pre-check that can only escalate, then triage, then either an answer with a strict check or a hand-over to the coach with a summary and a draft. A free-roaming agent has no business answering a client directly.
- Call transcripts are a workflow too. Long calls are split, summarised per part, and merged into key points, agreed actions, and a recap for the client.
- Check-in analysis is a bounded agent. It compares the new check-in with the two before it, reads the AI follow-up conversation the client had, and returns highlights, concerns, data gaps, and up to three suggestions.
- The intake chat is a conversation where code owns the plan. Code decides which health areas come next and when to stop. The model listens, writes the next question, and summarises for the coach at the end.
- The coach assistant is a supervisor: a small, cheap model acts as a scope gate, and only in-scope requests reach the tool-using agent.
The rule of thumb: the more the output reaches a client or changes data, the less autonomy the model gets.
The coach assistant: an agent that asks before it acts
The assistant is a chat inside the coach workspace. It can answer questions about clients, protocols, and check-ins, and it can change things, for example update a protocol or schedule a check-in.
Two design choices made this safe enough to ship.
First, the agent does not get one tool per endpoint. It gets a small fixed set: find a client, read an operation, describe an operation, run an operation, search evidence, load a skill. Operations come from a catalogue that maps to the real API endpoints, and they run as the signed-in coach. The agent cannot reach anything the coach could not.
Second, every write pauses. run_action triggers a LangGraph interrupt, the state is stored by a checkpointer in its own database schema, and the coach sees Confirm, Change, or Don't do it. Only then does the run continue. Tool calls are capped per turn, and a middleware repairs tool calls a model writes as text instead of calling them.
Health data and redaction
Before any model call, personal data is replaced with placeholders like [CLIENT] or [PERSON_1], and the real values are put back in the answer. Detection combines known names from the practice, patterns for emails, phones, and IBANs, and Presidio with spaCy for English and German. German needed extra rules because every noun is capitalised and looks like a name.
What a trace may contain is controlled by a privacy switch. In strict mode, only test practices send full content to LangSmith. Real practices send metadata only.
Grounding and not flooding the coach
An AI that produces many weak suggestions is worse than none. Every suggestion has to cite something real: a check-in answer, a message id, a transcript quote. Code checks the citation and drops anything that fails, plus anything on the practice's "never suggest" list.
Then a suggestion gate decides what the coach sees. Low importance never shows. Urgent always shows. Everything else respects cool-downs after a dismissal or a bad rating, and weekly caps per client. Suppressed suggestions are stored with the reason, so I can see later what the gate filtered.
Quality: evals before defaults
Each task has an eval dataset with made-up practices and clients, Python checks for hard expectations, and a rubric for an LLM judge. Running the evals syncs the dataset to LangSmith and records an experiment. Model choices are made by comparing configurations on the same cases, not by gut feeling. The result is cheap models for triage and checks, a mid-size model for writing and analysis, and a tiny local model for the pre-check, with an automatic fallback when the local server is down.
What I would tell another team
Start with the guardrails, not the agent. One entry point, redaction, scope, limits, and evals are what made it possible to move fast later. And give autonomy step by step. A workflow you can test is better than an agent you have to trust.