fix(gateway): render Slack attachment thread context - #32022
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds richer Slack message rendering so agents can see meaningful content when integrations (e.g., Zendesk) send empty top-level text and place payload into legacy attachments, including in thread parent backfills.
Changes:
- Centralized Slack message rendering into
_render_slack_message_text()(text + blocks + attachments). - Added attachment field/footer extraction so “attachment-only” integration messages are visible.
- Added tests covering attachment-only thread parents and attachment field rendering in message handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
gateway/platforms/slack.py |
Introduces shared rendering helpers and uses them in message handling + thread context/parent fetches. |
tests/gateway/test_slack_approval_buttons.py |
Adds coverage for attachment-only thread parent rendering in context + parent-text fetch. |
tests/gateway/test_slack.py |
Adds coverage ensuring attachment fields/footer content becomes visible for integration messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e11cffa to
c1cacb0
Compare
c1cacb0 to
0216c45
Compare
0216c45 to
03e5bff
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the comprehensive shared-renderer approach. The underlying defect is still present on current main: plugins/platforms/slack/adapter.py:3788-3790 skips attachment-only thread messages after reading only text, and :3891 does the same for cold reply_to_text fetches.
Problems
- The submitted production change targets
gateway/platforms/slack.py, but5600105478ffde29d7566b45421b100eaa29c4efmoved the active adapter toplugins/platforms/slack/adapter.py. The submitted file is no longer the runtime implementation. - Current Slack tests import the plugin adapter (
tests/gateway/test_slack.py:67-71;tests/gateway/test_slack_approval_buttons.py:45), so the regression coverage must move with the implementation.
Suggested changes
- Port the shared renderer and its live-message, thread-backfill, and parent-text call sites to
plugins/platforms/slack/adapter.py. - Preserve the proposed
include_block_payload=Truebehavior only for live events; historical thread context should remain readable text without the serialized Block Kit payload.
Automated hermes-sweeper review.
| "Slack: appended %d link unfurl(s) to message text", | ||
| len(att_parts), | ||
| ) | ||
| text = _render_slack_message_text( |
There was a problem hiding this comment.
Current main no longer loads this file: 5600105478ffde29d7566b45421b100eaa29c4ef moved SlackAdapter to plugins/platforms/slack/adapter.py. Port this renderer call and its helpers there, otherwise the active Slack path remains unchanged.
What does this PR do?
Slack app messages can put the useful parent content in legacy
attachmentswhile leaving top-leveltextempty. Thread backfill only readtext, so a reply in one of those threads could reach the agent without the ticket or alert details it was replying to.This reuses the Slack message renderer for live messages, thread history, and
reply_to_text. Historical thread context keeps readable block text, but does not include the full Block Kit JSON payload that current messages still expose.Related Issue
No linked issue.
Overlap: #30765 fixes the same Slack legacy-attachment thread-context failure. This PR folds that behavior into the shared renderer and adds coverage for dedupe, truncation, parent-text lookup, and avoiding Block Kit JSON in historical context.
Prior related work: #16213 and #16281.
Type of Change
Changes Made
gateway/platforms/slack.py: render Slack text, blocks, and legacy attachments through one helper.gateway/platforms/slack.py: use that renderer for thread backfill and parentreply_to_text, with bounded attachment output.tests/gateway/test_slack.py,tests/gateway/test_slack_approval_buttons.py: add regressions for attachment-only parents, fallback handling, truncation, and Block Kit history behavior.How to Test
textand useful legacyattachments.[Slack Block Kit payload ...]JSON.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passFull local
scripts/run_tests.shcompleted on macOS/Python 3.12 after installing.[all,dev]: 25,806 passed, 26 failed. The failures are outside this PR's Slack path and are local platform/runtime issues (Python 3.12 coroutine-frame assertions, Linux/systemd assumptions on macOS, temporary-HOMEpath behavior, and local browser/tooling assumptions). The changed Slack files passed in that full run.Documentation & 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