co-mono/packages/mom/CHANGELOG.md
Mario Zechner e1d3c2b76e fix(mom): handle Slack msg_too_long errors gracefully
- Add try/catch to all Slack API calls in promise chain
- Truncate main channel messages at 35K with elaboration note
- Truncate thread messages at 20K
- Prevents process crash on long messages
2025-12-04 23:39:17 +01:00

7.2 KiB

Changelog

[Unreleased]

Fixed

  • Slack API errors (msg_too_long) no longer crash the process

    • Added try/catch error handling to all Slack API calls in the message queue
    • Main channel messages truncated at 35K with note to ask for elaboration
    • Thread messages truncated at 20K
    • replaceMessage also truncated at 35K
  • Private channel messages not being logged

    • Added message.groups to required bot events in README
    • Added groups:history and groups:read to required scopes in README
    • app_mention handler now logs messages directly instead of relying on message event
    • Added deduplication in ChannelStore.logMessage() to prevent double-logging

Added

  • Message backfill on startup (#103)
    • Fetches missed messages from Slack using conversations.history API when mom restarts
    • Backfills up to 3 pages (3000 messages) per channel since last logged timestamp
    • Includes mom's own responses and user messages (excludes other bots)
    • Downloads attachments from backfilled messages
    • Logs progress: channel count, per-channel message counts, total with duration

[0.10.2] - 2025-11-27

Breaking Changes

  • Timestamps now use Slack format (seconds.microseconds) and messages are sorted by ts field
    • Migration required: Run npx tsx scripts/migrate-timestamps.ts ./data to fix existing logs
    • Without migration, message context will be incorrectly ordered

Added

  • Channel and user ID mappings in system prompt
    • Fetches all channels bot is member of and all workspace users at startup
    • Mom can now reference channels by name and mention users properly
  • Skills documentation in system prompt
    • Explains custom CLI tools pattern with SKILL.md files
    • Encourages mom to create reusable tools for recurring tasks
  • Debug output: writes last_prompt.txt to channel directory with full context
  • Bash working directory info in system prompt (/ for Docker, cwd for host)
  • Token-efficient log queries that filter out tool calls/results for summaries

Changed

  • Turn-based message context instead of raw line count (#68)
    • Groups consecutive bot messages (tool calls/results) as single turn
    • "50 turns" now means ~50 conversation exchanges, not 50 log lines
    • Prevents tool-heavy runs from pushing out conversation context
  • Messages sorted by Slack timestamp before building context
    • Fixes out-of-order issues from async attachment downloads
    • Added monotonic counter for sub-millisecond ordering
  • Condensed system prompt from ~5k to ~2.7k chars
    • More concise workspace layout (tree format)
    • Clearer log query examples (conversation-only vs full details)
    • Removed redundant guidelines section
  • User prompt simplified: removed duplicate "Current message" (already in history)
  • Tool status labels (_→ label_) no longer logged to jsonl
  • Thread messages and thinking no longer double-logged

Fixed

  • Duplicate message logging: removed redundant log from app_mention handler
  • Username obfuscation in thread messages to prevent unwanted pings
    • Handles @username, bare username, and <@USERID> formats
    • Escapes special regex characters in usernames

[0.10.1] - 2025-11-27

Changed

  • Reduced tool verbosity in main Slack messages (#65)
    • During execution: show tool labels (with → prefix), thinking, and text
    • After completion: replace main message with only final assistant response
    • Full audit trail preserved in thread (tool details, thinking, text)
    • Added promise queue to ensure message updates execute in correct order

[0.10.0] - 2025-11-27

Added

  • Working memory system with MEMORY.md files
    • Global workspace memory (workspace/MEMORY.md) shared across all channels
    • Channel-specific memory (workspace/<channel>/MEMORY.md) for per-channel context
    • Automatic memory loading into system prompt on each request
    • Mom can update memory files to remember project details, preferences, and context
  • ISO 8601 date field in log.jsonl for easy date-based grepping
    • Format: "date":"2025-11-26T10:44:00.123Z"
    • Enables queries like: grep '"date":"2025-11-26' log.jsonl
  • Centralized logging system (src/log.ts)
    • Structured, colored console output (green for user messages, yellow for mom activity, dim for details)
    • Consistent format: [HH:MM:SS] [context] message
    • Type-safe logging functions for all event types
  • Usage tracking and cost reporting
    • Tracks tokens (input, output, cache read, cache write) and costs per run
    • Displays summary at end of each agent run in console and Slack thread
    • Example: 💰 Usage: 12,543 in + 847 out (5,234 cache read, 127 cache write) = $0.0234
  • Working indicator in Slack messages
    • Channel messages show "..." while mom is processing
    • Automatically removed when work completes
  • Improved stop command behavior
    • Separate "Stopping..." message that updates to "Stopped" when abort completes
    • Original working message continues to show tool results (including abort errors)
    • Clean separation between status and results

Changed

  • Enhanced system prompt with clearer directory structure and path examples
  • Improved memory file path documentation to prevent confusion
  • Message history format now includes ISO 8601 date for better searchability
  • System prompt now includes log.jsonl format documentation with grep examples
  • System prompt now includes current date and time for date-aware operations
  • Added efficient log query patterns using jq to prevent context overflow
  • System prompt emphasizes limiting NUMBER of messages (10-50), not truncating message text
  • Log queries now show full message text and attachments for better context
  • Fixed jq patterns to handle null/empty attachments with (.attachments // [])
  • Recent messages in system prompt now formatted as TSV (43% token savings vs raw JSONL)
  • Enhanced security documentation with prompt injection risk warnings and mitigations
  • Moved recent messages from system prompt to user message for better prompt caching
    • System prompt is now mostly static (only changes when memory files change)
    • Enables Anthropic's prompt caching to work effectively
    • Significantly reduces costs on subsequent requests
  • Switched from Claude Opus 4.5 to Claude Sonnet 4.5 (~40% cost reduction)
  • Tool result display now extracts actual text instead of showing JSON wrapper
  • Slack thread messages now show cleaner tool call formatting with duration and label
  • All console logging centralized and removed from scattered locations
  • Agent run now returns { stopReason } instead of throwing exceptions
    • Clean handling of "aborted", "error", "stop", "length", "toolUse" cases
    • No more error-based control flow

Fixed

  • jq query patterns now properly handle messages without attachments (no more errors on empty arrays)

[0.9.4] - 2025-11-26

Added

  • Initial release of Mom Slack bot
  • Slack integration with @mentions and DMs
  • Docker sandbox mode for isolated execution
  • Bash tool with full shell access
  • Read, write, edit file tools
  • Attach tool for sharing files in Slack
  • Thread-based tool details (clean main messages, verbose details in threads)
  • Single accumulated message per agent run
  • Stop command (@mom stop) to abort running tasks
  • Persistent workspace per channel with scratchpad directory
  • Streaming console output for monitoring