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
Bind the room's workspace while a pending decision is settled
agent-runner353fb0bdf8faf73
diff --git a/core/switch_core/delivery/router.py b/core/switch_core/delivery/router.pyindex e2b1d2095..8b8705e0b 100644--- a/core/switch_core/delivery/router.py+++ b/core/switch_core/delivery/router.py@@ -1438,7 +1438,7 @@ class MessageRouter:decisions = self._decisionsassert decisions is not Noneroom_id = pending.room_id- with log_context(room_id=room_id):+ with tenant_scope(tenant_id), log_context(room_id=room_id):async with tenant_session(self.services.session_factory, tenant_id) as session:diff --git a/core/tests/switch_core/delivery/test_decision_routing.py b/core/tests/switch_core/delivery/test_decision_routing.pyindex 00cbffff7..a6fb0aaff 100644--- a/core/tests/switch_core/delivery/test_decision_routing.py+++ b/core/tests/switch_core/delivery/test_decision_routing.py@@ -44,7 +44,9 @@ from switch_core.db.stores.room_store import DECISION_NOTICE_AT_KEY, RoomStorefrom switch_core.decision.client import DynamicDecisionClientfrom switch_core.decision.settings import DecisionAvailability, ServerDefaultfrom switch_core.delivery.decision import DECISION_NOTICE, THREAD_CONTEXT+from switch_core.delivery.recipient import AgentRecipientfrom switch_core.outbound import OutboundPolicy+from switch_core.tenant_context import current_tenant_id, no_tenantfrom switch_core.transport import InboundMessagefrom tests.conftest import TEST_KEYRINGfrom tests.routing import process_on@@ -449,6 +451,38 @@ class TestWhatTheAgentIsGiven:assert "backend=server_default" in caplog.textassert event.payload.routed_reason == "decided"+ async def test_what_follows_a_delivery_runs_in_the_rooms_workspace(+ self,+ world: World,+ room: Journey,+ service: DecisionService,+ monkeypatch: pytest.MonkeyPatch,+ ) -> None:+ """Once the decision is delivered, the follow-up work (is the agent+ connected, wake its machine if not) reads the database. The decision+ worker has no request to take a workspace from, so it binds the room's+ own; under a restricted role Postgres otherwise refuses that read, and+ the decision is logged as failed after the agent already has it."""+ workspaces: list[str | None] = []+ is_available = AgentRecipient._is_available++ async def recording(+ recipient: AgentRecipient, session: AsyncSession, agent: Agent, room_id: str+ ) -> bool:+ workspaces.append(current_tenant_id())+ return await is_available(recipient, session, agent, room_id)++ monkeypatch.setattr(AgentRecipient, "_is_available", recording)+ _stop_waking(room)+ service.pick = "helper"+ told = await room.say("bob", "can someone check why the deploy failed?", at=10)++ with no_tenant():+ assert await room.process.router.decide_pending(TENANT_ZERO_ID) == 1++ assert await room.reached(told) == {"helper"}+ assert workspaces == [TENANT_ZERO_ID]+async def test_a_mention_is_not_marked_routed(self, world: World, room: Journey) -> None: