fix(api): harden the Slack follow-up hand-back and allow task updates
Merged
AV
2mo ago+449+449+012345678901234567890123456789-89-89-01234567890123456789
Follow-up to #7586 from review and the first live test.
Root cause of the lost reply
Production logs for the 00:28 test: every hand-back publish failed with
QstashError: {"error":"DeduplicationId cannot contain ':'"} status: 400
The hand-back's deduplication id was queued:<team>:<ts>. QStash forbids colons in that field, so no queued reply was ever re-delivered, and the error was folded into "Failed to finish thread session". Fixed here with a colon-free id and a test that asserts it; hand-back failures now log on their own line.
Also in this PR
- Hand-back cannot lose or duplicate a reply. Queued replies are marked in place with the hand-off id, published, then removed; a failed publish clears the mark and a mark older than a minute (dead worker) is taken again. A hand-back whose message a finished turn already ran stands down, so a twice-published job runs once.
- A retry of the original delivery cannot run the message twice. A queued message's claim is marked skipped instead of deleted.
- Hand-backs do not re-ask the flag; other workers wait up to 5s for PostHog instead of the events route's 1s.
tasks_updateis allowed from Slack, so "rename that task" works.- Web-search replies read as prose. Text fragments around citations are joined without blank lines.
Manual QA (Superset workspace)
- Slow request, one reply mid-turn without a mention โ one catch-up reply, ๐ cleared. Logs show "Handed back queued replies".
-
rename that task to Xin a thread where the agent created a task โ renamed, Changes footer shows it. - A web-search answer has no paragraph breaks mid-sentence.
Testing
bun test src/app/api/integrations/slack(96 pass)bunx tsc --noEmit --pretty falsein apps/api and packages/db (exit 0)bunx biome check apps packages
https://claude.ai/code/session_01YDDSQYG6WSZn4jXWTR3Pid
Summary by CodeRabbit
- New Features
- Slack-based agents can now create, search, and update tasks.
- Bug Fixes
- Improved handling of queued Slack messages during agent handoffs, reducing duplicate processing and preventing lost messages.
- Prevented already-processed hand-back replies from triggering another agent run.
- Fixed message formatting so text split by citations displays correctly.
- Reliability
- Improved recovery when publishing queued messages fails.
- Transient service failures, rate limits, and connection failures now recover more reliably.
- Improved deadline handling for Slack responses and feature-flag checks.