Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(chats): no dangling "with" in an empty chat's description

raullopez-sandbox63341bd6f408
diff --git a/core/switch_core/chats/service.py b/core/switch_core/chats/service.py
index cd1765fc1..4780d2bfd 100644
--- a/core/switch_core/chats/service.py
+++ b/core/switch_core/chats/service.py
@@ -1162,14 +1162,18 @@ class ChatService:
)
).scalar_one_or_none()
if found is None:
+ names = ", ".join(
+ [agent.name for agent in agents]
+ + [member.name for member in members]
+ )
try:
created = await self._room_service.create_room(
RoomCreateConfig(
name=name or "New Chat",
- description="Switch Console chat with "
- + ", ".join(
- [agent.name for agent in agents]
- + [member.name for member in members]
+ description=(
+ f"Switch Console chat with {names}"
+ if names
+ else "Switch Console chat"
),
agent_ids=[agent.id for agent in agents],
channel_type="direct" if direct else "channel_private",
diff --git a/core/tests/switch_core/gateway/test_chats_groups.py b/core/tests/switch_core/gateway/test_chats_groups.py
index 0b4d0126a..78030e14e 100644
--- a/core/tests/switch_core/gateway/test_chats_groups.py
+++ b/core/tests/switch_core/gateway/test_chats_groups.py
@@ -355,6 +355,10 @@ async def test_a_chat_with_no_agents_and_no_one_else(chats: _Harness) -> None:
assert chat["agents"] == []
assert chat["channelType"] == "channel_private"
assert chat["roomId"] in await _listed(chats, chats.alice)
+ async with chats.factory() as session:
+ room = await session.get(Room, chat["roomId"])
+ assert room is not None
+ assert room.description == "Switch Console chat"
async def test_one_agent_and_a_person_make_a_group(chats: _Harness) -> None: