Skip to content

feat(slack): add smart observe mode for monitored channels#4636

Closed
gunpowder-client-vm wants to merge 1 commit into
NousResearch:mainfrom
gunpowder-tech:feature/slack-observe-mode
Closed

feat(slack): add smart observe mode for monitored channels#4636
gunpowder-client-vm wants to merge 1 commit into
NousResearch:mainfrom
gunpowder-tech:feature/slack-observe-mode

Conversation

@gunpowder-client-vm

Copy link
Copy Markdown
Contributor

Summary

Adds a new SLACK_OBSERVE_CHANNELS mode that lets the bot monitor channels without requiring an @mention for every message. A fast LLM pre-filter decides whether to respond based on message content and recent context.

Motivation

The existing behavior (respond only when @mentioned) is fine for most channels, but some channels benefit from a bot that's always watching — surfacing complaints, answering questions, monitoring for specific keywords — without requiring users to explicitly mention it each time.

How it works

SLACK_OBSERVE_CHANNELS env var: comma-separated list of channel IDs to observe.

For channels in this list:

  1. Context buffering — every message is stored in a rolling per-channel buffer (last 20 messages) regardless of whether the bot responds.
  2. Direct @mentions — always trigger a response (for authorized users).
  3. Non-mention messages — a fast LLM call (_should_engage_in_channel) decides whether to respond, using recent context and any standing directives read from SOUL.md / MEMORY.md at runtime.
  4. Auth checkingSLACK_ALLOWED_USERS is respected. Unauthorized @mentions are silently ignored. Unauthorized messages that trigger engagement are relayed through the bot's own identity with an injection-hardened prefix so the gateway auth check passes.

Standard channels (not in SLACK_OBSERVE_CHANNELS) are unaffected — @mention required as before.

New method: _should_engage_in_channel

Uses google/gemini-2.0-flash-001 via OpenRouter (8s timeout, 3 output tokens) to answer "yes/no: should the bot respond?" Falls back to False (silent) on error or missing API key.

Reads standing directives from SOUL.md and MEMORY.md to make context-aware engagement decisions (e.g. "monitor for complaints", "watch for keyword X").

Changes

gateway/platforms/slack.py:

  • __init__: add _channel_context dict + _CONTEXT_BUFFER_SIZE
  • Mention gate replaced with observe logic (context buffer, auth check, LLM pre-filter, injection-safe relay)
  • New method: _should_engage_in_channel

Dependencies

  • Requires OPENROUTER_API_KEY for the LLM pre-filter (falls back gracefully to silent if unset)
  • SLACK_ALLOWED_USERS for auth gating (optional; if unset, all users are treated as authorized)

Introduces SLACK_OBSERVE_CHANNELS env var. Channels in this list get:
- Rolling context buffer (last 20 msgs) for engagement decisions
- Fast LLM pre-filter (_should_engage_in_channel) that reads SOUL.md/MEMORY.md
  for standing directives (complaints, requests, monitoring keywords)
- Direct @mentions always trigger a response for authorized users
- Unauthorized @mentions are silently ignored
- Unauthorized messages that trigger engagement are relayed through bot
  identity with injection-hardened prefix so gateway auth passes
- Standard channels retain require-@mention behavior

Drops SLACK_LISTEN_ALL_CHANNELS approach (superseded by observe mode).

Patches folded in: slack-observe-channels.py, fix-observe-auth.py,
fix-observe-relay.py, inject-engage-method.py, fix-engage-prompt.py
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have platform/slack Slack app adapter comp/gateway Gateway runner, session dispatch, delivery labels May 1, 2026
@gunpowder-client-vm

Copy link
Copy Markdown
Contributor Author

Closing as stale — >2 weeks old. Reopen or open a fresh PR if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/slack Slack app adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants