Skip to main content
CBT therapy protocol generator for mental health applications.

Code

Create supervisor_cbt.py with the code below, or save it directly from your editor.

Additional Files

Create these supporting files in the same directory:

agents.py

database.py

langgraph_integration.py

state.py

state_mapper.py

utils.py

workflow.py

Skill Configuration

Create skills/cbt-therapy-skill/skill.yaml:

How It Works

Multi-Agent Workflow
  • Drafter Agent: Creates initial CBT exercise draft
  • Safety Guardian: Validates clinical safety and ethics
  • Clinical Critic: Reviews therapeutic quality
LangGraph Integration
  • Uses LangGraph for workflow orchestration
  • Stateless execution (one-shot invocation)
  • Maps Bindu context to LangGraph thread
State Mapping
  • Converts Bindu messages to LangGraph input
  • Transforms ProtocolState to Bindu artifacts
  • Includes safety scores and clinical feedback
Workflow Flow
  1. Extract user concern from Bindu message
  2. Map context_id to LangGraph thread_id
  3. Invoke multi-agent workflow (Drafter → Safety → Critic)
  4. Convert ProtocolState to Bindu artifact format
  5. Return structured CBT exercise with metadata
Safety & Quality
  • Safety score (0-100) from Safety Guardian
  • Clinical score (0-100) from Clinical Critic
  • Safety verdict validation
  • Quality feedback in metadata

Dependencies

Environment Setup

Create .env file:

Run

Examples:
  • “I am overwhelmed with sleep problems”
  • “Can you help me create a coping strategy for anxiety?”
  • “What are the key principles of CBT for depression?”

Example API Calls

Frontend Setup

Open http://localhost:5173 and try to chat with the CBT therapy agent