Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(runtime): a Session bound to an unregistered backend starts, it is not refused forever (#2835)

Call White5ea621f02944
diff --git a/modules/agents/service.py b/modules/agents/service.py
index 74a09dad4..e18f302b5 100644
--- a/modules/agents/service.py
+++ b/modules/agents/service.py
@@ -133,7 +133,16 @@ class AgentService:
session_anchor: str,
workdir: str | None,
) -> RuntimeActivationResolution:
- """Resolve one exact disposable resource from durable Session fields."""
+ """Resolve one exact disposable resource from durable Session fields.
+
+ A backend with no registered agent has no runtime resource, which is a
+ definite answer, as ``runtime_activation_identity_for_request`` gives it:
+ the start goes ahead, and dispatch ends the Turn with the backend's
+ not-configured notice. Calling that absence inconclusive refused the start
+ and left the head queued, so the lane retried it every second for as long
+ as the backend stayed unregistered (a disabled backend, or an Agent
+ created for one). Only a lookup that fails is inconclusive.
+ """
agent = self.agents.get(str(backend or ""))
resolve = getattr(
@@ -142,7 +151,7 @@ class AgentService:
None,
)
if not callable(resolve):
- return RuntimeActivationResolution(authoritative=False)
+ return RuntimeActivationResolution(authoritative=True)
try:
return RuntimeActivationResolution(
authoritative=True,
diff --git a/tests/test_runtime_activation.py b/tests/test_runtime_activation.py
index 93c79d315..a48b48657 100644
--- a/tests/test_runtime_activation.py
+++ b/tests/test_runtime_activation.py
@@ -319,6 +319,25 @@ def test_session_binding_lookup_failure_is_not_resource_absence() -> None:
assert resolution == RuntimeActivationResolution(authoritative=False)
+def test_session_binding_lookup_for_an_unregistered_backend_is_resource_absence() -> None:
+ """No registered agent means no runtime resource: a definite absence, as the
+ request lookup already answers it, never an inconclusive lookup to retry."""
+
+ service = object.__new__(AgentService)
+ service.agents = {}
+
+ binding = service.runtime_activation_identity_for_session_binding(
+ "codex",
+ session_anchor="anchor",
+ workdir="/work",
+ )
+
+ assert binding == RuntimeActivationResolution(authoritative=True)
+ assert binding == service.runtime_activation_identity_for_request(
+ "codex", SimpleNamespace(session_key="route:base")
+ )
+
+
def test_request_lookup_failure_is_not_resource_absence() -> None:
service = object.__new__(AgentService)
service.agents = {
diff --git a/tests/test_session_delivery_fsm.py b/tests/test_session_delivery_fsm.py
index 28d031226..4add5b1c6 100644
--- a/tests/test_session_delivery_fsm.py
+++ b/tests/test_session_delivery_fsm.py
@@ -48,6 +48,7 @@ from core.session_turns import (
from core.agent_input import AgentInputMetadata, harness_source
from core.handlers.message_handler import MessageHandler
from core.message_context import resolve_turn_sink_key
+from modules.agents.service import AgentService
from modules.im import MessageContext
from modules.im.base import FileAttachment
from storage import message_deliveries as delivery_store
@@ -1292,6 +1293,33 @@ async def test_persisted_scheduled_start_preserves_raw_text_for_handler_routing(
assert captured["context"].platform_specific["source_actor"] == "source-session"
+def test_a_session_bound_to_an_unregistered_backend_starts_rather_than_refusing_forever(managers) -> None:
+ """A Session whose backend has no registered agent (a disabled backend, or an
+ Agent created for one while the service ran) starts its Turn: there is no
+ runtime resource to hold, and dispatch ends the Turn with the backend's
+ not-configured notice. Read as an inconclusive lookup, it was refused and left
+ queued, and the runtime-work lane retried it every second without end."""
+
+ manager, _other, _engine, _engine_b, starts = managers
+ registry = RuntimeActivationRegistry()
+ service = SimpleNamespace(agents={}, _turn_gates={}, activation_registry=registry)
+ service.runtime_activation_identity_for_session_binding = (
+ AgentService.runtime_activation_identity_for_session_binding.__get__(service)
+ )
+ manager.controller.agent_service = service
+ manager.controller.runtime_activation = registry
+
+ result = asyncio.run(
+ manager.deliver(
+ DeliveryRequest(session_id="ses_fsm", priority="p3", content="Reply with one word"),
+ context=_context(),
+ )
+ )
+
+ assert result.state == "claimed"
+ assert [text for _turn_id, text in starts] == ["Reply with one word"]
+
+
def test_first_delivery_binds_agentless_session_before_runtime_start(managers) -> None:
manager, _other, engine, _engine_b, starts = managers
with engine.begin() as conn: