Skip to content

fix(gateway): derive the Slack capability note from the live tool surface - #70194

Merged
teknium1 merged 2 commits into
mainfrom
slack/c15-capability-note
Jul 23, 2026
Merged

fix(gateway): derive the Slack capability note from the live tool surface#70194
teknium1 merged 2 commits into
mainfrom
slack/c15-capability-note

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

The Slack platform note no longer lies to the agent: instead of unconditionally claiming "you do NOT have access to Slack-specific APIs", the note is derived from the live tool surface (MCP servers + native toolsets), mirroring the merged Discord pattern — so the agent stops refusing valid requests when Slack tools are present.

Fixes #6536.

Changes

  • tools/mcp_tool.get_registered_mcp_server_names() — post-connection, availability-filtered MCP registration map; capability gate in build_session_context_prompt derives from it + native slack toolset/config.
  • Session-stable: computed at session construction, never mutates mid-conversation (prompt-cache safe).

Credits

Base: #68627 (@ygd58) — the only one of five overlapping PRs deriving the gate from the live tool surface, cherry-picked with authorship.
Supersedes #6545 (@mecampbellsoup — EARLIEST diagnosis, credited as originator), #62135, #36676, #69094.

Validation

Check Result
Note reflects toolset (with slack tools → mentions them; without → doesn't) green
Byte-stable across turns in one session green
tests/gateway/ -q -k slack 767 passed, 0 failed (re-verified post-rebase)

Infographic

slack-capability-note

ygd58 and others added 2 commits July 23, 2026 09:08
…ols present

Ports #63234 forward onto current main per teknium1's review.

gateway/session.py hard-coded the stale-API disclaimer for every Slack
session regardless of whether Slack tools were actually loaded. This
contradicted the system prompt when MCP or native slack tools were
present, causing the agent to refuse Slack API actions it could
actually perform (issue #6536).

Per review, the original predicate only checked the native 'slack'
toolset, missing Slack MCP servers (registered under mcp-<server> in
tools/mcp_tool.py) entirely. _slack_tools_loaded() now checks two
independent paths:

1. Native 'slack' toolset + SLACK_BOT_TOKEN (as before, but now calls
   _get_platform_tools() with include_default_mcp_servers=True instead
   of False, so a default-enabled MCP server also counts).
2. A connected MCP server that has ACTUALLY registered tools into the
   live registry (new tools.mcp_tool.get_registered_mcp_server_names()),
   whose name suggests Slack. This is session-scoped in the sense that
   matters here: MCP servers connect once per gateway process (not
   per-session), so checking the live per-server tool-registration map
   is the correct availability-filtered signal -- unlike the earlier
   get_all_tool_names() approach this replaces, which conflated ALL
   built-in tool names process-wide, this only inspects the small,
   purpose-built MCP server-name map.

Added a real regression test that registers a tool via the actual
tools.mcp_tool._track_mcp_tool_server() tracking function (not a mock
of the capability check) to verify a genuine Slack MCP server is
detected, plus a negative case for an unrelated MCP server.

5/5 Slack-specific tests pass; 126/126 in the full
tests/gateway/test_session.py file.
…sitive note to tool schemas

Follow-up to the #68627 cherry-pick (cluster C15 — Slack platform
capability-note accuracy; earliest report/fix: #6545 by @daikeren):

1. Session/prompt stability: the pinned session-context render
   (_pinned_session_context_prompt) is keyed by _ephemeral_change_key,
   whose contract requires every rendered input to appear in the key.
   The new _slack_tools_loaded() gate reads config + the live MCP
   registration map, so its state is now hashed into the key exactly
   like the existing Discord gate — a gate flip re-renders ONCE (a
   legitimate bust); within a session the note stays byte-stable for
   the life of the conversation (A/B: the new parity test fails with
   this key change reverted, passes with it).

2. Derived, non-overpromising positive note: rather than hardcoding a
   capability list that can drift stale again (the original bug class),
   the tools-present note tells the agent to consult the actual loaded
   Slack tool schemas for supported operations — the schemas ARE the
   source of truth, so the note cannot overclaim ops a given Slack
   toolset/MCP server doesn't expose (e.g. a read-only history server).

3. Tests: parity test proving a gate flip changes both render and key;
   byte-stability test proving three consecutive turns in one Slack
   session return the identical pinned object (sha256-equal); autouse
   fixture pins the new gate so key<->render parity is env-independent.
@teknium1 teknium1 added the platform/slack Slack app adapter label Jul 23, 2026
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 55d31c9

ℹ️ Info

Desktop E2E visual evidence · View test artifacts · View job

1 visual diff.

inline evidence upload failed.

Failed to upload diff-665a0833239e-onboarding-overlay-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-665a0833239e-onboarding-overlay-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso)

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery comp/tools Tool registry, model_tools, toolsets tool/mcp MCP client and OAuth needs-decision Awaiting maintainer decision before any implementation labels Jul 23, 2026
@teknium1
teknium1 merged commit e027f43 into main Jul 23, 2026
43 checks passed
@teknium1
teknium1 deleted the slack/c15-capability-note branch July 23, 2026 18:32
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 comp/tools Tool registry, model_tools, toolsets needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have platform/slack Slack app adapter tool/mcp MCP client and OAuth type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants