fix: parse Slack legacy attachments in thread reads and conversation backfill#334
Merged
Merged
Conversation
…backfill When a Slack message uses legacy attachments (the 'attachments' field) instead of top-level text, Junior previously saw empty text and either dropped the message from context or returned it with no content. This affects many bot integrations (Datadog, PagerDuty, deploy notifiers, etc.) that still use the pre-Block-Kit attachment format. Changes: - Add legacy-attachments.ts helper to sanitize and render attachment text from raw Slack payloads - Update slackThreadRead tool to include sanitized attachments and synthesized attachment_text in output - Update conversation backfill to enrich message text from legacy attachments so attachment-only messages are not dropped - Add SlackChannelMessage/SlackThreadReply.attachments field - Add unit tests for sanitization, rendering, and text composition Co-Authored-By: Claude (claude-opus-4) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Include legacy Slack attachment text in current-turn prompts, subscribed-message routing, and thread-read output so attachment-only messages keep useful context. Keep the parser small by rendering only the text fields Junior needs and avoiding an exported sanitizer surface. Co-Authored-By: GPT-5 Codex <codex@openai.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8fdc598. Configure here.
Mark the bare Slack attachment title as emitted when rendering a linked title so matching text fields do not repeat the same content. Co-Authored-By: GPT-5 Codex <codex@openai.com>
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.

Problem
When a Slack message uses legacy attachments (the
attachmentsfield) instead of top-leveltext, Junior sees empty text and either:This affects many bot integrations (Datadog, PagerDuty, deploy notifiers, etc.) that still use the pre-Block Kit attachment format. Example: a Datadog alert in a thread shows as empty text, so when someone asks Junior about it, Junior has no idea what the alert says.
Reported by @JoshFerge in #proj-junior.
Changes
New:
legacy-attachments.tshelpersanitizeSlackLegacyAttachments()— extracts text-bearing fields (fallback,pretext,title,title_link,text,fields,footer,author_name) and drops noise (color,actions,callback_id,image_url, etc.)renderSlackLegacyAttachmentText()— renders sanitized attachments as compact[attachment] ...lines with deduplicationappendSlackLegacyAttachmentText()— combines base message text with attachment textUpdated:
slackThreadReadtoolsanitizeMessage()now includesattachments(sanitized) andattachment_text(rendered) in outputUpdated: conversation backfill
createConversationMessageFromSdkMessage()enrichesentry.textwith legacy attachment text fromentry.raw.attachmentsbefore normalizationUpdated:
SlackChannelMessage/SlackThreadReplyinterfacesattachments?: unknown[]field to capture raw Slack legacy attachment payloadsSafety
normalizeConversationText(3200 char cap) in the backfill pathurl_private,image_url,actions, etc.)unknown, null-safe throughoutTests
11 unit tests covering sanitization, rendering, text composition, edge cases, and caps.