Skip to main content
AI & modern therapy

Prompt engineering and testing for mental health chatbots

By Nearby Published on April 6, 2026 Updated on October 9, 2026 6 min read

A useful prompt tells a mental health chatbot which task it's helping with, what information to ask for and how to decide on the next step. "Act as a psychologist" leaves those decisions largely unspecified. A thought record, for example, needs a way to distinguish the event from the user's interpretation before exploring alternatives.

The Boit and Patil framework (2025) treats prompt engineering as part of a larger system design. The paper calls this design MIND-SAFE. It proposes an architecture and a plan for evaluating it, rather than reporting a completed clinical trial.

What MIND-SAFE actually proposes

MIND-SAFE stands for Mental Well-Being Through Dialogue, Safeguarded and Adaptive Framework for Ethics. It is the framework in Boit and Patil's prompt-engineering paper, rather than a separate later implementation.

Its proposed architecture has an input layer, a dialogue engine and a multitiered checking system. The input layer assesses incoming messages. The dialogue engine uses a user-state database and retrieval-augmented generation (RAG) to supply relevant material from approaches such as CBT, ACT and DBT. A postgeneration filter examines the response, with therapist oversight and feedback informing subsequent development.

These components do different jobs. The prompt specifies how to conduct an exercise. Retrieval supplies source material. Application code can control which stage is active or what happens when a check fails. Calling a rule "hard" inside a prompt doesn't give it the same enforcement as application logic.

The detailed MIND-SAFE article examines this proposed design. The useful question for a developer is which component is responsible for a particular behavior and how that behavior will be tested.

Turn a broad instruction into a specific exercise

Consider a chatbot helping with an automatic thought after a difficult meeting. The following is an illustrative instruction fragment, rather than a tested treatment prompt:

Ask what happened in the meeting and which thought followed. Help the user separate observable events from their interpretation. Before offering an alternative, ask what supports the thought and what doesn't fit it. Let the user decide which interpretation is credible and choose whether to continue.

That gives a reviewer something concrete to inspect. Did the chatbot ask for the event? Did it distinguish an observation from an inference? Did its question leave room for disagreement, or did it lead the user toward a preferred answer?

A prompt can also specify when to pause an exercise, but the application needs defined behavior when the model misses that instruction. Testing should include short answers, ambiguous replies and attempts to change the task, alongside ordinary conversations.

SuDoSys, by Chen and colleagues (2024), offers a research example of stage-aware dialogue based on the WHO's PM+ guidelines. It combines generated instructions with a topic database and a stage controller. The LLM returns a transition status that the controller applies, so the model still influences progression.

The evaluation used 148 simulated clients and a separate role-play study with 20 students. It provides evidence about conversation quality. It doesn't demonstrate that putting an established protocol into a prompt preserves the protocol's clinical effect. Our CBT chatbot comparison places this design beside four other systems and their study methods.

What the 43% figure means

The Li and colleagues review (2023) included 35 studies. Fifteen described safety assessment or protection measures, about 43%. These included onboarding, access to human experts, adverse-event assessment or automated identification of potential harm.

The other 20 studies didn't report those measures in the review's extraction. That isn't evidence that they had no specialized prompts. Most included studies, 30 of 35, used retrieval-based conversational agents with established responses, rather than today's generative LLM chatbots.

The meta-analysis was a subset: 15 randomized trials with 1,744 participants. It examined psychological outcomes across different conversational systems. It wasn't a randomized comparison of prompt architectures, so it can't tell us which prompt design caused a benefit.

This distinction is practical when reading a product claim. A named therapy approach describes the intended method. To understand the implementation, look for an example exercise and documentation of the actual workflow. To assess outcomes, look for research on the particular system.

What EmoAgent adds to the engineering question

EmoAgent, Qiu and colleagues' 2025 preprint, uses simulated users to test interactions with character-based chatbots. EmoEval generates the users and estimates changes using questionnaire-based scores; EmoGuard adds feedback intended to improve the conversation.

The abstract reports deterioration in more than 34.4% of simulations. These are model-generated user trajectories and scores, rather than observed deterioration in human participants.

The guard experiments use selected character-and-style combinations. In two reported settings, the proportion of simulated users exceeding a five-point PHQ-9 increase fell to zero after adding EmoGuard. That thresholded result is different from the rate of any score increase, and it belongs to those experimental settings. The study helps test a checking mechanism; it doesn't measure elimination of clinical harm in people.

The engineering idea is useful: evaluate the generated conversation, rather than assume a well-written instruction was followed. Our guardrails article examines the experiments in more detail.

For Nearby's stated purpose and features, see the product facts. Nearby offers emotional support and self-help. These papers don't document its internal prompts or validate its architecture.

Frequently asked questions

What does prompt engineering mean here?

It means specifying the task, conversational steps and expected responses to different user inputs. In a complete application, those instructions work alongside state management, retrieval and checks.

Did 57% of systems lack specialized prompts?

That conclusion doesn't follow from Li's review. Fifteen of 35 studies reported safety measures; the remaining studies' lack of reporting doesn't establish their prompt design or the absence of safeguards.

Was MIND-SAFE tested in a clinical trial?

The cited Boit and Patil paper is a conceptual framework. It proposes a comparative validation strategy, rather than reporting patient outcomes from a completed test of the architecture.

How can a developer evaluate a structured prompt?

Define observable behavior first, then inspect whether conversations follow it across varied inputs. Compare the structured system with an appropriate baseline. Dialogue adherence, user experience and symptom outcomes need different measures; a high score on one doesn't substitute for the others.