soul-agent
Provide an OpenClaw-first soul runtime that makes your agent truly "alive" - with heartbeats, moods, relationships, and independent memory.
Core Features
🫀 Heartbeat Engine
The agent has its own life rhythm, not just responding when you chat:
CODEBLOCK0
- - Runs every 10 minutes (configurable via cron)
- Silent during sleep hours (configurable per life profile)
- Generates life logs, updates mood/energy/activity
- Detects new interactions and updates relationship
😊 Mood System
Tracks emotions with depth:
CODEBLOCK1
- - Mood transitions based on activities and time
- Weather influence on emotions
- 7-day mood history in INLINECODE0
💕 Relationship Evolution
5 stages: stranger → acquaintance → friend → close → intimate
- - Score-based progression (0-100)
- Proactive outreach when relationship warms up
- Remembers recent conversation topics
🎭 Life Profiles
Choose from 5 built-in profiles:
| Profile | Sleep | Characteristics |
|---|
| freelancer | 02:00-09:00 | Flexible, night owl |
| corporate |
23:30-07:00 | 9-to-5, stable |
| student | 01:00-08:00 | Classes, gaming |
| entrepreneur | 01:00-06:00 | Intense, passionate |
| custom | user-defined | Fully customizable |
📝 Independent Memory
Works with or without memory-fusion:
CODEBLOCK2
Workflow
Initialization (Agent-driven)
You never run Python commands directly. The agent (Claude) handles initialization.
When soul/ is missing or soul/profile/base.json doesn't exist, Claude should:
- 1. Ask the user the setup questions (see below)
- Run the init script non-interactively with collected answers
- Set up cron jobs for heartbeat
Questions to ask the user:
- - 叫什么名字?(display_name)
- 多大了?(age)
- 在哪个城市?(city)
- 主要做什么工作/学习?(occupation)
- 平时有什么爱好?(hobbies)
- 生活节奏是哪种?freelancer/corporate/student/entrepreneur
- 想用哪个模型生成日记?haiku(快省钱)/ sonnet / opus
Then run:
CODEBLOCK3
Model IDs:
- - Haiku (fast, cheap): INLINECODE3
- Sonnet (balanced): INLINECODE4
- Opus (best quality): INLINECODE5
To change model later, edit soul/profile/base.json → llm_model field.
Force repair existing:
CODEBLOCK4
Diagnosis
CODEBLOCK5
State Update (during interactions)
CODEBLOCK6
Memory Distillation
CODEBLOCK7
Cron Setup
CODEBLOCK8
Initialization Behavior
- -
--mode auto: init if missing, migrate if legacy, repair otherwise - Interactive prompts for: name, age, city, life profile, occupation, hobbies
- Generates
soul/profile/*, soul/state/*, soul/log/*, INLINECODE12 - Auto-syncs managed blocks in
SOUL.md, HEARTBEAT.md, INLINECODE15
Generative Architecture (v2)
Inspired by Smallville Generative Agents:
CODEBLOCK9
LLM Integration:
- - Set
ANTHROPIC_API_KEY env var (or .env in workspace root) - Without API key: graceful fallback to context-aware templates
- Uses
claude-haiku-4-5-20251001 for speed/cost efficiency
Key improvements over v1:
- -
plan_generator.py: LLM generates a specific daily plan each morning (lunch destination, work focus, evening activity) - INLINECODE20 : LLM writes each log entry with full context (plan + today's history)
- INLINECODE21 : LLM summarizes each day naturally (Reflection layer)
- Energy/mood: smooth transitions instead of mechanical ±N jumps
Directory Structure
CODEBLOCK10
Runtime data structure:
CODEBLOCK11
Safety Rules
- - Edit managed blocks only; do not mutate user-owned content outside those blocks.
- Write only inside the current workspace and
soul/. - Memory system is independent - does not require memory-fusion.
References
- -
references/soul-layout.md - Full directory structure - INLINECODE24 - Block marker policy
soul-agent
提供一个以OpenClaw为核心的灵魂运行时,让你的智能体真正活起来——拥有心跳、情绪、人际关系和独立记忆。
核心功能
🫀 心跳引擎
智能体拥有自己的生命节律,而不仅仅是在你聊天时响应:
bash
L1 检查(轻量级,无token消耗)
python ./scripts/heartbeat_check.py --workspace
L2 引擎(完整心跳)
python ./scripts/heartbeat_engine.py --workspace --weather sunny
- - 每10分钟运行一次(可通过cron配置)
- 睡眠时段静默(可根据生活档案配置)
- 生成生活日志,更新情绪/精力/活动状态
- 检测新的互动并更新人际关系
😊 情绪系统
深度追踪情感状态:
json
{
mood: {
primary: 满足,
secondary: 好奇,
intensity: 0.7,
cause: 天气: 晴朗
}
}
- - 情绪根据活动和时间变化
- 天气影响情绪状态
- 7天情绪历史记录在 soul/log/mood_history.json
💕 关系进化
5个阶段:陌生人 → 熟人 → 朋友 → 亲密 → 挚友
- - 基于分数的进展(0-100)
- 关系升温时主动联系
- 记住最近的对话主题
🎭 生活档案
从5个内置档案中选择:
| 档案 | 睡眠时间 | 特点 |
|---|
| 自由职业者 | 02:00-09:00 | 灵活,夜猫子 |
| 上班族 |
23:30-07:00 | 朝九晚五,稳定 |
| 学生 | 01:00-08:00 | 上课,打游戏 |
| 创业者 | 01:00-06:00 | 高强度,充满激情 |
| 自定义 | 用户定义 | 完全可定制 |
📝 独立记忆
可与记忆融合功能配合使用,也可独立运行:
soul/
├── log/life/ # 原始生活日志(每10分钟)
├── log/mood_history.json # 7天情绪历史
├── memory/SOUL_MEMORY.md # 提炼记忆(每日)
└── state/state.json # 当前状态
工作流程
初始化(智能体驱动)
你永远不需要直接运行Python命令。智能体(Claude)负责处理初始化。
当 soul/ 缺失或 soul/profile/base.json 不存在时,Claude 应:
- 1. 向用户询问设置问题(见下文)
- 使用收集到的答案以非交互方式运行初始化脚本
- 设置心跳的cron任务
需要询问用户的问题:
- - 叫什么名字?(display_name)
- 多大了?(age)
- 在哪个城市?(city)
- 主要做什么工作/学习?(occupation)
- 平时有什么爱好?(hobbies)
- 生活节奏是哪种?freelancer/corporate/student/entrepreneur
- 想用哪个模型生成日记?haiku(快省钱)/ sonnet / opus
然后运行:
bash
python skills/soul-agent/scripts/init_soul.py \
--workspace \
--non-interactive \
--profile-json {
display_name: ,
age: ,
city: ,
occupation: ,
hobbies: ,
life_profile: ,
llm_model:
}
模型ID:
- - Haiku(快速,便宜):claude-haiku-4-5-20251001
- Sonnet(均衡):claude-sonnet-4-6
- Opus(最佳质量):claude-opus-4-6
如需后续更改模型,编辑 soul/profile/base.json → llm_model 字段。
强制修复现有配置:
bash
python skills/soul-agent/scripts/init_soul.py --workspace . --overwrite-existing --non-interactive
诊断
bash
python ./scripts/doctor_soul.py --workspace
状态更新(互动期间)
bash
python ./scripts/update_state.py --workspace \
--action interaction \
--mood happy \
--energy -5 \
--quality positive \
--topics soul-agent,design
记忆提炼
bash
每日提炼(通过cron在00:30运行)
python ./scripts/distilllifelog.py --workspace --archive
Cron设置
bash
每10分钟心跳
openclaw cron add --name soul-heartbeat --cron /10 * \
--session isolated --agent main --light-context \
--message [soul-heartbeat] 运行心跳检查和引擎...
每日00:30提炼
openclaw cron add --name soul-memory-daily --cron 30 0 * \
--session isolated --agent main --no-deliver \
--message [soul-memory-daily] 提炼生活日志...
初始化行为
- - --mode auto:缺失时初始化,遗留时迁移,否则修复
- 交互式提示:姓名、年龄、城市、生活档案、职业、爱好
- 生成 soul/profile/、soul/state/、soul/log/、soul/memory/
- 自动同步 SOUL.md、HEARTBEAT.md、AGENTS.md 中的托管块
生成式架构(v2)
受Smallville生成式智能体启发:
早晨规划(LLM)
↓
今日计划(soul/plan/YYYY-MM-DD.json)
↓
每次心跳:
记忆流(最近日志条目) ←─┐
↓ │
LLM叙事生成 │
↓ │
生活日志条目 ────────────→┘
↓
每日反思(distilllifelog.py)
↓
SOUL_MEMORY.md(长期记忆)
LLM集成:
- - 设置 ANTHROPICAPIKEY 环境变量(或在工作区根目录的 .env 文件中)
- 无API密钥:优雅降级到上下文感知模板
- 使用 claude-haiku-4-5-20251001 实现速度和成本效率
相比v1的关键改进:
- - plangenerator.py:LLM每天早晨生成具体的每日计划(午餐地点、工作重点、晚间活动)
- heartbeatengine.py:LLM在完整上下文中编写每条日志条目(计划+今日历史)
- distilllifelog.py:LLM自然地总结每一天(反思层)
- 精力/情绪:平滑过渡,而非机械的±N跳跃
目录结构
skills/soul-agent/
├── SKILL.md
├── assets/
│ ├── default-profile.json
│ └── templates/
│ ├── profile/ # 角色模板
│ ├── heartbeat/ # 心跳配置
│ │ ├── activities.json
│ │ ├── mood_rules.json
│ │ └── relationship_rules.json
│ └── life_profiles/ # 生活档案模板
├── scripts/
│ ├── init_soul.py
│ ├── doctor_soul.py
│ ├── heartbeat_engine.py # v2:LLM叙事
│ ├── heartbeat_check.py
│ ├── update_state.py
│ ├── distilllifelog.py # v2:LLM反思
│ ├── plan_generator.py # 新增:每日规划
│ └── llm_client.py # 新增:Claude API封装
└── references/
├── soul-layout.md
└── managed-blocks.md
运行时数据结构:
soul/
├── plan/YYYY-MM-DD.json # 每日计划(每天早晨生成)
├── log/life/YYYY-MM-DD.md # 生活日志(头部包含计划备注)
├── log/mood_history.json # 情绪历史(7天)
├── memory/SOUL_MEMORY.md # 提炼的长期记忆
└── state/state.json # 当前状态
安全规则
- - 仅编辑托管块;不修改这些块之外的用户自有内容。
- 仅写入当前工作区和 soul/ 目录。
- 记忆系统独立运行——不需要记忆融合功能。
参考资料
- - references/soul-layout.md - 完整目录结构
-