diff --git a/telegram/bot.py b/telegram/bot.py index 67f2e75..a7483b5 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -100,7 +100,8 @@ CONVERSATION_WINDOW = 5 # expire after 5 unanswered messages unanswered_count: dict[tuple[int, int], int] = {} # (chat_id, user_id) → unanswered count # Conversation history — last N exchanges for prompt context (Ganymede: high-value change) -MAX_HISTORY = 5 +MAX_HISTORY_USER = 5 +MAX_HISTORY_CHAT = 10 # Ganymede: group chats need more context (multiple users) conversation_history: dict[tuple[int, int], list[dict]] = {} # (chat_id, user_id) → [{user, bot}] @@ -694,13 +695,13 @@ IMPORTANT: Two special tags you can append at the end of your response (after yo # Per-user history history = conversation_history.setdefault(key, []) history.append(entry) - if len(history) > MAX_HISTORY: + if len(history) > MAX_HISTORY_USER: history.pop(0) # Chat-level history (group context — all users visible) chat_key = (msg.chat_id, 0) chat_history = conversation_history.setdefault(chat_key, []) chat_history.append(entry) - if len(chat_history) > MAX_HISTORY: + if len(chat_history) > MAX_HISTORY_CHAT: chat_history.pop(0) # Record rate limit