Created
October 10, 2025 13:05
-
-
Save rishabhsonker/a577569c2c0bacaa8735be810a467eed to your computer and use it in GitHub Desktop.
MEMORY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From `MEMORY.md`: | |
| **Never Decay:** | |
| - Identity facts (name, birthday) | |
| - Relationships (mom = Sarah) | |
| - Emotional anchors (breakthrough moments) | |
| **Slow Decay (with emotional protection):** | |
| - Location: 365 days half-life | |
| - Employment: 180 days half-life | |
| - Long-term goals: 90 days half-life | |
| **Medium Decay:** | |
| - Health status: 30 days half-life | |
| - Active projects: 45 days half-life | |
| **Fast Decay:** | |
| - Emotional state: 7 days half-life | |
| - Temporary location: 3 days half-life | |
| **Event-Bound (step decay):** | |
| - Event anticipation: drops to 0.1 after event occurs | |
| **Reinforcement:** | |
| - Mentioning a fact again: +0.05 confidence, resets decay clock | |
| - Emotional weight slows decay (0.9+ weight = ~no decay) | |
| #### Conflict Resolution | |
| **Philosophy:** Trust-based supersession (no awkward clarifications) | |
| ```typescript | |
| // Example conflict scenarios: | |
| // 1. Normal update (recency bias) | |
| User: "Dad's surgery is March 15" | |
| → Stores with confidence: 0.9 | |
| User: "Dad's surgery is March 29" (later) | |
| → No correction signal detected | |
| → Supersedes with confidence: 0.7 (trusts user) | |
| → Logs potential conflict for analysis | |
| // 2. Explicit correction (high confidence) | |
| User: "Dad's surgery is March 15" | |
| User: "Wait, actually it's March 22 - I got the date wrong" | |
| → Detects "wait" + "actually" = EXPLICIT CORRECTION | |
| → Supersedes immediately with confidence: 1.0 | |
| ``` | |
| **Strategy:** | |
| - 100% trust-based supersession (new replaces old by default) | |
| - High confidence (1.0) when explicit correction signals detected | |
| - Medium confidence (0.7) when no correction (recency bias) | |
| - Background conflict logging for future improvements | |
| - No interrupting conversation to ask clarifying questions | |
| #### Cold Start: Chat-Based Onboarding | |
| **Problem:** New users have zero memory. Need to bootstrap naturally without forms. | |
| **Solution:** 3 pre-defined questions (30-60 seconds): | |
| ```typescript | |
| const ONBOARDING_QUESTIONS = [ | |
| { | |
| id: 'opening', | |
| question: "Hey! What's on your mind?", | |
| purpose: 'Current emotional state + active concerns', | |
| }, | |
| { | |
| id: 'people', | |
| question: (entities) => `Who's ${entities[0]}?`, | |
| purpose: 'Clarify relationships, build entity graph', | |
| }, | |
| { | |
| id: 'context', | |
| question: "Anything else I should know?", | |
| purpose: 'Fill gaps, understand intent', | |
| } | |
| ]; | |
| ``` | |
| **Example:** | |
| ``` | |
| him: "Hey! What's on your mind?" | |
| user: "My mom's having surgery tomorrow and I'm freaking out" | |
| him: "That's a lot to be carrying. Who's your mom—tell me about her?" | |
| user: "Sarah, she's 68. Getting a hip replacement. She's always been so independent." | |
| him: "Okay, I've got it—Sarah's surgery, you're anxious. I'm here too. What do you need?" | |
| ``` | |
| **Result:** 3-5 entities, 1-2 concerns, emotional baseline, all from natural conversation. | |
| #### Context Assembly Pipeline | |
| **Token Budget Breakdown:** | |
| ``` | |
| Minimal Start (~1,500 tokens): | |
| - System identity: 500 tokens (HIM.md persona) | |
| - Thread summary: 400 tokens | |
| - Recent messages: 600 tokens | |
| + Tool Retrievals (~500-1,000 tokens): | |
| - search_memories(query, limit=3): ~200 tokens | |
| - get_entity_context(entity): ~150 tokens | |
| - search_emotions(query): ~200 tokens | |
| - get_thread_context(keywords): ~300 tokens | |
| + "him" Memory (~150 tokens): | |
| - Personality state: 40 tokens (formality, trust, directness) | |
| - Top observations: 60 tokens (3-5 patterns) | |
| - Shared moment: 50 tokens (conditional) | |
| Total: ~2,150-2,650 tokens (optimal) | |
| ``` | |
| **Performance Targets:** | |
| - Response latency: <2s total | |
| - Time to first token: ~410ms | |
| - Context assembly: <500ms | |
| - Memory retrieval: <200ms | |
| - Cache hit rate: 78%+ (Redis) | |
| #### Proactive Engagement | |
| **Session-Aware:** | |
| - New session detection (>30 min gap) | |
| - ONE proactive message per session | |
| - Based on external events + observed patterns | |
| - Examples: "How did the interview go yesterday?" | |
| **Triggers:** | |
| - Event follow-up: 1 day after scheduled event | |
| - Commitment check-in: on due date | |
| - Resource share: after 3+ mentions of interest | |
| **Rules:** | |
| - ✅ Natural timing, contextual relevance | |
| - ✅ User can dismiss/ignore without pressure | |
| - ❌ Never mid-conversation | |
| - ❌ Never multiple per session | |
| #### Background Processing | |
| **Event-Driven Observation Extraction:** | |
| Triggers: | |
| - Emotional spike (weight >0.7): extract immediately, 6h cooldown | |
| - Pattern repetition (same entity 3+ times): 24h cooldown | |
| - Milestones (10, 50, 100, 500, 1000 messages): once per milestone | |
| - Time-based: weekly comprehensive extraction | |
| **Cost:** ~$0.002/user/month (~3 extractions/month) | |
| **Personality Evolution (weekly job):** | |
| ```typescript | |
| // Gradual evolution over time | |
| formality_level: 0.7 → 0.3 (decrease 0.05/week) | |
| trust_level: 0.3 → 0.9 (increase 0.05/week) | |
| directness_level: 0.5 → 0.8 (increase 0.03/week) | |
| // Relationship stage advancement: | |
| early → building_trust (trust >0.5) | |
| building_trust → deep_connection (trust >0.7) | |
| deep_connection → mature (trust >0.9) | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment