Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(chats): the summary names the chat's people
raullopez-sandboxfa7f6632defb
diff --git a/core/switch_core/chats/views.py b/core/switch_core/chats/views.pyindex 33ba45738..34935c6a8 100644--- a/core/switch_core/chats/views.py+++ b/core/switch_core/chats/views.py@@ -88,8 +88,9 @@ class ChatSummary(CamelModel):can_manage: bool# The viewer owns one of the agents, which keeps them in the room.owns_agent: bool- # People in the room, so a membership change re-sends the summary.+ # The people in the room, sorted, so any membership change re-sends the summary.member_count: int+ member_user_ids: list[str]last_message: ChatLastMessage | None@@ -169,11 +170,16 @@ async def chat_summary().scalars()}bridge = await _bridge(session, room)- member_count = await session.scalar(- select(func.count())- .select_from(ClientRoom)- .join(Client, Client.id == ClientRoom.client_id)- .where(ClientRoom.room_id == room.id, Client.type == MEMBER_CLIENT_TYPE)+ member_user_ids = sorted(+ user_id+ for user_id in (+ await session.execute(+ select(Client.user_id)+ .join(ClientRoom, ClientRoom.client_id == Client.id)+ .where(ClientRoom.room_id == room.id, Client.type == MEMBER_CLIENT_TYPE)+ )+ ).scalars()+ if user_id is not None)channel_name: str | None = Noneif bridge is not None and room.external_channel_id is not None:@@ -212,7 +218,8 @@ async def chat_summary(],can_manage=can_manage,owns_agent=any(agent.owner_id == viewer_id for agent in agents),- member_count=member_count or 0,+ member_count=len(member_user_ids),+ member_user_ids=member_user_ids,last_message=(ChatLastMessage(seq=last.seq,diff --git a/core/tests/switch_core/gateway/test_chats_groups.py b/core/tests/switch_core/gateway/test_chats_groups.pyindex 0e6a1c7e7..957f8da6f 100644--- a/core/tests/switch_core/gateway/test_chats_groups.py+++ b/core/tests/switch_core/gateway/test_chats_groups.py@@ -291,6 +291,36 @@ async def test_removing_a_person_updates_the_others_summary(chats: _Harness) ->await events.stream.aclose() # type: ignore[attr-defined]+async def test_swapping_one_person_for_another_updates_the_summary(+ chats: _Harness,+) -> None:+ created = await chats.client.post(+ "/chats",+ json={"agentIds": [], "memberUserIds": [chats.bob.id], "requestId": "c1"},+ headers=chats.as_user(chats.alice),+ )+ room_id = created.json()["chat"]["roomId"]+ assert created.json()["chat"]["memberUserIds"] == sorted(+ [chats.alice.id, chats.bob.id]+ )++ events = _stream(chats, chats.alice, {}, recheck=60.0)+ assert (await events.next())[0] == "chat"+ assert (await events.next())[0] == "ready"++ removed = await chats.client.delete(+ f"/chats/{room_id}/members/{chats.bob.id}", headers=chats.as_user(chats.alice)+ )+ assert removed.status_code == 204+ assert (await chats.invite(chats.alice, room_id, chats.admin)).status_code == 200+ # The stream reads both changes in one pass: same count, other people.+ name, summary = await events.next()+ assert name == "chat"+ assert summary["memberUserIds"] == sorted([chats.alice.id, chats.admin.id])+ assert summary["memberCount"] == 2+ await events.stream.aclose() # type: ignore[attr-defined]++# ── Creating with people ─────────────────────────────────────────────────────