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
Shorten the claim on a pending decision to the timeout plus 10 s
agent-runner353833f0220f938
diff --git a/core/switch_core/delivery/router.py b/core/switch_core/delivery/router.pyindex afbfd46ea..e2b1d2095 100644--- a/core/switch_core/delivery/router.py+++ b/core/switch_core/delivery/router.py@@ -188,6 +188,12 @@ _COMMAND_EVENT = "com.switch.command"_INSTALLS = TemplateInstallStore()+def decision_lease_seconds(timeout_seconds: float) -> float:+ """How long a worker's claim on a pending decision lasts: the decision+ call's timeout plus a margin for the delivery that follows it."""+ return timeout_seconds + 10++class RoomReads:"""What deciding one row reads about its room, read once and shared byevery agent the row is decided for.@@ -1392,7 +1398,11 @@ class MessageRouter:self._decision_max_age_seconds,)settled = 0- lease = decisions.timeout_seconds * 2 + 30+ # Long enough to cover one decision call (they run side by side), and+ # no longer: after a crash, a claimed message waits out the lease+ # before another worker takes it, and DECISION_PENDING_MAX_AGE_SECONDS+ # counts from when it was posted.+ lease = decision_lease_seconds(decisions.timeout_seconds)while True:async with tenant_session(factory, tenant_id) as session:claimed = await self._pending.claim(diff --git a/core/tests/switch_core/delivery/test_decision_routing.py b/core/tests/switch_core/delivery/test_decision_routing.pyindex b959af8d6..00cbffff7 100644--- a/core/tests/switch_core/delivery/test_decision_routing.py+++ b/core/tests/switch_core/delivery/test_decision_routing.py@@ -1018,3 +1018,12 @@ class TestAWorkspaceWithNoBackend:assert await room.reached(told) == set()assert room.room_notices == [DECISION_NOTICE]assert "refused by the server's outbound policy" in caplog.text+++def test_a_claim_lasts_the_decision_timeout_plus_a_margin():+ """After a crash a claimed message waits out the lease, so the lease must+ stay well inside the default two-minute age limit."""+ from switch_core.delivery.router import decision_lease_seconds++ assert decision_lease_seconds(5) == 15+ assert decision_lease_seconds(30) == 40