Files
miku-discord/readmes/AUTONOMOUS_V2_COMPARISON.md

13 KiB

Autonomous System Comparison

V1 (Current) vs V2 (Proposed)

┌─────────────────────────────────────────────────────────────────────┐
│                          V1 SYSTEM (Current)                         │
└─────────────────────────────────────────────────────────────────────┘

    ⏰ Timer (every 15 min)
         │
         ├──> 🎲 Random roll (10% chance)
         │         │
         │         ├──> ❌ No action (90% of time)
         │         │
         │         └──> ✅ Take action
         │                  │
         │                  ├──> 🎲 Random pick: general/engage/tweet
         │                  │
         │                  └──> 🤖 Call LLM to generate content
         │
         └──> ⏰ Wait 15 min, repeat

    Problems:
    ❌ No awareness of channel state
    ❌ Might speak to empty room
    ❌ Might interrupt active conversation
    ❌ Mood doesn't affect timing/frequency
    ❌ Wastes 90% of timer ticks


┌─────────────────────────────────────────────────────────────────────┐
│                          V2 SYSTEM (Proposed)                        │
└─────────────────────────────────────────────────────────────────────┘

    📨 Events (messages, presence, status)
         │
         ├──> 📊 Update Context Signals (lightweight, no LLM)
         │      │
         │      ├─> Message count (5 min, 1 hour)
         │      ├─> Conversation momentum
         │      ├─> User presence changes
         │      ├─> Time since last action
         │      └─> Current mood profile
         │
         └──> 🧠 Decision Engine (simple math, no LLM)
                  │
                  ├──> Check thresholds:
                  │     ├─> Conversation momentum > X?
                  │     ├─> Messages since appearance > Y?
                  │     ├─> Time since last action > Z?
                  │     ├─> Mood energy/sociability score?
                  │     └─> User events detected?
                  │
                  ├──> ❌ No action (most of the time)
                  │
                  └──> ✅ Take action (when context is right)
                           │
                           ├──> 🎯 Pick action based on context
                           │     ├─> High momentum → join conversation
                           │     ├─> User activity → engage user
                           │     ├─> FOMO triggered → general message
                           │     ├─> Long silence → break silence
                           │     └─> Quiet + curious → share tweet
                           │
                           └──> 🤖 Call LLM to generate content


    Benefits:
    ✅ Context-aware decisions
    ✅ Mood influences behavior
    ✅ Responds to social cues
    ✅ No wasted cycles
    ✅ Zero LLM calls for decisions


┌─────────────────────────────────────────────────────────────────────┐
│                        MOOD INFLUENCE EXAMPLE                        │
└─────────────────────────────────────────────────────────────────────┘

    Bubbly Miku (energy: 0.9, sociability: 0.95, impulsiveness: 0.8)
    ┌─────────────────────────────────────────────────────────┐
    │  Channel Activity Timeline                              │
    ├─────────────────────────────────────────────────────────┤
    │  [5 messages] ────────> Miku joins! (low threshold)     │
    │  [quiet 20 min] ─────> "Anyone here? 🫧"                │
    └─────────────────────────────────────────────────────────┘
    

    Shy Miku (energy: 0.4, sociability: 0.2, impulsiveness: 0.2)
    ┌─────────────────────────────────────────────────────────┐
    │  Channel Activity Timeline                              │
    ├─────────────────────────────────────────────────────────┤
    │  [5 messages] ────────> ... (waits)                     │
    │  [15 messages] ───────> ... (still hesitant)            │
    │  [40 messages] ───────> "Um... hi 👉👈" (finally joins) │
    │  [quiet 2 hours] ─────> ... (doesn't break silence)    │
    └─────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────────┐
│                      RESOURCE USAGE COMPARISON                       │
└─────────────────────────────────────────────────────────────────────┘

    V1 System (per hour):
    ┌──────────────────────────────────────────────────┐
    │  Timer checks: 4 (every 15 min)                  │
    │  Actions taken: ~0.4 (10% of 4)                  │
    │  LLM calls: ~0.4 (only when action taken)        │
    │  Wasted cycles: 3.6 (90% of time)                │
    │  Context awareness: 0 🚫                         │
    └──────────────────────────────────────────────────┘

    V2 System (per hour, typical server):
    ┌──────────────────────────────────────────────────┐
    │  Message events: ~50 (passive tracking)          │
    │  Presence events: ~10 (passive tracking)         │
    │  Decision checks: ~60 (lightweight math)         │
    │  Actions taken: ~0.5-2 (context-dependent)       │
    │  LLM calls: ~0.5-2 (only when action taken)      │
    │  Wasted cycles: 0 ✅                             │
    │  Context awareness: Real-time 🎯                 │
    └──────────────────────────────────────────────────┘

    Key Difference:
    V1: Blind random chance, no context
    V2: Smart decisions, full context, same LLM usage


┌─────────────────────────────────────────────────────────────────────┐
│                      DECISION FLOW EXAMPLE                           │
└─────────────────────────────────────────────────────────────────────┘

    Scenario: Active gaming chat, Miku is "excited" mood

    1. Message arrives: "Just beat that boss!"
       └─> Engine: track_message() → momentum = 0.7

    2. Check decision:
       ┌────────────────────────────────────────────┐
       │ conversation_momentum = 0.7                │
       │ threshold (excited) = 0.6 * (2-0.9) = 0.66 │
       │ 0.7 > 0.66 ✅                              │
       │                                            │
       │ messages_since_appearance = 8              │
       │ 8 >= 5 ✅                                  │
       │                                            │
       │ time_since_last_action = 450s              │
       │ 450 > 300 ✅                               │
       │                                            │
       │ random() < impulsiveness (0.9)             │
       │ 0.43 < 0.9 ✅                              │
       │                                            │
       │ DECISION: join_conversation ✅             │
       └────────────────────────────────────────────┘

    3. Execute action:
       └─> Call existing miku_detect_and_join_conversation_for_server()
           └─> LLM generates contextual response
               └─> "Wahaha! That boss was tough! What did you think of the music? 🎵✨"

    4. Record action:
       └─> Reset messages_since_appearance = 0
           └─> Update time_since_last_action


┌─────────────────────────────────────────────────────────────────────┐
│                           MIGRATION PATH                             │
└─────────────────────────────────────────────────────────────────────┘

    Phase 1: Install V2 (parallel)
    ┌──────────────────────────────────────────────┐
    │  Keep V1 scheduler running                   │
    │  Add V2 event hooks                          │
    │  V2 tracks context but doesn't act           │
    │  Monitor logs to verify tracking works       │
    └──────────────────────────────────────────────┘

    Phase 2: Test V2 (one server)
    ┌──────────────────────────────────────────────┐
    │  Enable V2 for test server                   │
    │  Disable V1 for that server                  │
    │  Observe behavior for 24 hours               │
    │  Tune thresholds if needed                   │
    └──────────────────────────────────────────────┘

    Phase 3: Full rollout
    ┌──────────────────────────────────────────────┐
    │  Switch all servers to V2                    │
    │  Remove V1 scheduler code                    │
    │  Keep V1 code as fallback                    │
    └──────────────────────────────────────────────┘

    Phase 4: Enhance (future)
    ┌──────────────────────────────────────────────┐
    │  Add topic tracking                          │
    │  Add user affinity                           │
    │  Add sentiment signals                       │
    │  ML-based threshold tuning                   │
    └──────────────────────────────────────────────┘