Skip to content

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

Leave Console member clients alone in the client re-check, so signal resyncs stop failing (#887)

Abel Dantasa19f009a0915
diff --git a/core/switch_core/clients/client_lifecycle_service.py b/core/switch_core/clients/client_lifecycle_service.py
index 0fc69c206..7347e515c 100644
--- a/core/switch_core/clients/client_lifecycle_service.py
+++ b/core/switch_core/clients/client_lifecycle_service.py
@@ -367,6 +367,9 @@ class ClientLifecycleService:
for record in await self._client_store.get_all(session)
if record.tenant_id == tenant_id
and record.type not in self.COLLAB_CLIENT_TYPES
+ # As in `start_all`: the chats routes write a member client's
+ # messages themselves, so it has nothing to run.
+ and record.type != MEMBER_CLIENT_TYPE
]
present = {record.id for record in records}
# A client whose row is gone will not be started again: nothing is
diff --git a/core/tests/switch_core/clients/test_client_signals.py b/core/tests/switch_core/clients/test_client_signals.py
index ffb03989a..62c73da73 100644
--- a/core/tests/switch_core/clients/test_client_signals.py
+++ b/core/tests/switch_core/clients/test_client_signals.py
@@ -19,6 +19,7 @@ from sqlalchemy import delete
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.pool import NullPool
+from switch_core.chats import MEMBER_CLIENT_TYPE
from switch_core.clients.client_lifecycle_service import ClientLifecycleService
from switch_core.clients.client_signals import ClientSignals
from switch_core.db.models import TENANT_ZERO_ID, Agent, Client
@@ -197,6 +198,27 @@ class TestReconcile:
assert lifecycle.get(client_id) is None
+ async def test_a_console_member_client_is_not_started(
+ self, session_factory: async_sessionmaker[AsyncSession]
+ ) -> None:
+ """A Console member's client has no actor: the chats routes write its
+ messages. The re-check started one, and the real factory refuses the
+ type, which failed every resync."""
+ lifecycle = _lifecycle(session_factory)
+ async with session_factory() as session:
+ client = Client(
+ transport_user_id="@console-member:test",
+ display_name="member",
+ type=MEMBER_CLIENT_TYPE,
+ )
+ session.add(client)
+ await session.commit()
+ client_id = client.id
+
+ await lifecycle.reconcile_tenant(TENANT_ZERO_ID)
+
+ assert lifecycle.get(client_id) is None
+
async def test_a_client_stopped_on_purpose_stays_stopped(
self, session_factory: async_sessionmaker[AsyncSession]
) -> None: