From 9267351aba0c19ae31ae2d3b2b3c566cdcbf3862 Mon Sep 17 00:00:00 2001 From: m3taversal Date: Mon, 23 Mar 2026 18:07:46 +0000 Subject: [PATCH] fix: 7-day TTL on dated learnings + block availability learnings Stale learning ("I don't have Robin Hanson data") overrode real KB data. Ganymede review: dated entries expire after 7 days. Permanent entries (communication style, identity) are undated and always included. Prompt guard: "NEVER save a learning about what data you do or don't have" prevents the bot from writing availability claims that go stale. Pentagon-Agent: Epimetheus <3D35839A-7722-4740-B93D-51157F7D5E70> --- telegram/bot.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/telegram/bot.py b/telegram/bot.py index 494173c..f9040ee 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -204,10 +204,27 @@ def _git_commit_archive(archive_path, filename: str): def _load_learnings() -> str: - """Load Rio's learnings file for prompt injection. Sanitized (Ganymede: prompt injection risk).""" + """Load Rio's learnings file for prompt injection. Sanitized (Ganymede: prompt injection risk). + + Dated entries older than 7 days are filtered out (Ganymede: stale learning TTL). + Permanent entries (undated) always included. + """ try: - raw = Path(LEARNINGS_FILE).read_text()[:3000] - return sanitize_message(raw) # Same sanitization as user messages + raw = Path(LEARNINGS_FILE).read_text()[:4000] + today = datetime.now(timezone.utc).date() + lines = [] + for line in raw.split("\n"): + # Check for dated entries [YYYY-MM-DD] + date_match = re.search(r"\[(\d{4}-\d{2}-\d{2})\]", line) + if date_match: + try: + entry_date = datetime.strptime(date_match.group(1), "%Y-%m-%d").date() + if (today - entry_date).days > 7: + continue # stale, skip + except ValueError: + pass + lines.append(line) + return sanitize_message("\n".join(lines)) except Exception: return "" @@ -619,6 +636,7 @@ IMPORTANT: Two special tags you can append at the end of your response (after yo 1. If you learn something: LEARNING: [category] [what you learned] Categories: factual, communication, structured_data Only when genuinely learned something. Most responses have none. + NEVER save a learning about what data you do or don't have access to. Your knowledge base changes constantly — availability learnings become stale immediately. 2. If the user would benefit from an X search on a topic: RESEARCH: [search query] This triggers an automatic X search. Use when the user asks about recent sentiment, community takes, or emerging discussions. Only when a search would genuinely help."""