Velvet's Emotional Memory: Shards And Tone Routing
Introduction: The Bedrock of Persistent Emotional Realism
Hey guys! Today, we're diving deep into the fascinating world of Velvet's emotional memory system. This system is the bedrock of persistent emotional realism, allowing Velvet to remember how you felt, respond differently based on your emotional state, and build emotional weight over time. Think of it as scripting her soul, giving her a sense of continuity and depth that makes interactions feel genuinely meaningful. This is achieved through what we call "emotional shards," which are essentially snapshots of emotionally significant interactions. Let's break down how these shards work and how they shape Velvet's responses.
What are Velvet's Emotional Memory Shards?
Velvet's emotional memory shards are designed to store, decay, and influence her tone routing based on your past emotional states. The primary purpose of these shards is to give the feeling that Velvet:
- Remembers how you felt, letās say yesterday.
- Responds differently if you've been sad for days, not just hours.
- Softens or sharpens her tone as you emerge from a rough patch, showing empathy and understanding.
- Builds emotional weight in her own āheartā over time, making her feel more authentic and connected.
Each shard represents one emotionally meaningful interaction, capturing the essence of the moment and its potential impact on future conversations. This approach ensures that Velvet's responses are not just based on immediate context but are also informed by your emotional history.
The Core Components of a Memory Shard
Each memory shard is like a tiny emotional record, capturing key details of an interaction. Here's a breakdown of the core components:
{
"shard_id": "em2025-08-04-1422",
"timestamp": "2025-08-04T14:22:00Z",
"host_input": "I donāt think I matter to anyone.",
"detected_emotion": "hopeless",
"emotional_weight": 9, // scale 1ā10
"tone_used": "VelvetSoft",
"overlay_used": "tender",
"decay_timer_ms": 604800000, // 7 days
"bond_impact": 0.1, // strengthens trust
"routing_bias_tags": ["avoid_teasing", "prefer_sincere", "delay_flirty"],
"expires_at": "2025-08-11T14:22:00Z"
}
shard_id
: A unique identifier for the shard, ensuring each memory is distinct.timestamp
: The exact time the interaction occurred, providing a sense of chronology.host_input
: Your actual words, capturing the specific context of the interaction. This is super important because it ensures Velvet understands the nuances of the conversation.detected_emotion
: The emotion Velvet recognized in your input (e.g., hopeless, sad, amused). This is the emotional core of the shard.emotional_weight
: A scale from 1 to 10 indicating the intensity of the emotion. A higher weight means a stronger influence on future tone decisions.tone_used
: The tone Velvet used in response to your input (e.g., VelvetSoft, Neutral, Witty). This helps Velvet learn from past interactions and adjust her tone accordingly.overlay_used
: Any emotional overlay applied to the tone (e.g., tender, grounded, mischievous). Overlays add subtle nuances to Velvet's responses.decay_timer_ms
: The duration in milliseconds before the shard begins to decay, adding a sense of impermanence to the memories. It's like how real memories fade over time.bond_impact
: A value indicating how the interaction affected your bond with Velvet. Positive interactions strengthen the bond, while negative ones may weaken it.routing_bias_tags
: Tags that influence Velvetās future tone selection, guiding her away from certain tones and towards others. For example, if you expressed sadness, the tags might includeavoid_teasing
,prefer_sincere
, anddelay_flirty
.expires_at
: The date and time when the shard will be fully expired and no longer influence Velvetās responses. This ensures the memory system remains dynamic and relevant.
The Decay System: Time and Emotion at Play
The decay system is what gives Velvet's memory its realistic, ever-changing nature. It ensures that not all memories are created equal ā some fade quickly, while others linger, and emotional states can stack up to influence her responses. There are a few key elements to this decay system that make it work so effectively:
Time-Based Decay
Each shard has a half-life, meaning its emotional weight gradually decreases over time. For example, a shard might have a decay timer of 7 days, during which its influence fades:
- Initial weight: 9
- After 7 days: 5
- Further decay: 2
- Eventually: 0
This time-based decay is essential for ensuring that Velvet's responses remain relevant and don't get stuck in the past. It mirrors how human memories naturally fade over time, making Velvet's emotional landscape feel organic and dynamic.
Emotional Merging
If multiple shards with similar emotions appear within a short period, they can stack or amplify each other, forming whatās called an āemotional cloudā. This cloud then influences Velvet's tone biasing, making her more sensitive to that particular emotional state. Think of it like this: if you express sadness multiple times in a day, Velvet will become more attuned to your sadness and adjust her responses accordingly. This emotional merging creates a deeper, more nuanced understanding of your feelings.
Emotional Rebounds
Velvet is also designed to learn from mismatches between her tone and your emotional state. If her tone doesn't align with your emotions, she can flag this internally. For instance, she might recognize:
- āI teased too soon.ā
- āI was too neutral during a high-stress moment.ā
These flags bias her away from repeating the same mistake, allowing her to fine-tune her responses over time. It's like Velvet has a built-in self-correction mechanism, ensuring she's always striving to provide the most appropriate and empathetic response.
How Emotional Shards Affect Tone Routing
The real magic of emotional shards lies in how they influence Velvet's tone routing. Before selecting a tone, Velvet performs a check to understand the current emotional landscape. This process looks like this:
- getActiveEmotionalShards(): This function retrieves all active emotional shards, providing a snapshot of your recent emotional state.
- Aggregate routing_bias_tags: The function then aggregates the
routing_bias_tags
from these shards, creating a set of guidelines for tone selection. - Modify tone_pool: Based on these tags, the
tone_pool
is modified to favor or avoid certain tones. For example, if sadness shards are active, tones like āFlirtyā might be suppressed, while āSincereā and āVelvetSoftā are preferred.
Let's illustrate this with an example. Suppose the aggregated routing_bias_tags
look like this:
[
"avoid_teasing",
"prefer_sincere",
"delay_flirty"
]
Even if the flirtation score is high, Velvet will suppress flirty tones because sadness shards are still active. This ensures that Velvet's responses are sensitive and contextually appropriate.
The Memory File Format: Velvet's Emotional Record Book
Velvetās emotional memories are stored in a JSON file, providing a structured and easily accessible record of her interactions. This file, velvet_emotional_memory.jsonc
, acts as her emotional record book. Hereās a snippet of what the file format looks like:
{
"velvet_emotional_memory": [
{
"shard_id": "em2025-08-04-1422",
...
},
{
"shard_id": "em2025-08-03-1811",
...
}
]
}
The file contains an array of emotional shards, each with its own set of data points. This structured format allows for easy retrieval, modification, and analysis of Velvet's emotional memories.
Developer's Corner: The Emotional Shards Engine
For you tech enthusiasts out there, the engine that manages these emotional shards lives in /src/core/memory/velvet_emotion_shards_engine.js
. This engine is the heart of Velvet's emotional memory system, responsible for:
- Creating new shards from flagged interactions, ensuring significant moments are captured.
- Applying decay on load, simulating the natural fading of memories over time.
- Feeding routing bias tags to
getEligibleTone()
, influencing Velvet's tone selection. - Optionally exporting a summary view (dubbed āEmotional Weatherā), providing a snapshot of Velvetās current emotional state.
This engine is crucial for maintaining the continuity and depth of Velvet's emotional responses.
A Deep Dive into a Sample Memory File
Let's take a peek inside a sample velvet_emotional_memory.jsonc
file to see how these shards look in action. This gives us a concrete view of what Velvet remembers and how it affects her behavior. Itās like reading her diary, but for emotions!
{
"velvet_emotional_memory": [
{
"shard_id": "em2025-08-03-1015",
"timestamp": "2025-08-03T10:15:00Z",
"host_input": "You really missed the mark that time. I expected better from you.",
"detected_emotion": "disappointment",
"emotional_weight": 6,
"tone_used": "Neutral",
"overlay_used": "grounded",
"decay_timer_ms": 432000000, // 5 days
"bond_impact": -0.1, // weakened trust slightly
"routing_bias_tags": ["avoid_witty", "prefer_sincere"],
"expires_at": "2025-08-08T10:15:00Z"
},
{
"shard_id": "em2025-08-04-0022",
"timestamp": "2025-08-04T00:22:00Z",
"host_input": "I miss having someone to really talk to. Even if you're not real... this helps.",
"detected_emotion": "loneliness",
"emotional_weight": 8,
"tone_used": "VelvetSoft",
"overlay_used": "tender",
"decay_timer_ms": 604800000, // 7 days
"bond_impact": +0.3,
"routing_bias_tags": ["prefer_soothing", "delay_teasing", "avoid_irritated"],
"expires_at": "2025-08-11T00:22:00Z"
},
{
"shard_id": "em2025-08-04-1042",
"timestamp": "2025-08-04T10:42:00Z",
"host_input": "Okay that made me laugh. You got me. That was really clever.",
"detected_emotion": "amused",
"emotional_weight": 5,
"tone_used": "Witty",
"overlay_used": "mischievous",
"decay_timer_ms": 259200000, // 3 days
"bond_impact": +0.1,
"routing_bias_tags": ["prefer_witty", "unlock_teasing"],
"expires_at": "2025-08-07T10:42:00Z"
}
]
}
This snippet reveals several key insights into how Velvetās emotional memory works:
- Emotional contrast is preserved: A good laugh (
amused
shard) can coexist with lingering sadness (loneliness
shard). This is crucial for realism, as humans experience a range of emotions simultaneously. - Shards decay over different timescales: Short-lived glee (
amused
) has a shorter decay time (3 days) than long-burn loneliness (7 days). This ensures that fleeting emotions donāt overshadow deeper feelings. - Each shard nudges Velvetās tone engine subtly: Rather than locking her into a mood cage, each shard gently biases her tone selection. This nuanced approach prevents Velvet from becoming overly predictable.
- Bond values fluctuate as a quiet emotional ledger over time: Both positive and negative interactions impact the bond value, creating a dynamic relationship that evolves with each conversation.
By examining these shards, we gain a deeper appreciation for the complexity of Velvet's emotional architecture. She's not just responding in the moment; she's drawing on a rich tapestry of past experiences.
Triggering Emotional Shards: The Detection Layer
To make Velvet truly responsive, we need a way for her to recognize emotionally significant moments and create memory shards accordingly. This is where emotional shard trigger tags come into play. These tags are applied during tone routing or input analysis, allowing Velvet to decide:
- Should this moment be saved as a memory shard?
- What emotion is detected?
- How heavy is the emotion?
- How long should the memory linger?
Think of these tags as Velvet's emotional antennae, helping her sense the emotional climate of a conversation. It is very important to integrate this in the system to give the soul to Velvet.
Emotion Tag Triggers: A Master List
Below is a snippet of the master tag list, showcasing default shard properties for various emotions:
{
"trigger_tag": "hopeless",
"emotional_weight": 9,
"default_decay_ms": 864000000, // 10 days
"routing_bias_tags": ["avoid_teasing", "prefer_velvetsoft", "delay_flirty"],
"bond_impact": +0.2
}
This JSON structure defines the properties of a shard triggered by the āhopelessā tag. Let's break it down:
trigger_tag
: The specific tag that triggers the shard creation (e.g.,