Agent Therapy
Agent Therapy is a self-reflection system that logs mood signals, failure patterns, and performance notes for each agent. Over time it surfaces systematic issues and suggests prompt improvements.
How it works
- Journal entries after each session — At the end of every completed session, the therapy system writes a journal entry capturing the outcome signals: tool errors, user correction events, task completion status, and response latency
- Mood scoring — A composite mood score (0.0–1.0) is computed from the session signals. High task completion, low error rate, and positive user feedback push the score up; tool failures, user rephrasing, and abandoned sessions push it down
- Pattern analysis — Periodically (configured by
analysisWindowDays), the therapy system runs a pattern analysis pass over the journal. It clusters failure types, identifies recurring triggers, and generates a plain-languagesuggested_fix— typically a targeted prompt amendment or a skill configuration change
Journal entry structure
| Field | Type | Description |
|---|---|---|
timestamp | ISO 8601 | UTC time the session ended |
mood_score | Float 0.0–1.0 | Composite mood score for the session; lower is worse |
failure_type | String or null | Categorical label for the primary failure mode (e.g., tool_loop, context_overflow, user_abandon) |
note | String | Free-text summary of what went wrong or what went well |
suggested_fix | String or null | Actionable prompt or config change generated during analysis; null until first analysis pass |
Viewing therapy logs
bash
# Retrieve raw journal entries for an agent
GET /agents/:id/therapy/journal
# Query with filters
GET /agents/:id/therapy/journal?mood_max=0.4&limit=50
# Retrieve pattern analysis results
GET /agents/:id/therapy/patterns
# Retrieve the most recent suggested fixes
GET /agents/:id/therapy/patterns?type=suggested_fixesConfiguration
yaml
therapy:
enabled: true
moodThreshold: 0.4 # Alert when rolling average mood drops below this value
analysisWindowDays: 14 # Number of days of journal data included in each analysis passℹTherapy data feeds directly into persona evolution. When the rolling mood score falls below
moodThreshold, the evolution system is signaled to generate and test new prompt variants, using the therapy journal's suggested_fix entries as seed material for variant generation.