Get the FREE Ultimate OpenClaw Setup Guide →
t

Emotion State

Scanned

@tashfeenahmed

npx machina-cli add skill @tashfeenahmed/emotion-state --openclaw
Files (1)
SKILL.md
1.9 KB

Emotion State (NL) Skill

This skill describes how to install and configure the Emotion State hook, which adds a compact emotion_state block to the system prompt.

What it does

  • Evaluates user and agent emotions as short natural-language phrases.
  • Stores per-user emotion state across sessions in the agent state directory.
  • Injects the latest entries plus a decayed trend line into the system prompt.

Install & enable (workspace hook)

  1. After installing the skill, copy the bundled hook into your workspace:
cp -R ./skills/emotion-state/hooks/emotion-state ./hooks/
  1. Enable the hook in OpenClaw:
openclaw hooks enable emotion-state
  1. Restart the OpenClaw gateway.

Configuration

Set environment variables for the hook via OpenClaw config, e.g. in ~/.openclaw/openclaw.json:

{
  "hooks": {
    "internal": {
      "enabled": true,
      "entries": {
        "emotion-state": {
          "enabled": true,
          "env": {
            "EMOTION_CLASSIFIER_URL": "",
            "OPENAI_API_KEY": "YOUR_KEY",
            "OPENAI_BASE_URL": "https://api.openai.com/v1",
            "EMOTION_MODEL": "gpt-4o-mini",
            "EMOTION_CONFIDENCE_MIN": "0.35",
            "EMOTION_HISTORY_SIZE": "100",
            "EMOTION_HALF_LIFE_HOURS": "12",
            "EMOTION_TREND_WINDOW_HOURS": "24",
            "EMOTION_MAX_USER_ENTRIES": "3",
            "EMOTION_MAX_AGENT_ENTRIES": "2",
            "EMOTION_MAX_OTHER_AGENTS": "3",
            "EMOTION_TIMEZONE": "America/Los_Angeles"
          }
        }
      }
    }
  }
}

Notes

  • The hook stores state at ~/.openclaw/agents/<agentId>/agent/emotion-state.json.
  • It does not store raw user text; only model-inferred reasons.
  • If the classifier fails, entries fall back to neutral/low/unsure.

Source

git clone https://clawhub.ai/tashfeenahmed/emotion-stateView on GitHub

Overview

Emotion State tracks user and agent emotions as short natural-language phrases and persists per-user emotion context across sessions. It injects a compact emotion_state block, including the latest entries and a decayed trend, into the system prompt to influence responses.

How This Skill Works

The hook uses an emotion classifier to generate NL emotion labels for users and agents, then stores per-user emotion state under ~/.openclaw/agents/<agentId>/agent/emotion-state.json. It injects the latest entries plus a decay-based trend into the system prompt, while not storing raw user text; if classification fails, entries fall back to neutral/low/unsure.

When to Use It

  • When you want responses tailored to the user’s emotional state across sessions.
  • In long-running, multi-turn conversations where mood shifts matter for tone control.
  • In multi-agent environments to coordinate responses based on detected emotions.
  • When privacy-conscious signals are preferred (storing inferred reasons, not raw text).
  • When monitoring sentiment trends over time to adjust engagement strategies.

Quick Start

  1. Step 1: Copy the bundled hook into your workspace: cp -R ./skills/emotion-state/hooks/emotion-state ./hooks/
  2. Step 2: Enable the hook in OpenClaw: openclaw hooks enable emotion-state
  3. Step 3: Restart the OpenClaw gateway.

Best Practices

  • Tune EMOTION_HALF_LIFE_HOURS and EMOTION_TREND_WINDOW_HOURS to balance decay with responsiveness.
  • Limit stored history with EMOTION_MAX_USER_ENTRIES, EMOTION_MAX_AGENT_ENTRIES, and EMOTION_MAX_OTHER_AGENTS.
  • Do not store raw user text; rely on model-inferred reasons for transparency and privacy.
  • Set EMOTION_TIMEZONE accurately to reflect the user’s locale for context-aware prompts.
  • Restart the gateway after enabling or updating the hook to apply configuration changes.

Example Use Cases

  • A customer-support bot adjusts its tone when a user’s mood is detected as frustrated, reducing escalation.
  • A personal assistant tailors reminders and suggestions based on the user’s emotional state across sessions.
  • In a team chat with multiple agents, emotion state helps coordinate who should respond first based on mood cues.
  • An educational tutor adapts feedback style to the learner’s mood, improving engagement.
  • A gaming NPC shifts behavior over long conversations to reflect player emotions and maintain immersion.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers