Skip to content

fix(slack): handle app_mention events so thread @mentions are delivered to agents#13252

Closed
dzianisv wants to merge 17 commits into
anomalyco:devfrom
dzianisv:fix/slack-thread-mention-delivery
Closed

fix(slack): handle app_mention events so thread @mentions are delivered to agents#13252
dzianisv wants to merge 17 commits into
anomalyco:devfrom
dzianisv:fix/slack-thread-mention-delivery

Conversation

@dzianisv

Copy link
Copy Markdown

Summary

  • Add app.event('app_mention') handler so @mention messages in threads are processed by the agent
  • Extract shared processMessage() function to eliminate code duplication between message and app_mention handlers
  • Add timestamp-based deduplication to prevent double-processing when Slack sends both message and app_mention events for the same @mention

Problem

When a user @mentions the bot in a Slack thread (e.g. @SupportEngineer, please create a PR with a code fix), Slack sends an app_mention event. The bot only had an app.message() handler registered and completely ignored app_mention events, so the message was never delivered to the agent.

Root Cause

The Slack bot in packages/slack/src/index.ts only registered app.message() which handles regular channel messages. The app_mentions:read OAuth scope was listed in the README as required, but no app.event('app_mention', ...) handler existed in the code.

Changes

File Change
packages/slack/src/index.ts Add app.event('app_mention') handler, extract processMessage(), use dedup
packages/slack/src/dedup.ts New module: timestamp-based deduplication with configurable TTL
packages/slack/test/dedup.test.ts 6 tests for dedup logic including TTL expiry and Slack event simulation
packages/slack/tsconfig.json Exclude test dir from typecheck (bun:test types)
plan.md Task tracking

Closes #13251

dzianisv and others added 17 commits December 17, 2025 12:28
- Add JWT expiration check utility
- Implement dynamic base URL resolution based on token environment
- Add missing x-api-key and Authorization: Bearer headers
- Add organizationId to ApiAuth schema
- Add proactive token expiration warnings in CLI and model discovery
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…itely

When network issues occur mid-stream (TCP half-open connections, stalled LLM
providers, proxy timeouts), the streaming loop would hang forever waiting for
the next chunk. This fix adds an idle timeout that detects when no data has
been received for a configurable period (default 60 seconds) and triggers a
retry with exponential backoff.

Changes:
- Add StreamIdleTimeoutError class to message-v2.ts
- Add withIdleTimeout() async generator wrapper in processor.ts
- Wrap stream.fullStream with idle timeout in the process loop
- Mark StreamIdleTimeoutError as retryable so sessions recover automatically
- Add stream_idle_timeout config option under experimental settings
- Add additional network error types (ETIMEDOUT, ENOTFOUND, etc) as retryable

Fixes issues where sessions get stuck for hours on LLM requests.
Related: anomalyco#8383, anomalyco#2512, anomalyco#2819, anomalyco#4255
fix: add stream idle timeout to prevent sessions from hanging indefinitely
Integrate Kilo Code provider:
- Add kilocode device authorization flow in auth.ts
- Add kilocode provider loader in provider.ts
- Add dynamic model discovery from Kilo Code API in models.ts
- Add JWT expiry check for kilocode tokens in run.ts
- Add install:local script for developer convenience
- Add desktop infra import in sst.config.ts

Preserves dev branch improvements:
- Provider filtering (enabled/disabled providers)
- Improved Data lazy loading with Flag support
- Better message handling in run command
- Plugin auth handling
This feature was causing more problems than it solved. Tool execution
blocks the stream, so the timeout couldn't distinguish between:
1. LLM provider stalled (actual problem)
2. Tool executing (normal operation)

Reverting to upstream behavior - no stream idle timeout.
…ed to agents

When a user @mentions the bot in a Slack thread (e.g. '@supportengineer,
please create a PR'), Slack sends an app_mention event that the bot was
ignoring — only app.message() was registered.

Changes:
- Add app.event('app_mention') handler to process @mention events
- Extract shared processMessage() to avoid duplicating message handling logic
- Add timestamp-based deduplication (Slack sends both message and app_mention
  events for @mentions in channels where the bot is a member)

Closes anomalyco#13251
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@dzianisv

Copy link
Copy Markdown
Author

Closing: this fix was applied to the wrong codebase. The actual Slack bot is in VibeTechnologies/VibeTeam, and the fix was merged there as PR #92. See VibeTechnologies/VibeTeam#92

@dzianisv dzianisv closed this Feb 12, 2026
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.

fix: Slack bot doesn't deliver thread messages with @mentions to agents

1 participant