← Back to PRs

#15879: Support for forwarded messages and file_shared messages in slack

by olyashok open 2026-02-14 00:42 View on GitHub →
channel: slack stale size: M
Summary Forwarded message support: Extracts and surfaces attachment notes from Slack forwarded messages so the agent can see forwarded content (adds attachments field to SlackMessageEvent type and a helper to detect forwarded messages). Large file upload fallback: When a user sends a message with a large file (>~20MB) in an MPDM, Slack Socket Mode may not deliver the normal message event — instead only a file_shared event is emitted. This adds a fallback handler that catches file_shared events, fetches the actual message from conversations.history, and feeds it into the normal message pipeline. Dedup logic: For small files that produce both message and file_shared events, a shared timestamp set prevents double-processing. Background Slack has a platform-level behavior where large file uploads in MPDMs via Socket Mode do not deliver the expected message event. Instead, only a non-message file_shared event is sent (containing file_id and channel_id but no message text or files array). This was confirmed by testing with a raw WebSocket listener — small files (~1KB) produce normal message events with subtype: "file_share", while large files (~35MB PDF) only produce file_shared events. Changes src/slack/overrides/types.ts — Extended SlackMessageEvent with attachments field src/slack/overrides/attachment-helper.ts — Helper to detect forwarded message content src/slack/overrides/extract-attachments.ts — Full attachment text extractor src/slack/monitor/message-handler/prepare.ts — Integrates attachment note into message body src/slack/monitor/events/file-shared.ts — New file_shared event handler with dedup src/slack/monitor/events.ts — Registers the new handler src/slack/monitor/events/messages.ts — Marks file messages as handled for dedup How the fallback works Slack sends file_shared event with { file_id, channel_id, user_id } Handler waits 2s for Slack to settle the message Fetches last 5 messages from conversations.history Finds the message containing the matching file_id Checks dedup set — skips if already handled via normal message event Constructs a SlackMessageEvent and passes it to handleSlackMessage Test plan [ ] Send a text-only message — bot responds normally (no regression) [ ] Send a message with a small file (<5MB) — bot responds, file is processed [ ] Send a message with a large file (>20MB) — bot responds via file_shared fallback [ ] Send a small file message — verify it's not processed twice (dedup) [ ] Forward a message in Slack — agent sees forwarded content note <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR extends Slack message handling in two directions: - Adds support for surfacing forwarded/attached message context by threading an `attachments` field into `SlackMessageEvent` and appending an attachment note during message preparation. - Adds a new `file_shared` Socket Mode event handler that backfills large file uploads by fetching the corresponding message from `conversations.history`, with timestamp-based deduping to avoid double-processing when both events are emitted. These changes integrate into the existing Slack monitor event registration (`registerSlackMonitorEvents`) and reuse the normal `handleSlackMessage` pipeline so downstream behaviors (policy checks, mention gating, media handling, etc.) remain centralized. <h3>Confidence Score: 3/5</h3> - This PR is close to mergeable, but has a couple correctness issues that can break the new Slack behaviors in production. - Main risk is the new `file_shared` fallback calling `conversations.history` without an explicit token, which may prevent message backfill entirely depending on client configuration. There’s also an apparently unused duplicate Slack type module that is likely accidental and could cause future drift/confusion. - src/slack/monitor/events/file-shared.ts; src/slack/overrides/types.ts <sub>Last reviewed commit: a9fd42b</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs