feat(slack): add smart observe mode for monitored channels#4636
Closed
gunpowder-client-vm wants to merge 1 commit into
Closed
feat(slack): add smart observe mode for monitored channels#4636gunpowder-client-vm wants to merge 1 commit into
gunpowder-client-vm wants to merge 1 commit into
Conversation
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
10 tasks
Contributor
Author
|
Closing as stale — >2 weeks old. Reopen or open a fresh PR if still relevant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
SLACK_OBSERVE_CHANNELSmode 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_CHANNELSenv var: comma-separated list of channel IDs to observe.For channels in this list:
_should_engage_in_channel) decides whether to respond, using recent context and any standing directives read fromSOUL.md/MEMORY.mdat runtime.SLACK_ALLOWED_USERSis 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_channelUses
google/gemini-2.0-flash-001via OpenRouter (8s timeout, 3 output tokens) to answer "yes/no: should the bot respond?" Falls back toFalse(silent) on error or missing API key.Reads standing directives from
SOUL.mdandMEMORY.mdto make context-aware engagement decisions (e.g. "monitor for complaints", "watch for keyword X").Changes
gateway/platforms/slack.py:__init__: add_channel_contextdict +_CONTEXT_BUFFER_SIZE_should_engage_in_channelDependencies
OPENROUTER_API_KEYfor the LLM pre-filter (falls back gracefully to silent if unset)SLACK_ALLOWED_USERSfor auth gating (optional; if unset, all users are treated as authorized)