Overview
The AI Mental Wellbeing Agent Team is a supportive mental health assessment and guidance system powered by AG2 (formerly AutoGen)‘s AI Agent framework. This application provides personalized mental health support through the coordination of specialized AI agents, each focusing on different aspects of mental health care based on user inputs such as emotional state, stress levels, sleep patterns, and current symptoms. Built using AG2’s swarm feature with theinitiate_swarm_chat() method.
Architecture
Swarm Orchestration Pattern
The Mental Wellbeing Team uses AG2’s swarm pattern for coordinated therapeutic support:Agent Roles
Assessment Agent
Role: Psychological assessment specialistApproach:
- Clinical precision with empathy
- Safe space creation
- Pattern identification
- Risk assessment
- Validation without minimizing
Action Agent
Role: Crisis intervention and resourcesApproach:
- Immediate coping strategies
- Intervention prioritization
- Resource connections
- Daily wellness plans
- Empowerment techniques
Follow-up Agent
Role: Long-term recovery planningApproach:
- Sustainable strategies
- Progress monitoring
- Relapse prevention
- Maintenance schedules
- Self-compassion focus
Implementation
- Swarm Agent Setup
- Agent Instructions
- Update Functions
- Swarm Execution
- Streamlit Interface
Agent Coordination Flow
Assessment Phase
Assessment Agent analyzes the user’s situation:
- Reviews emotional state and symptoms
- Identifies patterns and risk factors
- Validates experiences with empathy
- Provides 2-3 sentence summary
Action Phase
Action Agent creates immediate support:
- Develops evidence-based coping strategies
- Connects with appropriate resources
- Creates daily wellness plan
- Suggests support communities
- Provides 2-3 sentence summary
Follow-up Phase
Follow-up Agent designs long-term strategy:
- Creates personalized support plan
- Establishes progress monitoring
- Develops relapse prevention strategies
- Builds sustainable self-care routine
- Provides 2-3 sentence summary
Key Features
Comprehensive Assessment
Comprehensive Assessment
Clinical Precision:
- Emotional state analysis
- Pattern identification in thoughts and behaviors
- Risk assessment using validated approaches
- Relationship dynamics evaluation
- Creates safe space for sharing
- Acknowledges courage in seeking help
- Validates experiences without judgment
- Uses accessible, non-clinical language
Immediate Action Plans
Immediate Action Plans
Evidence-Based Strategies:
- Tailored coping techniques
- Self-regulation exercises
- Crisis management approaches
- Grounding and mindfulness practices
- Mental health services connections
- Support community recommendations
- Concrete daily wellness plans
- Specific times and activities
- Options for varying energy levels
Long-term Support
Long-term Support
Personalized Strategy:
- Milestone markers for progress
- Monitoring systems matched to preferences
- Relapse prevention based on triggers
- Support network mapping
- Graduated self-care routines
- Integration with lifestyle and values
- Progress over perfection emphasis
- Self-compassion techniques
- Regular check-in mechanisms
Interactive Results
Interactive Results
User-Friendly Presentation:
- Real-time summaries in sidebar
- Detailed expandable sections
- Clear action steps
- Organized by support phase
- Easy to save and reference
Input Parameters
- Emotional State
- Physical Indicators
- Stress & Support
- Life Context
Installation
Set OpenAI API Key
You’ll input your OpenAI API key in the Streamlit sidebarGet your key from platform.openai.com
Usage Example
Complete Support Plan Output
Complete Support Plan Output
User Input:
- Emotional State: “Feeling overwhelmed, anxious about work, trouble sleeping”
- Sleep: 4-5 hours per night
- Stress Level: 8/10
- Support System: Family, Friends
- Recent Changes: “New job, moved to new city”
- Symptoms: Anxiety, Insomnia, Difficulty Concentrating
- Your body is showing clear signs of stress (poor sleep, difficulty concentrating)
- Anxiety levels are significantly elevated (8/10)
- You have important support systems (family, friends) which is a strength
- Sleep deprivation is likely amplifying other symptoms
- Set phone alarm for same bedtime (10:30 PM)
- Dim lights 1 hour before bed
- Try 4-7-8 breathing: Breathe in for 4, hold for 7, out for 8 (4 times)
- Schedule one 20-minute walk daily (morning preferred)
- Text one friend/family member each day
- Keep a “worry dump” journal before bed
- BetterHelp or Talkspace: Online therapy ($60-90/week)
- Headspace app: Guided meditation free trial
- City-specific meetups: Search “[Your City] newcomers group”
- National Crisis Hotline: 988 (24/7, free)
- Crisis Text Line: Text HOME to 741741
- Primary goal: Sleep regulation
- Track: Sleep hours, anxiety level (1-10 scale)
- Milestone: 6+ hours sleep for 3 consecutive nights
- Add: Weekly social activity
- Continue: Sleep hygiene, daily walks
- Milestone: Stress level below 6/10
- Join: One local interest group
- Establish: Weekly friend check-in
- Milestone: Feeling “somewhat settled” in new city
- Use 4-7-8 breathing (3 rounds)
- Text your support system
- Take a 10-minute walk
- 1st of month: Review sleep tracker
- 15th of month: Assess stress level
- End of month: Celebrate one accomplishment
Technical Architecture
Two-Phase Execution
Context Accumulation
Best Practices
Honest Input
- Be truthful about your feelings
- Share relevant context
- Don’t minimize symptoms
- Include physical symptoms
- Mention support system honestly
Action Follow-Through
- Start with smallest actions
- Build gradually
- Track progress
- Celebrate small wins
- Be patient with setbacks
Professional Help
- Consider therapy if symptoms persist
- Use crisis resources when needed
- Don’t rely solely on AI support
- Verify advice with professionals
- Seek immediate help for crisis
Privacy Awareness
- Review OpenAI data policies
- Don’t share identifying details
- Use general descriptions
- Clear session data after use
- Consider privacy implications
Advanced Features
Adaptive Response Depth
Personalized Strategies
Performance Considerations
- Execution Time
- Cost
- Quality
- Summary phase: ~30-40s per agent
- Detailed phase: ~60-90s per agent
- Total: ~6-8 minutes for complete plan
- Model: GPT-4o (higher quality for sensitive content)
Ethical Considerations
Not a Replacement for Therapy
Not a Replacement for Therapy
This tool provides supportive guidance but:
- Cannot diagnose mental health conditions
- Cannot provide clinical treatment
- Cannot replace licensed professionals
- Cannot handle emergency situations
- Should complement, not replace, professional care
Privacy & Data
Privacy & Data
- Conversations processed by OpenAI
- Review OpenAI’s data policies
- No local storage of sensitive data
- Session state cleared on refresh
- Consider anonymizing personal details
Crisis Management
Crisis Management
- AI cannot assess suicide risk reliably
- Always provides crisis hotline info
- Encourages professional help
- Clear about limitations
- Emphasizes immediate help when needed
Cultural Sensitivity
Cultural Sensitivity
- Trained on diverse data
- May not capture cultural nuances
- Mental health stigma varies by culture
- Consider cultural context
- Seek culturally competent professionals
Related Examples
Game Design Team
Another swarm orchestration example
Health & Fitness Agent
Related wellness application
Deep Research Agent
Research on mental health topics
