fix Slack assistant status endpoint (#1272)

This commit is contained in:
Johannes du Plessis 2026-05-08 13:07:32 -07:00 • committed by GitHub
parent 743b2b9ba4
commit d38f17ffe8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View file

@ -1,6 +1,6 @@
"""Middleware that keeps Slack's assistant status current during agent work.
Slack's ``assistants.threads.setStatus`` indicator expires after two minutes
Slack's ``assistant.threads.setStatus`` indicator expires after two minutes
if no message is sent. This middleware refreshes the indicator while model and
tool calls are actively running, then clears it when the run exits without
relying on the model to post a final Slack reply.

View file

@ -287,7 +287,7 @@ async def set_slack_assistant_status(
) -> bool:
"""Set the assistant typing/status indicator on a Slack thread.
Wraps Slack's `assistants.threads.setStatus` API. The `chat:write` scope
Wraps Slack's `assistant.threads.setStatus` API. The `chat:write` scope
on the bot token is sufficient. Status auto-clears when the bot posts to
the thread, and Slack itself expires it after ~2 minutes — callers that
want it visible across longer runs must refresh it periodically.
@ -316,18 +316,18 @@ async def set_slack_assistant_status(
async with httpx.AsyncClient() as http_client:
try:
response = await http_client.post(
f"{SLACK_API_BASE_URL}/assistants.threads.setStatus",
f"{SLACK_API_BASE_URL}/assistant.threads.setStatus",
headers=_slack_headers(),
json=payload,
)
response.raise_for_status()
data = response.json()
if not data.get("ok"):
logger.warning("Slack assistants.threads.setStatus failed: %s", data.get("error"))
logger.warning("Slack assistant.threads.setStatus failed: %s", data.get("error"))
return False
return True
except httpx.HTTPError:
logger.exception("Slack assistants.threads.setStatus request failed")
logger.exception("Slack assistant.threads.setStatus request failed")
return False

View file

@ -74,7 +74,7 @@ async def test_set_slack_assistant_status_calls_correct_endpoint(
assert ok is True
client_cm.post.assert_awaited_once()
args, kwargs = client_cm.post.call_args
assert args[0].endswith("/assistants.threads.setStatus")
assert args[0].endswith("/assistant.threads.setStatus")
assert kwargs["json"] == {
"channel_id": "C1",
"thread_ts": "1.0",