molroo docs
Guides

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:

FieldDescription
emotion.vadPosition in Valence-Arousal-Dominance space
emotion.discreteHuman-readable label (joy, anger, sadness, etc.) with intensity
moodSlow-moving emotional baseline (changes gradually over many interactions)
somaticPhysical sensations tied to the emotion (racing heart, tension, warmth)
narrativeStory coherence metrics (tone, agency, coherence)
memoryEpisodeAutomatically stored memory of this interaction
socialUpdatesRelationship 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:

DimensionRangeMeaning
goal_relevance0 to 1How much does this matter to the character's goals?
goal_congruence-1 to +1Does this help or hinder the character's goals?
expectedness0 to 1Did the character see this coming?
controllability0 to 1Can the character do anything about it?
agency-1 to +1Who is responsible? (other vs. self)
norm_compatibility0 to 1Does 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)

ComponentRole
LLMEvaluates how the character would appraise a stimulus (generates appraisal vector) and produces the text response
molroo engineComputes 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.

Next steps

On this page