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
Fit the auto-route tests to main's session tokens and role matrix
agent-runner353a87ef7fb4f4b
diff --git a/core/tests/switch_core/gateway/role_matrix/harness.py b/core/tests/switch_core/gateway/role_matrix/harness.pyindex 3c64dbecb..6af25bfef 100644--- a/core/tests/switch_core/gateway/role_matrix/harness.py+++ b/core/tests/switch_core/gateway/role_matrix/harness.py@@ -72,6 +72,8 @@ from switch_core.db.stores.switch_core_process_store import SwitchCoreProcessStofrom switch_core.db.stores.template_store import TemplateStorefrom switch_core.db.stores.usage_store import UsageStorefrom switch_core.db.stores.user_store import UserStore+from switch_core.decision.client import DynamicDecisionClient+from switch_core.decision.settings import DecisionAvailabilityfrom switch_core.feature_flags import KNOWN_FEATURE_FLAGSfrom switch_core.gateway.app import create_gateway_appfrom switch_core.gateway.auth import create_jwt@@ -82,6 +84,7 @@ from switch_core.management.wiring import (mount_gateway_routes,)from switch_core.organization_directory import LocalDirectory+from switch_core.outbound import OutboundPolicyfrom switch_core.process_lease import ProcessLeasefrom switch_core.providers.github import GitHubConnections, GitHubReachfrom switch_core.signals import SignalBus@@ -378,6 +381,20 @@ def build_gateway(session_factory: async_sessionmaker[AsyncSession]) -> FastAPI:_store=OrganizationAppCredentialStore(settings.keyring),)gateway.state.controller_revoker = management.service+ # Auto-route's decision client, asking nothing: the decision settings+ # routes read and save the workspace's row, and Test meets a service that+ # is down.+ gateway.state.decision_client = DynamicDecisionClient(+ session_factory=session_factory,+ availability=DecisionAvailability.from_config(settings),+ keyring=settings.keyring,+ client=httpx.AsyncClient(transport=httpx.MockTransport(_decision_down)),+ guarded_client=httpx.AsyncClient(transport=httpx.MockTransport(_decision_down)),+ outbound_policy=OutboundPolicy.parse(""),+ timeout_seconds=1.0,+ telemetry=None,+ cache_seconds=0,+ )gateway.state.github_connections = _github()# The clients the room and chat services think are running: `World` adds# each agent it makes, as a running client would announce itself.@@ -386,6 +403,10 @@ def build_gateway(session_factory: async_sessionmaker[AsyncSession]) -> FastAPI:return gateway+def _decision_down(_request: httpx.Request) -> httpx.Response:+ return httpx.Response(503)++def _github() -> GitHubConnections:"""The server's GitHub App, answering for GitHub rather than asking it."""with tempfile.NamedTemporaryFile("w", suffix=".json", delete=False) as file:diff --git a/core/tests/switch_core/gateway/role_matrix/routes.py b/core/tests/switch_core/gateway/role_matrix/routes.pyindex ff33ace30..68914c389 100644--- a/core/tests/switch_core/gateway/role_matrix/routes.py+++ b/core/tests/switch_core/gateway/role_matrix/routes.py@@ -505,6 +505,20 @@ ROUTES: dict[str, Case] = {"DELETE /gateway/rooms/{room_id}/roles/{name}": delete(f"{G}/rooms/{{room_role}}/roles/reviewer", owner_or_admins()),+ "GET /gateway/decision-settings": get(f"{G}/decision-settings", admins()),+ "PUT /gateway/decision-settings": put(+ f"{G}/decision-settings", admins(), json={"backend": "none"}+ ),+ "DELETE /gateway/decision-settings": delete(f"{G}/decision-settings", admins()),+ "POST /gateway/decision-settings/test": post(+ f"{G}/decision-settings/test", admins(), json={"backend": "none"}+ ),+ "PUT /gateway/rooms/{room_id}/auto-route": put(+ f"{G}/rooms/{{room}}/auto-route",+ owner_or_admins(),+ json={"on": False},+ why="Write access to the room; this room's write access is private.",+ ),"PUT /gateway/rooms/{room_id}/protection": put(f"{G}/rooms/{{room}}/protection",owner_or_admins(),diff --git a/core/tests/switch_core/gateway/test_decision_settings.py b/core/tests/switch_core/gateway/test_decision_settings.pyindex 492de5202..adb345218 100644--- a/core/tests/switch_core/gateway/test_decision_settings.py+++ b/core/tests/switch_core/gateway/test_decision_settings.py@@ -9,6 +9,7 @@ from __future__ import annotationsimport jsonfrom collections.abc import AsyncIterator+from datetime import UTC, datetimefrom types import SimpleNamespacefrom typing import Any@@ -136,7 +137,13 @@ def _as(app: FastAPI, user: User, tenant_id: str = TENANT_ZERO_ID) -> httpx.Asynbase_url="http://test",cookies={"switch_auth": create_jwt(- user.id, user.email, user.role, KEYRING, tenant_id+ user.id,+ user.email,+ user.role,+ KEYRING,+ tenant_id,+ session_version=0,+ auth_time=datetime.now(UTC),)},)diff --git a/core/tests/switch_core/gateway/test_room_auto_route.py b/core/tests/switch_core/gateway/test_room_auto_route.pyindex ab7161ad6..492eb0f95 100644--- a/core/tests/switch_core/gateway/test_room_auto_route.py+++ b/core/tests/switch_core/gateway/test_room_auto_route.py@@ -10,6 +10,7 @@ from __future__ import annotationsimport uuidfrom collections.abc import AsyncIterator+from datetime import UTC, datetimefrom types import SimpleNamespacefrom typing import Any@@ -177,7 +178,13 @@ def _as(app: FastAPI, user: User) -> httpx.AsyncClient:base_url="http://test",cookies={"switch_auth": create_jwt(- user.id, user.email, user.role, KEYRING, TENANT_ZERO_ID+ user.id,+ user.email,+ user.role,+ KEYRING,+ TENANT_ZERO_ID,+ session_version=0,+ auth_time=datetime.now(UTC),)},)