mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-04 11:22:10 +00:00
fix Slack assistant status endpoint (#1272)
This commit is contained in:
parent
743b2b9ba4
commit
d38f17ffe8
3 changed files with 6 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"""Middleware that keeps Slack's assistant status current during agent work.
|
"""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
|
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
|
tool calls are actively running, then clears it when the run exits without
|
||||||
relying on the model to post a final Slack reply.
|
relying on the model to post a final Slack reply.
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ async def set_slack_assistant_status(
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Set the assistant typing/status indicator on a Slack thread.
|
"""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
|
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
|
the thread, and Slack itself expires it after ~2 minutes — callers that
|
||||||
want it visible across longer runs must refresh it periodically.
|
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:
|
async with httpx.AsyncClient() as http_client:
|
||||||
try:
|
try:
|
||||||
response = await http_client.post(
|
response = await http_client.post(
|
||||||
f"{SLACK_API_BASE_URL}/assistants.threads.setStatus",
|
f"{SLACK_API_BASE_URL}/assistant.threads.setStatus",
|
||||||
headers=_slack_headers(),
|
headers=_slack_headers(),
|
||||||
json=payload,
|
json=payload,
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if not data.get("ok"):
|
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 False
|
||||||
return True
|
return True
|
||||||
except httpx.HTTPError:
|
except httpx.HTTPError:
|
||||||
logger.exception("Slack assistants.threads.setStatus request failed")
|
logger.exception("Slack assistant.threads.setStatus request failed")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ async def test_set_slack_assistant_status_calls_correct_endpoint(
|
||||||
assert ok is True
|
assert ok is True
|
||||||
client_cm.post.assert_awaited_once()
|
client_cm.post.assert_awaited_once()
|
||||||
args, kwargs = client_cm.post.call_args
|
args, kwargs = client_cm.post.call_args
|
||||||
assert args[0].endswith("/assistants.threads.setStatus")
|
assert args[0].endswith("/assistant.threads.setStatus")
|
||||||
assert kwargs["json"] == {
|
assert kwargs["json"] == {
|
||||||
"channel_id": "C1",
|
"channel_id": "C1",
|
||||||
"thread_ts": "1.0",
|
"thread_ts": "1.0",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue