fix(slack): open DMs for user send targets - #19237
Closed
davesecops wants to merge 1 commit into
Closed
Conversation
davesecops
force-pushed
the
fix/slack-dm-user-targets
branch
2 times, most recently
from
May 7, 2026 01:48
c20ef73 to
912f2e2
Compare
davesecops
force-pushed
the
fix/slack-dm-user-targets
branch
from
May 12, 2026 20:47
912f2e2 to
97ad3b6
Compare
Contributor
|
Thanks for the focused Slack DM-target implementation. The requested behavior is still needed on current main, but this branch needs a plugin-era port before it can be salvaged. Problems
Suggested changes
Automated hermes-sweeper review. |
teknium1
added a commit
that referenced
this pull request
Jul 23, 2026
…paths Widen the #19237 send_message fix to the live adapter: send, _upload_file, send_multiple_images, send_image, send_video, send_document, send_exec_approval, send_slash_confirm, and send_clarify now route bare Slack user IDs (U.../W...) through a shared _ensure_dm_conversation helper before calling chat.postMessage / files_upload_v2, which reject user IDs. This closes the gap in #17261 where an attachment worked when replying in a thread but failed when directed at a user DM, and extends the DM-open fallback to clarify/approval Block Kit prompts so gated actions can reach a user directly. Resolution uses the workspace-scoped client (multi-workspace installs open the DM with the right bot token), caches per (team, user), and records the opened D... channel in the channel→team map. On failure the original target passes through so the downstream API call surfaces the real Slack error. Fixes #17261 Refs #19236
teknium1
added a commit
that referenced
this pull request
Jul 23, 2026
…paths Widen the #19237 send_message fix to the live adapter: send, _upload_file, send_multiple_images, send_image, send_video, send_document, send_exec_approval, send_slash_confirm, and send_clarify now route bare Slack user IDs (U.../W...) through a shared _ensure_dm_conversation helper before calling chat.postMessage / files_upload_v2, which reject user IDs. This closes the gap in #17261 where an attachment worked when replying in a thread but failed when directed at a user DM, and extends the DM-open fallback to clarify/approval Block Kit prompts so gated actions can reach a user directly. Resolution uses the workspace-scoped client (multi-workspace installs open the DM with the right bot token), caches per (team, user), and records the opened D... channel in the channel→team map. On failure the original target passes through so the downstream API call surfaces the real Slack error. Fixes #17261 Refs #19236
Contributor
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…paths Widen the NousResearch#19237 send_message fix to the live adapter: send, _upload_file, send_multiple_images, send_image, send_video, send_document, send_exec_approval, send_slash_confirm, and send_clarify now route bare Slack user IDs (U.../W...) through a shared _ensure_dm_conversation helper before calling chat.postMessage / files_upload_v2, which reject user IDs. This closes the gap in NousResearch#17261 where an attachment worked when replying in a thread but failed when directed at a user DM, and extends the DM-open fallback to clarify/approval Block Kit prompts so gated actions can reach a user directly. Resolution uses the workspace-scoped client (multi-workspace installs open the DM with the right bot token), caches per (team, user), and records the opened D... channel in the channel→team map. On failure the original target passes through so the downstream API call surfaces the real Slack error. Fixes NousResearch#17261 Refs NousResearch#19236
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.
What does this PR do?
Adds Slack
send_messagesupport for direct-message user targets. Hermes already supports Slack conversation IDs (C...,G...,D...), but user-oriented targets require opening a DM first because Slackchat.postMessageonly accepts conversation IDs.This PR makes these target forms work:
slack:U123ABCDEFslack:@aliceslack:<@U123ABCDEF>For user targets, Hermes now calls
conversations.opento get aD...DM conversation before posting.Related Issue
Fixes #19236
Type of Change
Changes Made
tools/send_message_tool.pyU...) as explicit internal user targets.@usernametargets as explicit internal username targets.<@U...>) as an explicit user target.users.list.conversations.openbeforechat.postMessage.tests/tools/test_send_message_tool.py_send_slacktests for user-ID DM opening, username resolution, and ambiguous username handling.How to Test
Run targeted tests:
venv/bin/python -m pytest tests/tools/test_send_message_tool.py tests/gateway/test_channel_directory.py -q -o 'addopts='Verify targeted result:
Optional live Slack validation with a configured app that has
chat:write,im:write, andusers:read:Expected: Hermes resolves the user, opens a DM, and sends successfully.
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Targeted test output:
Full-suite note:
A local full
pytest tests/ -q -o 'addopts='run was attempted but did not complete within 10 minutes in this development environment. The targeted tool/gateway regression tests for this change pass.