← Back to Skills Marketplace
fenrirlabsnl

EmoClaw

by fenrirlabsnl · GitHub ↗ · v1.0.6
cross-platform ✓ Security Clean
1904
Downloads
1
Stars
0
Active Installs
7
Versions
Install in OpenClaw
/install emoclaw
Description
Give your AI emotions that grow from its own memories. Emoclaw builds a unique emotional state that shifts with every conversation, decays between sessions, and evolves over time through self-calibration. Train it on your agent's identity files and watch it develop its own emotional fingerprint.
README (SKILL.md)

Emotion Skill

Emotions for AI agents — built from memories, shaped by relationships, always changing.

Emoclaw trains a lightweight model on your agent's identity and conversation history, producing a persistent emotional state that evolves with every interaction. Emotions decay naturally between sessions, shift based on who's talking and what's being said, and gradually recalibrate as your agent grows. The result is injected into the system prompt as an [EMOTIONAL STATE] block, giving your AI a felt sense of its own inner life.

How it works

  1. Bootstrapextract.py reads your agent's identity/memory files. label.py scores each passage via the Claude API (opt-in). train builds a small neural net from those scores. One-time setup.
  2. Encode — Each incoming message is turned into a 384-dim vector by a frozen MiniLM sentence encoder. No fine-tuning, no network call — runs from a local cache.
  3. Feel — The encoding + context (who's talking, what channel, previous emotion) flows through a GRU and MLP head, outputting an N-dimensional emotion vector (0-1 per dimension). The GRU hidden state persists across sessions — this is the "emotional residue" that carries forward mood.
  4. Decay — Between sessions, each dimension drifts back toward its baseline at a configurable half-life (fast for arousal, slow for safety/groundedness). Time apart = cooling off.
  5. Inject — The emotion vector is formatted as an [EMOTIONAL STATE] block and inserted into the agent's system prompt, giving the AI a felt sense of its own inner state.

Model is ~2MB, runs on CPU, adds \x3C50ms per message. Network access is only used during bootstrap (opt-in).

Quick Reference

Situation Action
First-time setup python scripts/setup.py (or manual steps below)
Check current state python -m emotion_model.scripts.status
Inject state into prompt python -m emotion_model.scripts.inject_state
Start the daemon bash scripts/daemon.sh start
Send a message to daemon See Daemon Protocol
Retrain after new data python -m emotion_model.scripts.train
Resume interrupted training python -m emotion_model.scripts.train --resume
Add new training data Add .jsonl entries to emotion_model/data/, re-run prepare + train
Upgrade from v0.1 See references/upgrading.md
Change baselines Edit emoclaw.yamldimensions[].baseline
Add a new channel Edit emoclaw.yamlchannels list
Add a relationship Edit emoclaw.yamlrelationships.known
Customize summaries Create a summary-templates.yaml and point config at it

Setup

Quick Setup

python skills/emoclaw/scripts/setup.py

This copies the bundled emotion_model engine to your project root, creates a venv, installs the package, and copies the config template. Then edit emoclaw.yaml to customize for your agent.

Manual Setup

If you prefer to set up manually:

1. Install the package

cd \x3Cproject-root>
# Copy engine and pyproject.toml from the skill
cp -r skills/emoclaw/engine/emotion_model ./emotion_model
cp skills/emoclaw/engine/pyproject.toml ./pyproject.toml

# Create venv and install
python3 -m venv emotion_model/.venv
source emotion_model/.venv/bin/activate
pip install -e .

Required: Python 3.10+, PyTorch, sentence-transformers, PyYAML.

2. Copy and customize the config

cp skills/emoclaw/assets/emoclaw.yaml ./emoclaw.yaml

Edit emoclaw.yaml to set:

  • name — your agent's name
  • dimensions — emotional dimensions with baselines and decay rates
  • relationships.known — map of relationship names to embedding indices
  • channels — communication channels your agent uses
  • longing — absence-based desire growth (can be disabled)
  • model.devicecpu recommended (MPS has issues with sentence-transformers)

See references/config-reference.md for the full schema.

3. Bootstrap (new agent)

If starting from scratch with identity/memory files:

# Extract passages from your identity files
python scripts/extract.py

# Auto-label passages using Claude API (requires ANTHROPIC_API_KEY)
python scripts/label.py

# Prepare train/val split and train
python -m emotion_model.scripts.prepare_dataset
python -m emotion_model.scripts.train

Or run the full pipeline:

python scripts/bootstrap.py

4. Verify

python -m emotion_model.scripts.status
python -m emotion_model.scripts.diagnose

Usage

Option A: Daemon (Recommended)

The daemon loads the model once and listens on a Unix socket, avoiding the ~2s sentence-transformer load time per message.

# Start
bash scripts/daemon.sh start

# Or directly
python -m emotion_model.daemon
python -m emotion_model.daemon --config path/to/emoclaw.yaml

Option B: Direct Python Import

from emotion_model.inference import EmotionEngine

engine = EmotionEngine(
    model_path="emotion_model/checkpoints/best_model.pt",
    state_path="memory/emotional-state.json",
)

block = engine.process_message(
    message_text="Good morning!",
    sender="alice",        # or None for config default
    channel="chat",        # or None for config default
    recent_context="...",  # optional conversation context
)
print(block)

Option C: One-shot State Injection

For system prompt injection without the daemon:

python -m emotion_model.scripts.inject_state

This reads the persisted state, applies time-based decay, and outputs the [EMOTIONAL STATE] block.

Integration

System Prompt Injection

Add the output block to your system prompt. The block format:

[EMOTIONAL STATE]
Valence: 0.55 (balanced)
Arousal: 0.35 (balanced)
Dominance: 0.50 (balanced)
Safety: 0.70 (open)
Desire: 0.20 (neutral)
Connection: 0.50 (balanced)
Playfulness: 0.40 (balanced)
Curiosity: 0.50 (balanced)
Warmth: 0.45 (balanced)
Tension: 0.20 (relaxed)
Groundedness: 0.60 (balanced)

This feels like: present, alive, between one thing and the next
[/EMOTIONAL STATE]

Daemon Protocol

Send JSON over the Unix socket:

{"text": "Good morning!", "sender": "alice", "channel": "chat"}

Special commands:

{"command": "ping"}
{"command": "state"}

Heartbeat Integration

The emotional state decays over time and needs to be refreshed at each session start. Add this entry to your HEARTBEAT.md:

- task: Refresh emotional state
  schedule: session_start
  run: python skills/emoclaw/scripts/inject_state.py
  inject: system_prompt  # append output as [EMOTIONAL STATE] block

Or call the daemon / inject_state script from your heartbeat/cron:

# In your heartbeat script
STATE_BLOCK=$(python -m emotion_model.scripts.inject_state 2>/dev/null)
# Inject $STATE_BLOCK into system prompt

Important: Without heartbeat integration, the emotional state block will go stale between sessions. The inject_state script applies time-based decay and outputs the current state — it must be called at least once per session.

Architecture

The model processes each message through this pipeline:

Message Text ──→ [Frozen MiniLM Encoder] ──→ 384-dim embedding
                                                    │
Conversation Context ──→ [Feature Builder] ──→ context vector
                                                    │
Previous Emotion ──────────────────────────→ emotion vector
                                                    │
                                            ┌───────┴───────┐
                                            │ Input Project  │
                                            │ (Linear+LN+GELU)│
                                            └───────┬───────┘
                                                    │
                                            ┌───────┴───────┐
                                            │     GRU       │
                                            │ (hidden state) │ ← emotional residue
                                            └───────┬───────┘
                                                    │
                                            ┌───────┴───────┐
                                            │ Emotion Head  │
                                            │ (MLP+Sigmoid) │
                                            └───────┬───────┘
                                                    │
                                            N-dim emotion vector [0,1]

The GRU hidden state persists across sessions — this is the "emotional residue" that carries forward mood, context, and relational memory.

See references/architecture.md for full details.

Security & Privacy

Data Flow

  1. Extraction (scripts/extract.py) reads markdown files listed in emoclaw.yamlbootstrap.source_files and bootstrap.memory_patterns. These are configurable and default to identity/memory files within the repo. Extracted passages are written to emotion_model/data/extracted_passages.jsonl.

  2. Redaction — Before writing, extracted text is passed through configurable regex patterns (bootstrap.redact_patterns) that replace API keys, tokens, passwords, and other secrets with [REDACTED]. Default patterns cover Anthropic keys, GitHub PATs, bearer tokens, SSH keys, and generic key=value credentials. Add custom patterns in emoclaw.yaml.

  3. Labeling (scripts/label.py) — opt-in only. Sends extracted passages to the Anthropic API for emotional scoring. Requires both ANTHROPIC_API_KEY and explicit user consent (interactive prompt before any API call). Use --yes to skip the prompt for automation. Use --dry-run to preview without any network calls.

  4. Training runs entirely locally. No data leaves the machine during prepare_dataset or train.

  5. Inference runs entirely locally. The daemon and inject_state script make no network calls.

Network Access

Network access is optional and limited to a single script:

Script Network? Purpose
extract.py No Reads local files only
label.py Yes (opt-in) Sends passages to Anthropic API
prepare_dataset No Local data processing
train No Local model training
daemon / inject_state No Local inference

The sentence-transformers encoder downloads model weights on first use (from Hugging Face). After that, it runs from cache with no network needed.

File Permissions

Path Purpose Created by
memory/emotional-state.json Persisted emotion vector + trajectory daemon / inference
emotion_model/data/*.jsonl Training data (extracted/labeled passages) extract.py / label.py
emotion_model/checkpoints/ Model weights train script
/tmp/{name}-emotion.sock Daemon Unix socket daemon

The daemon socket is created with permissions 0o660 (owner + group read/write) and cleaned up on shutdown. The socket path is configurable in emoclaw.yamlpaths.socket_path.

Path Validation

extract.py validates that every file path resolves to within the repository root before reading. Symlink chains and ../ sequences that would escape the repo boundary are rejected. This prevents a misconfigured source_files or memory_patterns from reading arbitrary files.

Configuring Redaction

Add or modify patterns in emoclaw.yaml:

bootstrap:
  redact_patterns:
    - '(?i)sk-ant-[a-zA-Z0-9_-]{20,}'    # Anthropic API keys
    - '(?i)(?:api[_-]?key|token|secret|password|credential)\s*[:=]\s*\S+'
    - 'your-custom-pattern-here'

Set redact_patterns: [] to disable redaction entirely (not recommended).

Isolation Recommendations

  • Run the bootstrap pipeline (extract → label → train) in an isolated environment or review the source file list before running
  • Audit bootstrap.source_files and bootstrap.memory_patterns in your emoclaw.yaml to ensure only intended files are included
  • Review emotion_model/data/extracted_passages.jsonl before running label.py to confirm no sensitive content will be sent externally
  • The daemon should run under the same user as your agent process — avoid running as root

Configuration

All configuration lives in emoclaw.yaml. The package falls back to built-in defaults if no YAML is found.

Config search order:

  1. EMOCLAW_CONFIG environment variable
  2. ./emoclaw.yaml (project root)
  3. ./skills/emoclaw/emoclaw.yaml

Key sections:

  • dimensions — name, labels, baseline, decay half-life, loss weight
  • relationships — known senders with embedding indices
  • channels — communication channels (determines context vector size)
  • longing — absence-based desire modulation
  • model — architecture hyperparameters
  • training — training hyperparameters
  • calibration — self-calibrating baseline drift (opt-in)

See references/config-reference.md for the complete schema.

Bootstrap Pipeline

Step 1: Extract Passages

scripts/extract.py reads identity and memory files, splitting them into labeled passages:

python scripts/extract.py
# Output: emotion_model/data/extracted_passages.jsonl

Source files are configured in emoclaw.yamlbootstrap.source_files and bootstrap.memory_patterns.

Step 2: Auto-Label

scripts/label.py uses the Claude API to score each passage on every emotion dimension:

export ANTHROPIC_API_KEY=sk-ant-...
python scripts/label.py
# Output: emotion_model/data/passage_labels.jsonl

Each passage gets a 0.0-1.0 score per dimension plus a natural language summary.

Step 3: Prepare & Train

python -m emotion_model.scripts.prepare_dataset
python -m emotion_model.scripts.train

Retraining

To add new training data:

  1. Add entries to emotion_model/data/ in JSONL format:
    {"text": "message text", "labels": {"valence": 0.7, "arousal": 0.4, ...}}
    
  2. Re-run the preparation and training:
    python -m emotion_model.scripts.prepare_dataset
    python -m emotion_model.scripts.train
    

Incremental Retraining

The training script saves a rich checkpoint (training_checkpoint.pt) that preserves the full optimizer state, learning rate schedule, and early stopping counter. To continue training from where you left off:

# Resume from the last checkpoint automatically
python -m emotion_model.scripts.train --resume

# Or specify a checkpoint file
python -m emotion_model.scripts.train --resume emotion_model/checkpoints/training_checkpoint.pt

This is a true continuation — optimizer momentum, cosine annealing position, and patience counter all pick up exactly where they stopped.

Growth Model

As the AI accumulates real conversation data:

  1. Passive collection — Log messages + model predictions
  2. Correction events — When emotion feels wrong, log the correction
  3. Periodic retraining — Incorporate new data, retrain
  4. Baseline adjustment — Baselines may shift as the AI develops

The system is designed to grow with the AI, not remain static.

Resources

  • references/architecture.md — Model architecture deep-dive
  • references/config-reference.md — Full YAML config schema
  • references/dimensions.md — Emotion dimension documentation
  • references/calibration-guide.md — Baseline, decay, and self-calibration tuning
  • references/upgrading.md — Version upgrade guide
  • assets/emoclaw.yaml — Template config for new AIs
  • assets/summary-templates.yaml — Generic summary templates
  • assets/example-summary-templates.yaml — Example personality-specific templates
  • engine/ — Bundled emotion_model Python package (copied to project root by setup.py)
Usage Guidance
This skill appears internally coherent for its stated purpose, but it processes potentially sensitive local files (identity/memories) and can optionally send extracted passages to Anthropic for auto-labeling. Before installing: - Review and understand which local files it will read (config.bootstrap.source_files and memory patterns) and move or redact anything you do not want processed. - If you do not want any external network exposure, do not run the labeling/bootstrap step that requires ANTHROPIC_API_KEY (label.py/bootstrap.py call is opt-in). - Verify the redact_patterns in the config cover any secrets you care about — regex redaction is helpful but not foolproof. - Run the skill in an isolated environment (container or dedicated VM) and create the venv under a directory you control to avoid accidental overwrites. - If you run the daemon, restrict socket ownership/group and permissions so only intended local users/processes can connect. - If you need higher assurance, audit the extract.py and label.py source to confirm no unexpected network calls are made outside the documented optional labeling step.
Capability Analysis
Type: OpenClaw Skill Name: emoclaw Version: 1.0.6 The OpenClaw skill 'emoclaw' is designed with strong security and privacy features. It explicitly declares and controls network access (opt-in to Anthropic API for labeling, with redaction and user consent). Critical protections like path validation (`extract.py`) prevent arbitrary file reads, and sensitive data redaction (`config.py`) mitigates credential leakage. All subprocess executions use safe command lists, and YAML parsing uses `safe_load`. The `SKILL.md` instructions are clear and do not contain any malicious prompt injection attempts, and the injected emotional state block is structured data derived from the model, not arbitrary input. The overall design demonstrates a proactive approach to security for an AI agent skill.
Capability Assessment
Purpose & Capability
Name/description match what the code and instructions do: extract identity/memory files, optionally label passages with Anthropic (Claude), train a small model, persist an emotion state, and inject an [EMOTIONAL STATE] block. The files and APIs used (sentence-transformers, torch) are appropriate for this task.
Instruction Scope
Runtime instructions explicitly tell the agent to read identity and memory files, prepare/train a model, persist state, and optionally send extracted passages to Anthropic for labeling. That scope is consistent with the stated goal but necessarily touches sensitive user data; the package includes redact regexes but redaction is imperfect by nature. The daemon exposes a local UNIX-socket API for inference (no auth beyond socket permissions).
Install Mechanism
There is no remote download/install spec embedded in the registry; SKILL.md describes a manual copy + venv + pip install workflow using included source. All dependencies are standard Python packages (torch, sentence-transformers, etc.). No URLs, extract steps, or obscure installers were observed.
Credentials
The skill does not require unrelated credentials. An optional ANTHROPIC_API_KEY is used only for the opt-in labeling step (bootstrap/label.py), which is consistent with the described functionality. No other secrets or external tokens are requested.
Persistence & Privilege
The skill persists state (memory/emotional-state.json, checkpoints) and can run a long-lived daemon that listens on a UNIX socket (configurable path, default /tmp/{name}-emotion.sock, created with 0o660 permissions). It does not request always:true and does not modify other skills. The socket-based interface could allow local users in the same group to query/control the daemon unless filesystem permissions and ownership are carefully managed.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install emoclaw
  3. After installation, invoke the skill by name or use /emoclaw
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.6
emoclaw 1.0.6 - Documentation: Converted the "How it works" section from a table to a numbered list for improved clarity. - No code or functional changes; all file contents remain the same except for documentation formatting.
v1.0.5
emoclaw 1.0.5 - SKILL.md has been updated to clarify how Emoclaw works, with a concise step-by-step overview of the emotional state generation process. - Added a high-level summary explaining message encoding, emotion calculation, session-based decay, and prompt block injection. - Setup, usage, integration, and architecture instructions remain, but with improved clarity and emphasis on opt-in network usage during bootstrap. - No code changes; documentation improved for accessibility and quick understanding.
v1.0.4
v1.0.3 — Security & Transparency Addresses OpenClaw registry security review. Added - Path validation — extract.py rejects any file path that resolves outside the repo root - Secret redaction — Extracted passages are filtered through 5 default regex patterns (API keys, tokens, PATs, SSH keys, credentials) before writing to JSONL. Configurable via bootstrap.redact_patterns in emoclaw.yaml - API consent prompt — label.py displays passage count, character total, and source file list before any API call, requiring explicit confirmation. --yes flag for automation - Security & Privacy section in SKILL.md — documents data flow, network access, file permissions, redaction, and isolation recommendations Changed - _meta.json — declares ANTHROPIC_API_KEY as optional env var, adds permissions block (filesystem reads/writes, optional network, daemon socket), and install block with dependencies - config.py — bootstrap defaults now include redact_patterns - emoclaw.yaml template — bootstrap section includes redact_patterns with sensible defaults No breaking changes All existing configs, models, and state files work without modification.
v1.0.3
**emoclaw 1.0.3 Changelog** - Added _meta.json file for improved metadata handling. - Manual install instructions updated: engine and pyproject.toml copy steps are now explicit. - Heartbeat integration instructions clarified to prevent emotional state going stale between sessions. - Minor wording and formatting improvements in setup and integration sections.
v1.0.2
emoclaw 1.0.2 - Updated the skill description to emphasize persistent, evolving emotional states built from AI memories and self-calibrated over time. - Clarified the conceptual overview and purpose, presenting emotions as dynamic and agent-specific. - No code or functionality changes; documentation only.
v1.0.1
- Added the full `engine/emotion_model` codebase with modules for model configuration, inference, training, feature engineering, scripts, and tests. - Updated setup instructions to clarify that the Quick Setup script now copies the full model engine to the project root before initializing the environment. - No changes to APIs or integration; this release prepares emotion model code for standalone use and custom training. - Users can now directly explore, modify, or extend the model, training scripts, and configuration templates.
v1.0.0
- Initial release of the emoclaw skill: persistent, N-dimensional emotion state tracking for AI agents. - Provides decay toward customizable baselines, relationship context, and system prompt emotion block injection. - Supports both daemonized operation (for performance) and direct Python/import use. - Includes a bootstrap pipeline for new agents, with labeling and training scripts. - Highly configurable via `emoclaw.yaml`: emotion dimensions, baselines, channels, relationship mappings, and more. - Detailed setup, usage, and integration instructions now documented.
Metadata
Slug emoclaw
Version 1.0.6
License
All-time Installs 0
Active Installs 0
Total Versions 7
Frequently Asked Questions

What is EmoClaw?

Give your AI emotions that grow from its own memories. Emoclaw builds a unique emotional state that shifts with every conversation, decays between sessions, and evolves over time through self-calibration. Train it on your agent's identity files and watch it develop its own emotional fingerprint. It is an AI Agent Skill for Claude Code / OpenClaw, with 1904 downloads so far.

How do I install EmoClaw?

Run "/install emoclaw" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is EmoClaw free?

Yes, EmoClaw is completely free (open-source). You can download, install and use it at no cost.

Which platforms does EmoClaw support?

EmoClaw is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created EmoClaw?

It is built and maintained by fenrirlabsnl (@fenrirlabsnl); the current version is v1.0.6.

💬 Comments