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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(agents): support default runtime key fallback
cyhfac08f1a5900
diff --git a/modules/agents/service.py b/modules/agents/service.pyindex 2a5700787..a66f9ede4 100644--- a/modules/agents/service.py+++ b/modules/agents/service.py@@ -36,7 +36,7 @@ class AgentService:async def handle_message(self, agent_name: str, request: AgentRequest):agent = self.get(agent_name)- runtime_key = agent.runtime_turn_key(request)+ runtime_key = self._runtime_turn_key(agent, request)gate = self._get_turn_gate(runtime_key)await gate.lock.acquire()gate.token = uuid.uuid4().hex@@ -86,7 +86,7 @@ class AgentService:async def handle_stop(self, agent_name: str, request: AgentRequest) -> bool:agent = self.get(agent_name)- runtime_key = agent.runtime_turn_key(request)+ runtime_key = self._runtime_turn_key(agent, request)gate = self._turn_gates.get(runtime_key)if gate is not None and gate.token:self._stamp_runtime_turn(request, runtime_key, gate.token)@@ -130,6 +130,17 @@ class AgentService:self._turn_gates[runtime_key] = _RuntimeTurnGate()return self._turn_gates[runtime_key]+ @staticmethod+ def _runtime_turn_key(agent: BaseAgent, request: AgentRequest) -> str:+ runtime_key = getattr(agent, "runtime_turn_key", None)+ if callable(runtime_key):+ return runtime_key(request)+ return (+ str(getattr(request, "composite_session_id", "") or "").strip()+ or str(getattr(request, "base_session_id", "") or "").strip()+ or "default"+ )+def _runtime_turn_tokens(self, runtime_keys: set[str]) -> dict[str, str]:tokens = {}for runtime_key in runtime_keys:diff --git a/tests/test_agent_service.py b/tests/test_agent_service.pyindex 22111d9e5..95fa51ce5 100644--- a/tests/test_agent_service.py+++ b/tests/test_agent_service.py@@ -130,6 +130,26 @@ def test_agent_service_allows_distinct_runtime_keys_in_parallel() -> None:asyncio.run(_run())+def test_agent_service_falls_back_to_request_runtime_key_for_legacy_agent_stubs() -> None:+ async def _run():+ service = AgentService(controller=_Controller())+ handled = []++ async def _handle_message(request):+ handled.append(request)++ service.register(SimpleNamespace(name="legacy", handle_message=_handle_message))+ request = _request("hello", "legacy:/repo")++ await service.handle_message("legacy", request)++ assert handled == [request]+ assert request.context.platform_specific["agent_runtime_turn_key"] == "legacy:/repo"+ service.release_runtime_turn(request.context)++ asyncio.run(_run())++def test_agent_service_runtime_guard_drops_stale_emits_after_next_turn_starts() -> None:async def _run():service = AgentService(controller=_Controller())