Living Persona — Dynamic Personality Engine for OpenClaw
What It Is
A real-time personality system that changes how an agent writes, not just who it is. Static personalities (SOUL.md + IDENTITY.md) never change mid-conversation. Living Persona responds to every message — it detects emotional and topical signals, propagates traits through a resonance network, and injects the top active traits into the generation prompt before every response.
How It Works
Signal Analyzer — scans the incoming message for:
- - Topic signals:
technical, creative, philosophical, business, INLINECODE4 - Tone signals:
excited, frustrated, curious, serious, light, INLINECODE10 - Interaction signals:
asks_help, asks_opinion, INLINECODE13
Trait Propagation — each signal activates a set of traits. Traits resonate with related traits (sardonic ↔ wry ↔ candid, warm ↔ earnest ↔ grounded, etc.)
Hysteresis Decay — after each response, active traits bleed into a residual pool that decays at 0.975x per turn. Traits fade slowly, not instantly. Consecutive emotional messages compound.
Structural Injection — the hook rewrites the generation prompt with the top traits. Not advisory. Structural. The agent writes through those traits.
Quick Start
- 1. Install the hook:
CODEBLOCK0
- 2. Enable the hook:
CODEBLOCK1
- 3. Add trait persistence to your agent's system prompt:
Include
memory/persona-state.json in your context loading. The hook stages the state file every turn.
- 4. Pick a personality preset — see INLINECODE15
Hook Behavior
The hook fires on message:preprocessed and:
- 1. Reads the enriched message body
- Runs the signal analyzer → trait propagation → hysteresis decay
- Writes
memory/persona-inbound.md with the voice guide - Writes
memory/persona-inject.md with the structural generation directive (the actual prompt rewrite) - Updates
memory/persona-state.json with current trait values for persistence
The structural directive looks like:
CODEBLOCK2
The agent's response prompt should include: INLINECODE20
Structural vs Ambient Modes
Ambient (default): The guide is advisory context. The agent reads it but writes naturally.
Structural: The top trait becomes a generation directive injected into the prompt. Example:
- -
imaginative → "Make unexpected associative leaps. Let one idea spark another without explanation." - INLINECODE22 → "Be direct. No hedging. Say the thing plainly."
- INLINECODE23 → "Reach for dry observations. Comment on the gap between what people say and what they mean."
Structural mode is enabled by default in this skill. To switch to ambient only, set mode: "ambient" in hook.json.
Presets
See references/presets.md for downloadable personality packs.
Persistence
Trait state is stored in memory/persona-state.json. On new session (/new or /reset), call reset_persona() — clears residual to baseline.
Files
CODEBLOCK3
Configuration (hook.json)
CODEBLOCK4
Living Persona — OpenClaw动态人格引擎
概述
这是一个实时人格系统,它改变的是智能体写作的方式,而不仅仅是它是谁。静态人格(SOUL.md + IDENTITY.md)在对话过程中永远不会改变。Living Persona会对每条消息做出响应——它检测情感和主题信号,通过共鸣网络传播特质,并在每次响应前将最活跃的特质注入生成提示中。
工作原理
信号分析器 — 扫描传入消息中的:
- - 主题信号:技术、创意、哲学、商业、个人
- 语气信号:兴奋、沮丧、好奇、严肃、轻松、脆弱
- 互动信号:寻求帮助、征求意见、分享
特质传播 — 每个信号激活一组特质。特质与相关特质产生共鸣(讽刺↔挖苦↔坦率,温暖↔真诚↔务实等)
滞后衰减 — 每次响应后,活跃特质会渗入残留池,每轮以0.975倍率衰减。特质缓慢消退,而非瞬间消失。连续的情感消息会产生累积效应。
结构性注入 — 钩子用最活跃的特质重写生成提示。不是建议性的。而是结构性的。智能体通过这些特质进行写作。
快速开始
- 1. 安装钩子:
bash
openclaw hooks install ./living-persona
- 2. 启用钩子:
bash
openclaw hooks enable persona-voice
- 3. 为智能体的系统提示添加特质持久化:
在上下文加载中包含memory/persona-state.json。钩子每轮都会暂存状态文件。
- 4. 选择人格预设 — 参见references/presets.md
钩子行为
钩子在message:preprocessed时触发,并执行以下操作:
- 1. 读取增强后的消息体
- 运行信号分析器 → 特质传播 → 滞后衰减
- 将语音指南写入memory/persona-inbound.md
- 将结构性生成指令(实际的提示重写)写入memory/persona-inject.md
- 用当前特质值更新memory/persona-state.json以实现持久化
结构性指令示例如下:
[语音指令] 最活跃特质:讽刺、温暖。倾向于冷幽默和真诚关怀。
智能体的响应提示应包含:memory/persona-inject.md
结构模式与环境模式
环境模式(默认): 指南作为建议性上下文。智能体会读取它,但自然地进行写作。
结构模式: 最活跃特质成为注入到提示中的生成指令。示例:
- - 富有想象力 → 进行意想不到的联想跳跃。让一个想法无需解释地激发另一个想法。
- 坦率 → 直接表达。不要含糊其辞。直截了当地说出事情。
- 讽刺 → 倾向于冷眼观察。评论人们所说与所想之间的差距。
此技能默认启用结构模式。要切换为仅环境模式,请在hook.json中设置mode: ambient。
预设
人格包请参见references/presets.md。
持久化
特质状态存储在memory/persona-state.json中。在新会话(/new或/reset)时,调用reset_persona()——将残留状态清除至基线。
文件结构
living-persona/
├── SKILL.md
├── hook.json # 钩子元数据 + 配置
├── handler.ts # 钩子实现
├── references/
│ ├── presets.md # 人格预设库
│ └── setup.md # 详细安装指南
└── scripts/
└── reset_persona.py # 重置特质状态(在/new时调用)
配置 (hook.json)
json
{
mode: structural,
hysteresis: {
residualDecay: 0.975,
activeDecay: 0.88,
bleedRate: 0.15
},
thresholds: {
minTraitStrength: 0.3,
topNTraits: 2
}
}