5.5 KiB
Autonomous V2 Implementation Complete! ✅
What Changed
✅ Files Modified
-
utils/autonomous.py(previouslyutils/autonomous_v2.py)- Now the main autonomous system
- Uses context-aware decision engine
- Imports legacy functions from
autonomous_v1_legacy.py
-
utils/autonomous_v1_legacy.py(previouslyutils/autonomous.py)- Old autonomous system preserved as backup
- Contains all the implementation functions (still used by V2)
-
utils/autonomous_engine.py(NEW)- Core decision engine
- Tracks context signals (messages, presence, activities)
- Makes intelligent decisions without LLM calls
- Mood-aware personality profiles
-
bot.py- Added
initialize_v2_system()call inon_ready() - Added
on_message_event()hook to track every message - Added
on_presence_update()event handler - Added
on_member_join()event handler - Removed old autonomous reaction code (now handled by V2)
- Added
-
server_manager.py- Updated
_run_autonomous_for_server()to use V2 tick - Updated
_run_autonomous_reaction_for_server()to use V2 tick - Removed conversation detection scheduler (now event-driven)
- Updated
-
utils/moods.py- Added
on_mood_change()notifications inrotate_server_mood() - Added mood change notification in wake-up handler
- Added
-
api.py- Added mood change notifications to all mood-setting endpoints
- Updated
/servers/{guild_id}/mood,/servers/{guild_id}/mood/reset,/test/mood/{guild_id}
How It Works Now
Event-Driven Architecture
Before V1:
Timer (every 15 min) → 10% random chance → Action
After V2:
Message arrives → Track context → Check thresholds → Intelligent decision → Action
Context Tracking (No LLM!)
Every message/event updates lightweight signals:
- Message count (last 5 min, last hour)
- Conversation momentum (0-1 scale)
- User presence events (status changes, activities)
- Time since last action
- Current mood profile
Decision Logic
Checks in priority order:
- Join Conversation - High momentum + social mood
- Engage User - Someone started interesting activity
- FOMO Response - Lots of messages without Miku
- Break Silence - Channel quiet + energetic mood
- Share Tweet - Quiet period + appropriate mood
- React to Message - Mood-based probability
Mood Influence
Each mood has personality traits that affect decisions:
- Energy: How quickly Miku breaks silence
- Sociability: How easily she joins conversations
- Impulsiveness: How quickly she reacts to events
Examples:
- Bubbly (0.9 energy, 0.95 sociability): Joins after 5 messages, breaks 30 min silence
- Shy (0.4 energy, 0.2 sociability): Waits for 40+ messages, tolerates 50 min silence
- Asleep (0.0 all): Does nothing at all
Testing Checklist
✅ Syntax Checks Passed
autonomous_engine.py✅autonomous.py✅bot.py✅server_manager.py✅
🔄 Runtime Testing Needed
-
Start the bot - Check for initialization messages:
🚀 Initializing Autonomous V2 System... ✅ Autonomous V2 System initialized -
Send some messages - Watch for context tracking:
(No output expected - tracking is silent) -
Wait for autonomous action - Look for V2 decisions:
🤖 [V2] Autonomous engine decided to: join_conversation for server 123456 ✅ [V2] Autonomous tick queued for server 123456 -
Change mood via API - Verify mood change notification:
🎭 API: Server mood set result: True (Should see mood notification to autonomous engine) -
Monitor reactions - New messages should trigger real-time reaction checks:
🎯 [V2] Real-time reaction triggered for message from User
Rollback Plan (If Needed)
If V2 causes issues:
-
Rename files back:
cd /home/koko210Serve/docker/ollama-discord/bot/utils mv autonomous.py autonomous_v2_broken.py mv autonomous_v1_legacy.py autonomous.py -
Revert bot.py changes:
- Remove V2 imports and event handlers
- Restore old autonomous reaction code
-
Revert server_manager.py:
- Change back to
miku_autonomous_tick_for_server - Restore conversation detection scheduler
- Change back to
-
Restart bot
Performance Notes
Resource Usage
- Zero LLM calls for decisions - Only simple math on tracked metrics
- Lightweight tracking - No message content stored, just counts and timestamps
- Efficient - Event-driven, only acts when contextually appropriate
Expected Behavior Changes
- More natural timing - Won't interrupt active conversations
- Mood-consistent - Bubbly Miku is chatty, shy Miku is reserved
- Better engagement - Responds to user activities, not just timers
- Context-aware reactions - More likely to react in active chats
Next Steps
- Monitor logs for first 24 hours
- Tune thresholds if needed (in
autonomous_engine.py) - Collect feedback on behavior naturalness
- Consider future enhancements:
- Topic detection
- User affinity tracking
- Time-of-day learning
- Sentiment signals
Documentation
- Decision Logic: See
AUTONOMOUS_V2_DECISION_LOGIC.mdfor detailed examples - Comparison: See
AUTONOMOUS_V2_COMPARISON.mdfor V1 vs V2 diagrams - Migration Guide: See
AUTONOMOUS_V2_MIGRATION.mdfor implementation details
🎉 The V2 system is ready to roll! Start the bot and watch Miku become truly autonomous!