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(vibey): name the Turn on every Model Hub resolution (#2444)
Call White834e1609a327
diff --git a/docs/plans/model-hub-contracts/vibey-consumer.md b/docs/plans/model-hub-contracts/vibey-consumer.mdindex 13f1a9367..aced54ca7 100644--- a/docs/plans/model-hub-contracts/vibey-consumer.md+++ b/docs/plans/model-hub-contracts/vibey-consumer.md@@ -51,8 +51,13 @@ retains the caller's catalog alias through remapping and failover. The token isin-memory only and excluded from the launch repr. `request_headers` is a requiredmap (empty when unused) carrying any gateway correlation metadata; it is neveromitted. The caller supplies a Session-specific process scope-and the current Vibey turn id for durable turn provenance, then retires the scope-through the existing router lifecycle when the consumer shuts down.+and the current Vibey turn id on every resolution for durable turn provenance. It names+the turn itself, because the loop's later model calls run in their own tasks, where the+turn cannot be found by task. A resolution without a turn id would mark the scope's turns+ambiguous. The consumer is the service: a Vibey Session's scope and credentials live+until the service process exits, and its Turns reuse them. There is no per-Turn rotation,+so no call can fail on a credential retired under it. The token never leaves the process+and is never placed in a command environment.Planning capabilities retain the requested catalog row's authority, including foraliases. Unknown `context_window`, `max_output_tokens`, `supports_tools`, anddiff --git a/modules/agents/model_hub.py b/modules/agents/model_hub.pyindex 1f00feb15..dedbee060 100644--- a/modules/agents/model_hub.py+++ b/modules/agents/model_hub.py@@ -282,13 +282,17 @@ async def resolve_model_hub_launch(process_scope: Optional[str] = None,context: Any = None,config: Any = None,+ turn_id: Optional[str] = None,) -> ModelHubLaunch:router = getattr(controller, "model_hub_runtime", None)resolver = getattr(router, "resolve", None)if callable(resolver):- manager = getattr(controller, "session_turns", None)- turn_lookup = getattr(manager, "model_hub_turn_id_for_task", None)- turn_id = turn_lookup() if callable(turn_lookup) else None+ if turn_id is None:+ # Only the Turn's own dispatch task is found this way; a caller resolving+ # from another task (Vibey's later model calls) names its Turn itself.+ manager = getattr(controller, "session_turns", None)+ turn_lookup = getattr(manager, "model_hub_turn_id_for_task", None)+ turn_id = turn_lookup() if callable(turn_lookup) else Nonesnapshot = {"config": config} if config is not None else {}try:return await resolver(diff --git a/modules/agents/vibey/agent.py b/modules/agents/vibey/agent.pyindex 2e5f2880a..42d8b70c2 100644--- a/modules/agents/vibey/agent.py+++ b/modules/agents/vibey/agent.py@@ -515,8 +515,10 @@ class VibeyAgent(BaseAgent):async def resolve() -> ModelSelection:try:+ # Every resolution names the Turn: the loop's later model calls run in their own tasks.launch = await resolve_model_hub_launch(- self.controller, BACKEND, model, process_scope=f"{BACKEND}:{session_id}", context=context+ self.controller, BACKEND, model, process_scope=f"{BACKEND}:{session_id}", context=context,+ turn_id=turn.turn_id,)except Exception as error:turn.refusal = launch_refusal_copy(self.controller, error)diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yamlindex 032b3a27f..20bb7b7cc 100644--- a/tests/scenarios/model_hub/catalog.yaml+++ b/tests/scenarios/model_hub/catalog.yaml@@ -188,6 +188,14 @@ scenarios:test: tests/test_model_hub_vibey_consumer.py::test_sequential_vibey_retry_replaces_route_and_retains_served_provenancerelated_tests:- tests/test_model_hub_vibey_consumer.py::test_vibey_route_replacement_refuses_overlap_without_poisoning_current_request+ - id: MH-VIBEY-008+ name: Every Vibey resolution names its Turn, so each Turn on its Session's service-lifetime scope keeps exact provenance+ status: covered+ kind: lifecycle+ layer: contract+ test: tests/test_model_hub_vibey_consumer.py::test_a_vibey_sessions_turns_share_its_scope_and_each_keeps_its_provenance+ related_tests:+ - tests/test_vibey_agent.py::test_every_model_hub_resolution_names_its_turn- id: MH-CODEX-ROUTING-001name: Shared Codex authentication stays stable while concurrent aliases route and settle independentlystatus: covereddiff --git a/tests/test_model_hub_vibey_consumer.py b/tests/test_model_hub_vibey_consumer.pyindex 59c67e2a7..164c801fc 100644--- a/tests/test_model_hub_vibey_consumer.py+++ b/tests/test_model_hub_vibey_consumer.py@@ -480,6 +480,46 @@ async def test_sequential_vibey_retry_replaces_route_and_retains_served_provenanawait gateway.close()+++async def test_a_vibey_sessions_turns_share_its_scope_and_each_keeps_its_provenance(tmp_path):+ """MH-VIBEY-008: the consumer is the service, so a Session's scope lives until it exits, with no per-Turn rotation.++ Every resolution names its Turn (a later model call's too), so each Turn on the shared scope settles exact.+ """+ primary = _source("src_primary01", "Primary", vendor="anthropic", protocol="anthropic")+ turns = ("turn-first", "turn-second", "turn-third")+ service = _vibey_service(tmp_path, [primary], handles=[+ LiveInvokeHandle(_outcome(RawOutcomeKind.SUCCESS, source_id=primary.id), (b"{}",)) for _ in turns+ ])+ gateway = ModelHubTurnGateway(service)+ router = ModelHubRuntimeRouter(service=service, turn_gateway=gateway)+ tokens = []+ try:+ async with aiohttp.ClientSession() as client:+ for turn_id in turns:+ preflight = await router.resolve_hop("menu-alias", process_scope="vibey:session", turn_id=turn_id)+ later = await router.resolve_hop("menu-alias", process_scope="vibey:session", turn_id=turn_id)+ tokens += [preflight["token"], later["token"]]+ async with client.post(+ f'{later["base_url"]}/messages',+ headers={"Authorization": f'Bearer {later["token"]}'},+ json={"model": later["runtime_model"], "messages": []},+ ) as response:+ assert response.status == 200+ await response.read()+ completion = router.settle_turn(turn_id, settled_by=SETTLED_BY_TERMINAL_RESULT, ts=NOW.isoformat())+ if completion:+ await completion+ record = service.provenance.get(turn_id)+ assert record is not None and record["outcome"] == "served", turn_id+ assert record["served"]["source_id"] == primary.id+ _validate("turn-provenance.schema.json", record)+ finally:+ await gateway.close()+ assert len(set(tokens)) == 1+@pytest.mark.asyncioasync def test_vibey_route_replacement_refuses_overlap_without_poisoning_current_request(tmp_path):"""MH-VIBEY-006: a new launch cannot take an in-flight request's turn identity."""diff --git a/tests/test_vibey_agent.py b/tests/test_vibey_agent.pyindex 4281852b8..c65c4cb81 100644--- a/tests/test_vibey_agent.py+++ b/tests/test_vibey_agent.py@@ -1286,6 +1286,23 @@ async def test_a_route_model_hub_refuses_mid_run_shows_the_hubs_copy(engine, sesassert copy and harness.controller.im_client.sent[-1] == f"❌ {copy}"++async def test_every_model_hub_resolution_names_its_turn(engine, session, tmp_path, published) -> None:+ """MH-VIBEY-008: the loop's later model calls run in their own tasks, where a Turn cannot be found by task."""+ harness = _Harness(engine, tmp_path, "telegram", _tool_turn())+ resolve, turns = harness.controller._resolve, []++ async def route(*args, turn_id=None, **kwargs):+ turns.append(turn_id)+ return await resolve(*args, turn_id=turn_id, **kwargs)++ harness.controller.model_hub_runtime = SimpleNamespace(resolve=route)+ request = harness.request("look")++ await harness.agent.handle_message(request)++ assert turns == [_turn(request.context)] * 2+async def test_an_im_stop_finds_the_turn_by_its_runtime_key(engine, session, tmp_path, published) -> None:started = asyncio.Event()