Skip to content

fix: advertise Slack context tools when available - #36676

Closed
jakelongvu-bot wants to merge 1 commit into
NousResearch:mainfrom
jakelongvu-bot:codex/slack-platform-context-tools-prompt
Closed

fix: advertise Slack context tools when available#36676
jakelongvu-bot wants to merge 1 commit into
NousResearch:mainfrom
jakelongvu-bot:codex/slack-platform-context-tools-prompt

Conversation

@jakelongvu-bot

Copy link
Copy Markdown
Contributor

Summary

  • stop telling Slack agents they cannot call Slack APIs when read-only Slack context tools are actually enabled
  • inject the current Slack channel ID and thread timestamp into the session context prompt for slack_get_thread/slack_get_messages
  • keep the old conservative disclaimer when the Slack context tools or bot token are not available

Why

Recent Hermes Slack context tools let the agent verify Slack thread/channel context directly. The built-in Slack platform note still said the opposite, which can make the model avoid the tools and fall back to pasted snippets or assumptions.

Validation

  • remote clean verification using staging venv:
    • python -m py_compile gateway/session.py tests/gateway/test_slack_session_context_prompt.py
    • python -m pytest tests/gateway/test_slack_session_context_prompt.py -q (2 passed)
  • git diff --check

@jakelongvu-bot

Copy link
Copy Markdown
Contributor Author

Vucar staging is already patched and restarted (Hermes gateway PID 1234536). Targeted staging test passed: tests/gateway/test_slack_session_context_prompt.py -q -> 2 passed. Smoke with Hermes env loaded confirmed Slack context tools are advertised, channel/thread IDs are present, and the old no Slack-specific APIs disclaimer is gone. @thomasdongg please review/coordinate deploy with Charles/Viet Thinh.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/slack Slack app adapter P2 Medium — degraded but workaround exists labels Jun 1, 2026

@mxnstrexgl mxnstrexgl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated PR Review

Security Scan

  • ✓ No hardcoded secrets, injection sinks, unsafe deserialization, or dependency red flags found by this automated scan.

Code Quality

  • ✓ No blocking code-quality issues found by this automated scan.

Summary

Status: APPROVE — security findings: 0, quality suggestions: 0.

Automated review; raw diff content intentionally omitted.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for identifying the stale Slack platform note. The current patch needs rework before it can safely advertise capabilities.

Problems

  • gateway/session.py:246 tests for a "slack" toolset, but current main has only hermes-slack (toolsets.py:468-471) and no registered slack_get_* tools. The prompt can therefore describe APIs that are not in the model schema.
  • gateway/session.py:348 directly interpolates chat_name, bypassing current _format_untrusted_prompt_value() hardening (gateway/session.py:372-378; introduced by 09666ceb).
  • gateway/session.py:352 adds volatile message_id to the cached system prompt. Current main deliberately moved the Discord equivalent to per-turn user content to preserve cache stability (d6c53dcd; tests/gateway/test_session.py:256-278).
  • The new tests stub the capability helper, so they do not validate resolver/registry behavior or prompt stability.

Suggested changes

  • Gate the note on concrete, selected registered tools; align names with the final Slack-history schema.
  • Serialize metadata, move message IDs to per-turn content, and add resolver, injection, and cache-invariance regressions.

Automated hermes-sweeper review.

Comment thread gateway/session.py
from hermes_cli.tools_config import _get_platform_tools
cfg = load_config()
enabled = _get_platform_tools(cfg, "slack", include_default_mcp_servers=False)
return "slack" in enabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_get_platform_tools() returns toolset names, but neither this PR's base nor current main defines a slack toolset or the advertised slack_get_* tools. This can never enable under normal configuration, or can advertise APIs that are absent if an unknown slack passthrough is manually configured. Gate on actual selected registered tool definitions instead.

Comment thread gateway/session.py
)
id_lines.append(f" - Channel ID for tool calls: `{src.chat_id}`")
if src.chat_name and src.chat_name != src.chat_id:
id_lines.append(f" - Channel name: `{src.chat_name}`")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chat_name is untrusted gateway metadata. Current main requires _format_untrusted_prompt_value() for this class of value (gateway/session.py:372-378); direct Markdown interpolation here reopens the prompt-injection surface fixed by 09666ceb.

Comment thread gateway/session.py
if src.thread_id:
id_lines.append(f" - Thread timestamp for `slack_get_thread`: `{src.thread_id}`")
if src.message_id:
id_lines.append(f" - Triggering message timestamp: `{src.message_id}`")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message_id changes every inbound turn, so placing it in build_session_context_prompt() churns the cached system-prompt signature. Current main's d6c53dcd moved the Discord equivalent into per-turn user content and tests this invariant; use the same pattern for Slack.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by #70194 (merged): covered by the derivation approach landed via #70194.

Thanks for the work — it's credited in #70194's summary.

@teknium1 teknium1 closed this Jul 23, 2026
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 P2 Medium — degraded but workaround exists platform/slack Slack app adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants