Skip to content

fix(gateway/slack): send tool call progress messages to correct Slack thread - #2956

Closed
jneeee wants to merge 1 commit into
NousResearch:mainfrom
jneeee:fix/slack-progress-messages-thread2
Closed

fix(gateway/slack): send tool call progress messages to correct Slack thread#2956
jneeee wants to merge 1 commit into
NousResearch:mainfrom
jneeee:fix/slack-progress-messages-thread2

Conversation

@jneeee

@jneeee jneeee commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Problem

Slack tool call progress messages (e.g. ⚙️ read_file: "...") were appearing in the wrong place:

  • DM top-level messages: progress messages went to the DM root instead of a thread under the user's message. The final response correctly created a thread via reply_to=ts, but progress messages had no thread anchor.
  • Channel @mentions: already worked correctly since source.thread_id = ts (fallback).

Root Cause

In gateway/run.py, _progress_metadata was built solely from source.thread_id:

_progress_metadata = {"thread_id": source.thread_id} if source.thread_id else None

For DM top-level messages, source.thread_id = None (by design — DMs share one session). So _progress_metadata = None, and progress messages were sent without thread_ts to the DM root.

Meanwhile, the final response was sent with reply_to=event.message_id (the original message's ts), which correctly created a thread. The progress messages and final response ended up in different places.

Fix

  1. Added event_message_id parameter to _run_agent().
  2. _handle_message_with_agent passes event.message_id to _run_agent.
  3. _progress_metadata now uses source.thread_id or event_message_id as the thread anchor, matching what reply_to does for the final response.
  4. Same fix applied to _status_thread_metadata and stream consumer metadata for consistency.

Tests

Added TestProgressMessageThread in tests/gateway/test_slack.py:

  • Verifies DM top-level messages keep source.thread_id = None (session keying unaffected)
  • Verifies message_id = ts is available as thread fallback
  • Verifies Slack send() passes correct thread_ts when metadata.thread_id is set
  • Verifies channel @mention thread assignment still works

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #3063. Cherry-picked onto current main with authorship preserved. Clean fix — thanks for tracking this down!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants