Repository navigation
fix(slack): map thread-status text to Agent Sessions API enum - #111820
ching-kaching wants to merge 3 commits into
Conversation
Slack's Agent Sessions API (agents.sessions.setStatus, used automatically
on slack-sdk >= 3.44) replaced the legacy assistant.threads.setStatus.
The legacy call took an arbitrary display string ("is thinking...", a
custom typing_status_text, live per-tool text); the new one requires a
lifecycle enum (active/processing/suspended/closed) and rejects free text
with invalid_arguments.
_set_thread_status passed the display string straight through, so on any
install where slack-sdk auto-selects the new API the status call silently
no-ops (caught + debug-logged) and the working-state status line
disappears entirely, with no error surfaced anywhere.
Map to the enum when the new API is in play: "processing" while working,
"active" when clearing. Verified live against the real Slack API (both
enum values return ok:true; the previous free-text call returned
invalid_arguments).
The existing TestAgentSessionsApiRouting tests asserted the pre-fix
(buggy) behavior: free-text status strings passed straight through to
agents_sessions_setStatus. Update them to expect the enum mapping
("processing"/"active") and add a regression test proving a custom
typing_status_text still collapses to the enum instead of leaking as
free text, which Slack's real API rejects with invalid_arguments.
Duplicate of #109914 — same fix mechanism (map the display string to the |
Claude Code review of NousResearch#111820 found a real gap: _sdk_supports_agent_sessions() is a class-level probe, but the client INSTANCE can still lack agents_sessions_setStatus (older cached client, a test double), in which case _session_status_method already fell back to the legacy call. The enum rewrite in _set_thread_status checked only the class-level probe, so that fallback path would send "processing"/"active" as free text to the legacy API - which only clears on an empty string, so stop_typing would never clear the status there. Fix: _session_status_method_with_kind now returns which method it picked, and _set_thread_status keys the enum rewrite on that, not the separate class-level check. Added a test pinning the fallback behavior and a docs caveat clarifying typing_status_text has no visible effect at all on slack-sdk 3.44+, independent of the assistant:write scope.
Claude Code review of NousResearch#111820 found a real gap: _sdk_supports_agent_sessions() is a class-level probe, but the client INSTANCE can still lack agents_sessions_setStatus (older cached client, a test double), in which case _session_status_method already fell back to the legacy call. The enum rewrite in _set_thread_status checked only the class-level probe, so that fallback path would send "processing"/"active" as free text to the legacy API - which only clears on an empty string, so stop_typing would never clear the status there. Fix: _session_status_method_with_kind now returns which method it picked, and _set_thread_status keys the enum rewrite on that, not the separate class-level check. Added a test pinning the fallback behavior and a docs caveat clarifying typing_status_text has no visible effect at all on slack-sdk 3.44+, independent of the assistant:write scope.
88cd48e to
0b9eadf
Compare
|
Ran a self-review with Claude Code against this diff. It found one real correctness gap and I fixed it in the latest push: Gap: Fix: Also added a docs caveat: Two things flagged as reasonable but out of scope for this fix, noting here in case a maintainer wants them split out:
|
|
Independent reproduction + confirmation that this is the right fix. We hit this in production yesterday (2026-09-14, ~17:00 UTC) on a self-hosted Hermes gateway running three Slack bots. The status line under the composer ("Bot is thinking…") simply stopped appearing — no error surfaced anywhere in normal operation, since Environment:
Before finding this PR we arrived independently at the same diagnosis and patched our install with a functionally identical change — Two details in this PR that I can confirm matter in practice, having gotten them wrong first:
The doc change is a good call as well; No changes requested — this looks complete to me. Flagging one process point: the linked issue is labelled |
Bug
Slack's new Agent Sessions API (
agents.sessions.setStatus, used automatically onceslack-sdk >= 3.44is installed — see the earlier migration in this repo) requiresstatusto be a lifecycle enum:active/processing/suspended/closed. The legacyassistant.threads.setStatusit replaces took an arbitrary display string ("is thinking...", a customtyping_status_text, live per-tool text)._set_thread_statusinplugins/platforms/slack/adapter.pystill passes the display string straight through to whichever method_session_status_methodresolves. On any install where the SDK auto-selects the new Agent Sessions API, the call now fails withinvalid_argumentsevery time — caught and only debug-logged, so nothing surfaces the failure. Net effect: the working-state status line ("is thinking...") silently disappears on every agent-session-capable install, with no error visible to the operator.Repro (live, against the real API)
Fix
Map the display string to the nearest lifecycle enum only when the Agent Sessions API is in play (checked via the existing
_sdk_supports_agent_sessions()):processingwhile a turn is working,activewhen the status is cleared. The legacy path (older slack-sdk) is untouched and keeps sending free text as before.Custom
typing_status_text/ live per-tool status text has no enum equivalent under the new API — Slack renders its own generic placeholder in that case, same as an app with noassistant:writescope. That's a Slack platform limitation (confirmed againstdocs.slack.dev/ai/agent-sessions), not something this adapter can route around.Verification
Called both enum values live against a real workspace/thread before and after the fix:
status: "is thinking..."→invalid_argumentsstatus: "processing"→ok:true;status: "active"→ok:true