Fix Miku confusing who said what in conversations
Three interrelated fixes for speaker attribution confusion: 1. Fix misleading episodic memory header (discord_bridge.py): The Cat core hardcodes '## Context of things the Human said in the past:' when formatting recalled conversations. Our plugins store BOTH user messages ([User]: prefix) AND Miku's own responses ([Miku]: prefix) in episodic memory. This misleading header primes the LLM to attribute Miku's words to the user. Replaced with '## Past conversation excerpts (prefixed by who said what):' which accurately describes the mixed-speaker content. 2. Tighten episodic recall (discord_bridge.py): Added before_cat_recalls_episodic_memories hook setting threshold=0.75 (vs default 0.7) to reduce the chance of Miku's own just-uttered response being recalled on the very next user message, which would feed her own words back as misleading context. 3. Add role clarification (miku_personality.py & evil_miku_personality.py): Added a clarifying note after '# Conversation until now:' in the prompt suffix to explicitly tell the model that 'Human = the user, AI = you (Miku)', helping it reconcile the two labeling systems (episodic [User]/[Miku] prefixes vs conversation history Human/AI roles).
This commit is contained in:
@@ -160,6 +160,31 @@ def before_cat_recalls_declarative_memories(declarative_recall_config, cat):
|
||||
return declarative_recall_config
|
||||
|
||||
|
||||
@hook(priority=80)
|
||||
def before_cat_recalls_episodic_memories(episodic_recall_config, cat):
|
||||
"""
|
||||
Keep episodic recall focused to prevent Miku's own responses from being
|
||||
immediately recalled into context on the very next user message.
|
||||
|
||||
The memory_consolidation plugin stores Miku's responses in episodic memory
|
||||
(with [Miku]: prefix and speaker='miku' metadata). Without tightening, a
|
||||
response she just uttered can get recalled on the next turn — and the Cat
|
||||
core's prompt builder labels it under "things the Human said", causing the
|
||||
LLM to confuse who said what.
|
||||
|
||||
Default Cat settings (k=3, threshold=0.7) are reasonable; we keep them.
|
||||
"""
|
||||
# k=3 is the default — stays tight
|
||||
# threshold=0.75 is very slightly stricter than the 0.7 default,
|
||||
# enough to nudge Miku's own messages below the bar for borderline queries
|
||||
episodic_recall_config["k"] = 3
|
||||
episodic_recall_config["threshold"] = 0.75
|
||||
|
||||
print(f"🔧 [Discord Bridge] Adjusted episodic recall: k={episodic_recall_config['k']}, threshold={episodic_recall_config['threshold']}")
|
||||
|
||||
return episodic_recall_config
|
||||
|
||||
|
||||
@hook(priority=50)
|
||||
def after_cat_recalls_memories(cat):
|
||||
"""
|
||||
@@ -220,6 +245,20 @@ def before_agent_starts(agent_input, cat) -> dict:
|
||||
tools_output = agent_input.get('tools_output', '')
|
||||
user_input = agent_input.get('input', '')
|
||||
|
||||
# Fix misleading header in episodic memory context.
|
||||
# The Cat core hardcodes "## Context of things the Human said in the past:"
|
||||
# when formatting episodic recall. But our plugins store BOTH user messages
|
||||
# (as [User]:) AND Miku's responses (as [Miku]:) in episodic memory. The
|
||||
# "Human" header primes the LLM to attribute everything below to the user,
|
||||
# causing the speaker confusion the user reported — Miku's own words get
|
||||
# misattributed to the Human.
|
||||
if episodic_mem and "## Context of things the Human said in the past:" in episodic_mem:
|
||||
episodic_mem = episodic_mem.replace(
|
||||
"## Context of things the Human said in the past:",
|
||||
"## Past conversation excerpts (prefixed by who said what):"
|
||||
)
|
||||
agent_input['episodic_memory'] = episodic_mem
|
||||
|
||||
print(f"\U0001f50d [Discord Bridge] before_agent_starts called")
|
||||
print(f" input: {user_input[:80]}")
|
||||
print(f" declarative_mem length: {len(declarative_mem)}")
|
||||
|
||||
@@ -114,7 +114,8 @@ def agent_prompt_suffix(suffix, cat):
|
||||
|
||||
[Current mood: {mood_name.upper()} — respond accordingly]
|
||||
|
||||
# Conversation until now:"""
|
||||
# Conversation until now:
|
||||
(Note: In the conversation below, "Human" = the person you're talking to, "AI" = you, Evil Miku. Pay attention to who said what.)"""
|
||||
|
||||
|
||||
@hook(priority=100)
|
||||
|
||||
@@ -86,7 +86,8 @@ def agent_prompt_suffix(suffix, cat):
|
||||
|
||||
{tools_output}
|
||||
|
||||
# Conversation until now:"""
|
||||
# Conversation until now:
|
||||
(Note: In the conversation below, "Human" = the person you're talking to, "AI" = you, Miku. Pay attention to who said what.)"""
|
||||
|
||||
|
||||
@hook(priority=100)
|
||||
|
||||
Reference in New Issue
Block a user