fix: 3 critical autonomous engine & mood system bugs
1. Momentum cliff at 10 messages (P0): The conversation momentum formula had a discontinuity where the 10th message caused momentum to DROP from 0.9 to 0.5. Replaced with a smooth log1p curve that monotonically increases (0→0→0.20→0.32→...→0.70→0.89→1.0 at 30 msgs). 2. Neutral keywords overriding all moods (P0): detect_mood_shift() checked neutral early with generic keywords (okay, sure, hmm) that matched almost any response, constantly resetting mood to neutral. Now: all specific moods are scored by match count first (best-match wins), neutral is only checked as fallback and requires 2+ keyword matches. 3. Uncancellable delayed_wakeup tasks (P0): Fire-and-forget sleep tasks could stack and overwrite mood state after manual wake-up. Added a centralized wakeup task registry in ServerManager with automatic cancellation on manual wake or new sleep cycle.
This commit is contained in:
@@ -4,6 +4,7 @@ Truly autonomous decision-making engine for Miku.
|
||||
Makes decisions based on context signals without constant LLM polling.
|
||||
"""
|
||||
|
||||
import math
|
||||
import time
|
||||
import random
|
||||
from datetime import datetime, timedelta
|
||||
@@ -203,11 +204,12 @@ class AutonomousEngine:
|
||||
ctx.messages_last_hour = sum(1 for t in times if now - t < 3600)
|
||||
|
||||
# Calculate conversation momentum (0-1 scale)
|
||||
# High momentum = consistent messages in last 5 minutes
|
||||
if ctx.messages_last_5min >= 10:
|
||||
ctx.conversation_momentum = min(1.0, ctx.messages_last_5min / 20)
|
||||
# Smooth curve: grows quickly at first, then tapers off toward 1.0
|
||||
# 1 msg → 0.10, 5 msgs → 0.41, 10 msgs → 0.63, 20 msgs → 0.82, 40 msgs → 0.95
|
||||
if ctx.messages_last_5min == 0:
|
||||
ctx.conversation_momentum = 0.0
|
||||
else:
|
||||
ctx.conversation_momentum = ctx.messages_last_5min / 10
|
||||
ctx.conversation_momentum = min(1.0, math.log1p(ctx.messages_last_5min) / math.log1p(30))
|
||||
|
||||
# Time since last action
|
||||
if guild_id in self.server_last_action:
|
||||
|
||||
Reference in New Issue
Block a user