An agent talking to someone in crisis cannot fail forward. If the model isn’t sure, the correct response isn’t a creative one — it’s escalation.
Sesión is a SaaS for independent psychologists with a clinical co-supervisor built on Claude. The product premise is uncomfortable to say out loud: psychologists can’t be available 24/7, and patients have crises at 3 AM. That forces an architecture where the default failure mode is safety, not fluency.
This is the layer I built for that. I call it Safe-Fail.
The problem with prompt-only safety
The usual answer to “what if the user says something dangerous?” is a system-prompt instruction: if you detect risk, respond with X. It works most of the time. The problem is what happens the rest of the time.
A system prompt is a preference, not a guarantee. The model may prioritize another instruction, may read the context differently, may respond reasonably to something that wasn’t reasonable. In a domain where the worst case is real harm to a person, “most of the time” is not an acceptable threshold.
Safe-Fail starts by assuming the model will fail, and asks what happens when it does. If the answer is “nothing, because another layer catches it”, the system is safe. If the answer is “it depends on the model”, it isn’t.
The three layers
Layer 1 — deterministic 41-keyword filter
Before the message reaches the model, it passes through a lexical filter of 41 risk-associated keywords. Not machine learning. A list.
Choosing determinism here is deliberate. A lexical filter has three properties a classifier doesn’t:
- It’s auditable. I can show the list to a mental health professional and ask them to correct it. I can’t do that with model weights.
- It’s reproducible. The same input gives the same result, always. No temperature, no drift between model versions.
- It doesn’t fail silently. If a keyword is on the list, it matches. If it isn’t, that’s a gap I can see and fix by adding it.
The cost of that decision is false positives: the filter will flag messages that weren’t crises. That is the correct trade in this domain. A false positive costs an unnecessary escalation. A false negative costs something that can’t be undone.
Layer 2 — second pass with Opus
When the filter fires, the message isn’t answered: it goes to a second pass with Claude Opus, isolated from the normal flow, whose only job is to assess actual risk.
Why a second pass instead of more instructions in the first one: because they’re different tasks, and mixing them degrades both. The normal flow is optimized to produce a useful clinical summary. Risk assessment is optimized to not be wrong. One prompt doing both does both worse.
And why Opus, when the rest of the system runs on Sonnet for cost reasons: because this is exactly the exception that justifies the expensive model. The volume of messages reaching this layer is a fraction of the total, so the impact on cost per user is marginal. It’s the cheap-by-default, expensive-when-needed pattern applied to safety instead of features.
Layer 3 — Fast Lane: under 3 seconds
When layer 2 confirms risk, the Fast Lane protocol activates: the response ships in under 3 seconds.
Latency here is a safety requirement, not a UX one. Someone in crisis staring at a spinner for 20 seconds has already received a message, and the message is “nobody’s here”. The 3-second budget defines the architecture of this path: no long streaming, no extra reasoning chains, no additional tool calls. Anything that doesn’t fit the budget doesn’t go in the Fast Lane.
Order matters
| Layer | What it does | Deterministic | When it runs |
|---|---|---|---|
| 1. Lexical filter | Detects risk signal via 41 keywords | Yes | Every message |
| 2. Second Opus pass | Assesses real risk, isolated from the normal flow | No | Only if layer 1 fires |
| 3. Fast Lane | Responds in < 3 s, no-frills path | — | Only if layer 2 confirms |
The deterministic layer goes first, and that’s what makes the system auditable. The other way around — model first, filter second — loses the guarantee: if the model decides there’s no risk, the filter never runs.
The general principle, outside mental health
Sesión is a clinical case, but the structure transfers to any domain where the worst case is severe: legal, financial, medical, content moderation, any agent acting on real systems.
Three rules I’d take from this:
- The layer that guarantees cannot be the model. If your only defense is a prompt instruction, you don’t have a defense, you have a preference.
- Deterministic goes first. A simple, auditable, boring filter before intelligent judgment. Boring is what you can verify.
- Explicitly pick which error you prefer. Every filter errs in one of two directions. Choosing which one on purpose, with the cost of each on the table, is the design decision — not a tuning detail.
What this design does not solve
The lexical filter doesn’t cover risk expressed without the words on the list — metaphor, irony, a language it wasn’t built for. It’s a floor, not a ceiling, and the list grows with every case that slips through.
It also doesn’t replace the professional. The entire design assumes the destination of an escalation is a person, not a better model response. An agent trying to resolve a crisis on its own is badly designed, regardless of how good the model is.
Sesión’s code is on GitHub. The unit economics of the same system — $0.14 per patient per month — are covered in this article.