Emotion Pipeline
How molroo computes emotions for your AI characters.
Emotion Pipeline
molroo handles all emotion computation server-side. You send interactions, we return psychologically grounded emotional responses. No prompt engineering, no emotion logic on your end.
How it works
Your app sends a message
│
▼
molroo API
┌──────────────────────┐
│ Cognitive appraisal │ "How does the character evaluate this?"
│ Emotion dynamics │ "How does the emotion evolve over time?"
│ State transitions │ "Are there any sudden emotional shifts?"
│ Response assembly │ "What does the character feel and express?"
└──────────────────────┘
│
▼
AgentResponse
(emotion, mood, somatic markers, text)All emotion math is deterministic and reproducible. The same input always produces the same emotional output, regardless of which LLM provider you use.
What you get back
Every interaction returns an AgentResponse with:
| Field | Description |
|---|---|
emotion.vad | Position in Valence-Arousal-Dominance space |
emotion.discrete | Human-readable label (joy, anger, sadness, etc.) with intensity |
mood | Slow-moving emotional baseline (changes gradually over many interactions) |
somatic | Physical sensations tied to the emotion (racing heart, tension, warmth) |
narrative | Story coherence metrics (tone, agency, coherence) |
memoryEpisode | Automatically stored memory of this interaction |
socialUpdates | Relationship changes triggered by this interaction |
The appraisal input
The only part you can control is the appraisal vector — a 6-dimension evaluation of how the character perceives a stimulus:
| Dimension | Range | Meaning |
|---|---|---|
goal_relevance | 0 to 1 | How much does this matter to the character's goals? |
goal_congruence | -1 to +1 | Does this help or hinder the character's goals? |
expectedness | 0 to 1 | Did the character see this coming? |
controllability | 0 to 1 | Can the character do anything about it? |
agency | -1 to +1 | Who is responsible? (other vs. self) |
norm_compatibility | 0 to 1 | Does this fit the character's values? |
With an LLM adapter, the SDK generates this appraisal automatically from the conversation context. Without an LLM adapter, you provide the appraisal values directly.
Personality shapes everything
Each character's HEXACO personality profile influences how they process emotions:
- High Emotionality — Amplifies negative appraisals, stronger fear/anxiety responses
- High Extraversion — Higher baseline arousal, more expressive reactions
- High Agreeableness — Charitable interpretations of others' actions
- High Conscientiousness — Better emotion regulation, less volatile behavior
- High Openness — Wider emotional range, more nuanced responses
You define personality once when creating the character. The engine handles the rest.
Key properties
Emotional inertia — Emotions don't flip instantly. There's momentum. A character who is angry stays angry for a while, even if the next input is positive.
Mood vs. emotion — Emotions are momentary reactions. Mood is a slow-moving baseline that shifts over many interactions. A single kind word won't fix a bad mood.
Sudden shifts — When accumulated stress crosses a threshold, emotions can jump dramatically (calm to rage). And recovering from that extreme state takes more positive input than it took to get there.
Body budget — Characters have a physiological energy reserve. Prolonged stress depletes it, making emotional reactions more intense and harder to regulate.
What the LLM does (and doesn't do)
| Component | Role |
|---|---|
| LLM | Evaluates how the character would appraise a stimulus (generates appraisal vector) and produces the text response |
| molroo engine | Computes all emotion math, updates state, manages personality effects, tracks relationships and memory |
The LLM never decides what emotion the character feels. It only provides the cognitive evaluation. The engine handles everything else.
This means you can swap LLM providers freely — the emotional behavior stays consistent.