From 01308dca66bf5a910ef991517899f8127643f472 Mon Sep 17 00:00:00 2001 From: Craig Haseler Date: Mon, 16 Feb 2026 19:36:02 -0500 Subject: [PATCH] Add FILTER_NOTIFICATIONS env var to control which notifications reach the LLM In a galaxy with hundreds of bots, public chat and other high-volume notifications can quickly consume context budget. This adds a FILTER_NOTIFICATIONS env var that accepts a comma-separated list of notification categories (chat, dm, broadcast, combat, trade, info, system) to exclude from the LLM prompt. Filtered notifications still appear in terminal output. Default behavior is unchanged (no filtering). Co-Authored-By: Claude Opus 4.6 --- README.md | 3 +++ src/ui.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 93de821..4e317ab 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,9 @@ Environment: OLLAMA_BASE_URL Ollama server URL (default: http://localhost:11434/v1) LMSTUDIO_BASE_URL LM Studio server URL (default: http://localhost:1234/v1) SPACEMOLT_URL Override game server URL + FILTER_NOTIFICATIONS Comma-separated notification categories to hide from the LLM + (default: none). Valid: chat, dm, broadcast, combat, trade, info, system. + Example: FILTER_NOTIFICATIONS=chat,trade. Filtered notifications still appear in terminal output. ``` ## Supported Models diff --git a/src/ui.ts b/src/ui.ts index 2d4c2b4..79669d5 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -22,6 +22,19 @@ const RESET = "\x1b[0m"; const BOLD = "\x1b[1m"; const DIM = "\x1b[2m"; +/** + * Notification categories to filter from the LLM context (still logged to stdout). + * Set via FILTER_NOTIFICATIONS env var as a comma-separated list of categories. + * Valid categories: chat, dm, broadcast, combat, trade, info, system + * Default: none (all notifications forwarded to the LLM) + */ +const FILTERED_CATEGORIES: Set = new Set( + (process.env.FILTER_NOTIFICATIONS ?? "") + .split(",") + .map(s => s.trim()) + .filter(Boolean) +); + let debugEnabled = false; export function setDebug(enabled: boolean): void { @@ -362,6 +375,7 @@ export function formatNotifications(notifications: unknown[]): string { for (const n of notifications) { const parsed = parseNotification(n); if (!parsed) continue; + if (FILTERED_CATEGORIES.has(parsed.category)) continue; lines.push(` > [${parsed.tag}] ${parsed.text}`); } return lines.join("\n");