Skip to content

fix(slack): collect thread attachments across recent messages instead of only the newest#706

Open
shiminshen wants to merge 2 commits into
vercel:mainfrom
shiminshen:fix/slack-thread-attachment-lookback
Open

fix(slack): collect thread attachments across recent messages instead of only the newest#706
shiminshen wants to merge 2 commits into
vercel:mainfrom
shiminshen:fix/slack-thread-attachment-lookback

Conversation

@shiminshen

Copy link
Copy Markdown

Description

Fixes #705.

collectInboundFileParts scans thread.recentMessages backwards, but the loop body ends with an unconditional return on the first non-bot message it inspects — the loop never advances. When a user posts an image in a thread and then mentions the bot in a text-only follow-up, the newest non-bot message has no files, so everything earlier is silently dropped and the model sees zero file parts. This is the exact case the function's own doc comment says the lookback exists to cover ("a user dropped a file in the thread first, then mentioned the bot in a follow-up").

The fix collects attachments across non-bot messages, newest first, capped at 10 file parts to keep model input bounded on long threads. If you'd rather keep single-message semantics ("most recent message that has files") instead of bounded accumulation, I'm happy to adjust — flagged the same question in #705.

We've been running this change in production for an internal Slack knowledge agent (as a patch-package patch of the dist) since eve 0.17.

How did you test your changes?

  • pnpm run test:unit in packages/eve — 445 files, 4683 passed (adds a regression test that fails on main, plus accumulation and cap cases)
  • pnpm run typecheck — clean
  • pnpm lint — clean
  • Production use via the equivalent dist patch in our Slack deployment

PR Checklist

…ewest message

collectInboundFileParts scans thread.recentMessages backwards but returns
unconditionally on the first non-bot message, so files posted earlier in
the thread are silently dropped whenever the newest user message has no
attachments.

Signed-off-by: shiminshen <16914659+shiminshen@users.noreply.github.com>
… of only the newest

collectInboundFileParts scanned thread.recentMessages backwards but
returned unconditionally on the first non-bot message, so files posted
earlier in a thread were silently dropped whenever the newest user
message had no attachments — the exact follow-up-mention case the
lookback exists to cover. Collect across non-bot messages newest first,
capped at 10 file parts to keep model input bounded.

Signed-off-by: shiminshen <16914659+shiminshen@users.noreply.github.com>
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@shiminshen is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@shiminshen

Copy link
Copy Markdown
Author

One note on the THREAD_LOOKBACK_MAX_FILES = 10 bound: it's intentionally a hardcoded backstop to keep this diff minimal. If you'd prefer it configurable, I'm happy to lift it into UploadPolicy (e.g. an optional maxFiles, defaulting to 10, alongside maxBytes) — either in this PR or as a follow-up, whichever you prefer.

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.

Slack channel: images/files posted earlier in a thread are silently dropped — attachment lookback only ever inspects one message

1 participant