feat: add scoped Slack history tool - #29489
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused resubmission. The feature addresses a current gap: gateway/session.py:496-504 still tells Slack sessions that Slack APIs cannot be called, and current main has no tracked slack_history tool.
Problems
tools/slack_history_tool.py:111-125passes the entireSLACK_BOT_TOKENvalue as one bearer token. Hermes supports comma-separated multi-workspace tokens inwebsite/docs/user-guide/messaging/slack.md:524-561, and the active adapter splits them inplugins/platforms/slack/adapter.py:979-992; this path would fail for those configured workspaces and cannot select the inbound workspace's credential.toolsets.py:62puts the tool in_HERMES_CORE_TOOLS. All platform bundles inherit that list (toolsets.py:430-485), so any configured Slack token exposes Slack retrieval to non-Slack sessions as well. That defeats the claimed scoped boundary.
Suggested changes
- Route history calls through the active workspace-aware Slack client/token mapping and add multi-workspace coverage.
- Keep the tool Slack-scoped rather than core, and fail closed unless invocation provenance is an authorized Slack session.
Automated hermes-sweeper review.
|
|
||
|
|
||
| def _token() -> str: | ||
| token = (os.environ.get("SLACK_BOT_TOKEN") or "").strip() |
There was a problem hiding this comment.
SLACK_BOT_TOKEN may be a comma-separated multi-workspace value. The active adapter splits it and maps credentials per workspace (plugins/platforms/slack/adapter.py:979-992); passing the whole value as one Bearer token fails and cannot select the workspace for this session. Please use the same workspace-aware credential path and add a multi-workspace regression test.
| # Cross-platform messaging (gated on gateway running via check_fn) | ||
| "send_message", | ||
| # Scoped Slack history/search (gated on SLACK_BOT_TOKEN via check_fn) | ||
| "slack_history", |
There was a problem hiding this comment.
This makes Slack history part of every hermes-* bundle because they inherit _HERMES_CORE_TOOLS. With any Slack token configured, a non-Slack session can invoke it with an explicit channel ID. Keep this in the Slack-specific bundle/toolset and enforce trusted Slack-session provenance before retrieving workspace data.
Summary
slack_historytool for recent messages, thread replies, and bounded channel search.SLACK_BOT_TOKEN, adds Slack/messaging toolset integration, and exposes current Slack IDs in Slack session context only when the tool is available.Safety
Test Plan
TZ=UTC LANG=C.UTF-8 PYTHONHASHSEED=0 /Users/dennis/.hermes/hermes-agent/venv/bin/python -m pytest -o addopts= -n 4 --ignore=tests/integration --ignore=tests/e2e -m 'not integration' tests/tools/test_slack_history_tool.py tests/tools/test_slack_history_toolset.py tests/hermes_cli/test_slack_cli.py tests/gateway/test_slack_history_context_prompt.py -q