feat: Last Prompt shows full prompt with evil mode awareness

- discord_bridge before_agent_starts now checks evil_mode from
  working_memory to load the correct personality files:
  Normal: miku_lore/prompt/lyrics + /app/moods/{mood}.txt
  Evil: evil_miku_lore/prompt/lyrics + /app/moods/evil/{mood}.txt
- Reads files directly instead of relying on cross-plugin working_memory
- cat_client.query() returns (response, full_prompt) tuple
- Full prompt includes system prefix + recalled memories + conversation
- API /prompt/cat returns full_prompt field
This commit is contained in:
2026-03-01 01:17:06 +02:00
parent a0a16e6784
commit 892edf5564
7 changed files with 129 additions and 23 deletions

View File

@@ -107,7 +107,7 @@ class CatAdapter:
author_name: Optional[str] = None,
mood: Optional[str] = None,
response_type: str = "dm_response",
) -> Optional[str]:
) -> Optional[tuple]:
"""
Send a message through the Cat pipeline via WebSocket and get a response.
@@ -125,7 +125,8 @@ class CatAdapter:
response_type: Type of response context
Returns:
Cat's response text, or None if Cat is unavailable (caller should fallback)
Tuple of (response_text, full_prompt) on success, or None if Cat
is unavailable (caller should fallback to query_llama)
"""
if not globals.USE_CHESHIRE_CAT:
return None
@@ -175,6 +176,7 @@ class CatAdapter:
# Cat may send intermediate messages (chat_token for streaming,
# notification for status updates). We want the final "chat" one.
reply_text = None
full_prompt = ""
deadline = asyncio.get_event_loop().time() + self._timeout
while True:
@@ -212,8 +214,9 @@ class CatAdapter:
msg_type = msg.get("type", "")
if msg_type == "chat":
# Final response — extract text
# Final response — extract text and full prompt
reply_text = msg.get("content") or msg.get("text", "")
full_prompt = msg.get("full_prompt", "")
break
elif msg_type == "chat_token":
# Streaming token — skip, we wait for final
@@ -232,7 +235,7 @@ class CatAdapter:
if reply_text and reply_text.strip():
self._consecutive_failures = 0
logger.info(f"🐱 Cat response for {cat_user_id}: {reply_text[:100]}...")
return reply_text
return reply_text, full_prompt
else:
logger.warning("Cat returned empty response via WS")
self._consecutive_failures += 1