feat(slack-relay): router reacts :eyes: to each message it routes

Merged
KH
5d ago
+274-27

What

The Slack router now acknowledges every message it routes to an agent with an :eyes: reaction, as soon as it takes the message and before the agent starts.

  • Where: Router.fromSlack (step 0). This runs before the per-thread queue and before the orchestrator. Every message that reaches it is one the router routes, because the Socket Mode handler has already dropped ignored ones (plain channel chatter, replies in threads it doesn't hold, bot messages and edits, DMs when slack.allowDms is off, disallowed or shared channels). Those get no reaction.
  • Fire-and-forget: routing never waits on reactions.add and never fails because of it. already_reacted is ignored. Any other failure logs only Slack's error code (ack reaction failed for C…:<ts> (<code>)), never the message text.
  • missing_scope: logged once (ack reaction off: the bot token lacks reactions:write (add reactions:write and reinstall the app)). After that the router stops trying and routes as before.
  • Value: slack.ackReaction: eyes (env SLACK_ACK_REACTION). Set it to empty to turn the reaction off.
  • Scope: reactions:write is added to manifest/slack-app-manifest.json, so render-manifest.py picks it up. It is also listed in the docs. SlackWeb now throws SlackApiError with a .code. The error message is unchanged.

Existing installs

Add reactions:write under OAuth & Permissions, Bot Token Scopes, then Reinstall to Workspace. Until then the router logs the line above once and routes as normal. This is documented in docs/self-hosted-slack-relay.md.

Versions

slack-relay 0.3.11, agent-relay 0.7.50. The merge order is #441 (slack-relay 0.3.10, agent-relay 0.7.48), then #442 (agent-relay 0.7.49), then this PR, which will rebase onto main once they land. The registry (self-hosted/requirements.yaml) gains slack-relay-0.3.11 and agent-relay-0.7.50 as current, and the opt.slack-relay.channels option now covers slack.ackReaction. The doc is regenerated.

Tests

test/ack.test.ts:

  • A routed mention, a reply in its thread and an allowed DM each get :eyes:.
  • Ignored messages get no reaction: plain chatter, a reply in an untracked thread, a bot message, an edit.
  • ackReaction: "" turns it off, and a custom name is used.
  • missing_scope is logged once, not retried, and routing continues.
  • already_reacted stays silent, and other errors log the code only.
  • A reaction that never settles, throws synchronously or hits a network error does not block or fail routing.
  • SlackWeb.addReaction posts reactions.add and surfaces Slack's error code.

Local runs: npm run typecheck and npm test pass. scripts/ci/charts.sh static, scripts/ci/version-bump.sh, registry.mjs check and ci/agent-relay/render.sh pass. No image was built.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

The Slack router now requests an :eyes: reaction on each message it routes to an agent, as soon as it takes the message; routing never waits on it, so the reaction usually shows before the agent starts but can land later or fail without affecting the answer.

  • Ignored messages (chatter, replies in untracked threads, bot messages, edits) get no reaction.
  • already_reacted is silent; other failures log only Slack's error code, never the message text.
  • A token missing reactions:write is logged once and the router stops trying until restarted.
  • Configurable via slack.ackReaction (env SLACK_ACK_REACTION), default eyes; empty turns it off.
  • SlackWeb now throws SlackApiError with a .code.

Migration

  • Existing installs must add reactions:write under Bot Token Scopes, reinstall the app, and move to a slack-relay image from chart 0.3.11 or later, then restart the router (kubectl -n agent-relay rollout restart deployment -l app.kubernetes.io/name=slack-relay,app.kubernetes.io/component=router).
  • Bumps slack-relay to 0.3.11 and agent-relay to 0.7.50.