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): a fallback names its Source from Model Hub as it is now, not the app config (#2679)
Call White682650af1749
diff --git a/core/controller.py b/core/controller.pyindex 1eeaba68b..b90761cf5 100644--- a/core/controller.py+++ b/core/controller.py@@ -432,9 +432,11 @@ class Controller:await self.model_hub_service.start_vibey_without_models()async def _model_hub_catalog_changed(self, backend: str) -> None:- """Follow a committed Model Hub catalog change for one backend."""+ """Follow a committed Model Hub catalog change for one backend.- from config.v2_config import V2Config+ Model Hub's current config is read through ``model_hub_runtime``; the app+ config (``self.config``) carries none of it, so nothing here copies it there.+ """if backend == "vibey":try:@@ -442,11 +444,6 @@ class Controller:except Exception:# The catalog change stands; the next start reconciles again.logger.warning("Vibey Agent model reconciliation failed", exc_info=True)- try:- latest = V2Config.load()- except FileNotFoundError:- return- self.config.model_hub = latest.model_hub# Each runtime moves to the committed catalog at its next turn;# nothing restarts or drains. A disabled backend has nothing to adopt.agent = getattr(getattr(self, "agent_service", None), "agents", {}).get(backend)diff --git a/modules/agents/vibey/agent.py b/modules/agents/vibey/agent.pyindex d4cdf0ea5..2205c32f8 100644--- a/modules/agents/vibey/agent.py+++ b/modules/agents/vibey/agent.py@@ -1302,12 +1302,24 @@ class VibeyAgent(BaseAgent):except Exception:logger.exception("Vibey could not deliver %d generated image(s)", len(run.hosted_images))- def _source_name(self, source_id: str) -> Optional[str]:- hub = getattr(self.config, "model_hub", None)- for source in getattr(hub, "sources", None) or ():- if getattr(source, "id", None) == source_id:- return getattr(source, "display_name", None) or None- return None+ async def _source_names(self) -> Mapping[str, str]:+ """Each Model Hub Source's display name by id, as Model Hub holds them now.++ Read through the Model Hub runtime, the one owner of its current config, off+ the event loop: ``self.config`` is the controller's app config, which carries+ no Model Hub state, and a Source renamed or added since start must show as it+ is now.+ """+ runtime = getattr(self.controller, "model_hub_runtime", None)+ if runtime is None:+ return {}+ try:+ hub = await asyncio.to_thread(runtime.snapshot)+ except Exception:+ # A name is display only: the card and the line still show the Source by id.+ logger.warning("Vibey could not read Model Hub's Sources for display names", exc_info=True)+ return {}+ return {source.id: source.display_name for source in hub.sources if source.display_name}async def _emit_hosted(self, run: _Run, activity: HostedActivity) -> None:"""One hosted call: its line for IM and its card for the Web (``core.hosted_activity``)."""@@ -1327,7 +1339,8 @@ class VibeyAgent(BaseAgent):message = run.responses.get(row_id)if message is None:return- for activity in native_activities(message, source_names=self._source_name, response_id=row_id):+ names = await self._source_names()+ for activity in native_activities(message, source_names=names.get, response_id=row_id):await self._emit_hosted(run, activity)async def _emit_proxy_hosted(self, run: _Run, event: ToolFinished) -> None:@@ -1347,9 +1360,8 @@ class VibeyAgent(BaseAgent):await self._emit_tool_line(run, call.name, dict(call.arguments))returnduration = int((time.monotonic() - started) * 1000) if started is not None else None- await self._emit_hosted(- run, proxy_activity(call, result.hosted, source_names=self._source_name, duration_ms=duration)- )+ names = await self._source_names()+ await self._emit_hosted(run, proxy_activity(call, result.hosted, source_names=names.get, duration_ms=duration))def _committed_tool_result(self, event_id: str) -> Optional[ToolResultMessage]:"""The tool result a ``ToolFinished`` names: one row, by primary key."""diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yamlindex e1a1c1ae0..c0457461a 100644--- a/tests/scenarios/model_hub/catalog.yaml+++ b/tests/scenarios/model_hub/catalog.yaml@@ -389,6 +389,7 @@ scenarios:- tests/test_vibey_agent.py::test_a_proxied_call_after_the_turn_moved_to_another_source_runs_on_the_hop_it_now_holds- tests/test_vibey_agent.py::test_a_proxied_search_names_the_source_that_refused_it- tests/test_vibey_agent.py::test_a_search_its_source_refused_names_that_source_through_the_real_gateway+ - tests/test_vibey_agent.py::test_a_fallback_names_a_source_that_existed_before_the_service_started- id: MH-HOSTED-VIBEY-005name: A hosted call goes back verbatim and pinned only to the Source that served it, within its turn while the hop still declares the tool natively or with current replay evidence; a refusal before any output (pin_unavailable, xAI's decrypt refusal) ends the send, and the loop renders the request again for a fresh hop within its bounds, portable only as the last resortstatus: covereddiff --git a/tests/test_controller_model_hub_gate.py b/tests/test_controller_model_hub_gate.pyindex 0e4a119e1..2153d1180 100644--- a/tests/test_controller_model_hub_gate.py+++ b/tests/test_controller_model_hub_gate.py@@ -232,16 +232,15 @@ def test_controller_builds_one_model_hub_aggregate_by_default_or_explicit_enable# A catalog change moves each runtime at its next turn: the agent adopts# the committed catalog, and nothing restarts.- latest = SimpleNamespace(model_hub=SimpleNamespace(agents={"codex": SimpleNamespace(mode="hub")}))controller.backend_restart_coordinator = SimpleNamespace(request_restart=AsyncMock())codex = SimpleNamespace(adopt_model_hub_catalog=AsyncMock())controller.agent_service = SimpleNamespace(agents={"codex": codex})- monkeypatch.setattr(V2Config, "load", classmethod(lambda _cls: latest))asyncio.run(captured["backend_catalog_changed"]("codex"))asyncio.run(captured["backend_catalog_changed"]("opencode"))- assert controller.config.model_hub is latest.model_hub+ # Model Hub's config is read through model_hub_runtime; the app config carries none of it.+ assert not hasattr(controller.config, "model_hub")codex.adopt_model_hub_catalog.assert_awaited_once_with()controller.backend_restart_coordinator.request_restart.assert_not_awaited()diff --git a/tests/test_vibey_agent.py b/tests/test_vibey_agent.pyindex c148294db..6eea03f02 100644--- a/tests/test_vibey_agent.py+++ b/tests/test_vibey_agent.py@@ -34,6 +34,7 @@ from typing import Any, Optionalimport pytestfrom sqlalchemy import select, update+from config.v2_config import ModelHubConfigfrom core.agent_core.agent.events import NAMED_ERROR_KINDS, ToolFinishedfrom core.agent_core.agent.recovery import UNRECORDED_EFFECTfrom core.agent_core.ai.provider import Done@@ -213,6 +214,10 @@ class _Controller:self.hub_limits = {"context_window": 32000, "max_output_tokens": 4096}# HopResolution.hosted_tools as Model Hub resolves it for the hop.self.hub_hosted_tools: dict = {}+ # The hop's Source, and the Sources Model Hub holds now (``model_hub_runtime.snapshot``). Like the+ # service's app config, ``config`` carries no Model Hub state.+ self.hub_source_id = "src_test"+ self.hub_sources: list = []self.agent: Optional[VibeyAgent] = Noneself.agent_service = SimpleNamespace(mark_runtime_turn_started=self._native_start,@@ -224,7 +229,9 @@ class _Controller:model_hub_turn_id_for_task=lambda: None,_build_context=lambda session_id: _context(platform, session_id, turn_id="redelivery", delivery_id=""),)- self.model_hub_runtime = SimpleNamespace(resolve=self._resolve)+ self.model_hub_runtime = SimpleNamespace(+ resolve=self._resolve, snapshot=lambda: ModelHubConfig(sources=list(self.hub_sources))+ )self.message_dispatcher = ConsolidatedMessageDispatcher(self)# --- controller ---------------------------------------------------------@@ -258,7 +265,7 @@ class _Controller:requested_model=requested_model,target_model=requested_model,runtime_model=requested_model,- source_id="src_test",+ source_id=self.hub_source_id,source_identity="sha256:test-source-identity",gateway_base_url="http://hub.invalid/vibey",gateway_token="hub-token",@@ -4124,6 +4131,50 @@ async def test_a_native_hosted_call_reaches_the_workbench_as_a_card_and_cited_anassert result["content_text"].startswith("Domain filters shipped.") and f"]({CHANGELOG})" in result["content_text"][email protected]("platform", ["telegram", "avibe"])+async def test_a_fallback_names_a_source_that_existed_before_the_service_started(+ engine, session, tmp_path, published, platform+) -> None:+ """MH-HOSTED-VIBEY-004: the turn's own Source refused web search natively, so the model's search runs by proxy+ and the card and IM line say where it fell back from. The Source existed before the agent was built, as on every+ upgraded install: its name comes from Model Hub as it is now, never the app config the agent was built with,+ which carries no Model Hub state, so the note never shows the raw id."""+ import httpx++ from tests.test_model_hub_l3 import _source++ refusing = "src_642f42a4dc86"+ answer = {"record": {"status": "completed", "sources": []}, "execution": {+ "mode": "proxy", "executor_origin": {"provider": "openai", "api": "openai_responses", "model": "gpt-6-luna"},+ "executor_source_id": "src_ed2426efbf28", "executor_billing": "metered",+ }}+ call = ToolCallBlock(id="toolu_1", name="web_search", arguments={"query": "avibe 3.2.1"})+ async with httpx.AsyncClient(transport=httpx.MockTransport(lambda _: httpx.Response(200, json=answer))) as client:+ harness = _Harness(+ engine,+ tmp_path,+ platform,+ [[Done(AssistantMessage((call,), ORIGIN, "tool_use"))], [Done(assistant("done"))]],+ gateway_client=client,+ )+ # Both Sources were in Model Hub before the agent above was built.+ harness.controller.hub_sources = [+ _source(refusing, "Fake OpenAI A"), _source("src_ed2426efbf28", "Fake OpenAI B")+ ]+ harness.controller.hub_source_id = refusing+ harness.controller.hub_hosted_tools = {"web_search": {"native": "unsupported", "replay": "unsupported", "refused": True}}+ await harness.agent.handle_message(harness.request("what is new in avibe 3.2.1?"))++ with engine.connect() as conn:+ [event] = conn.execute(+ select(agent_events).where(agent_events.c.session_id == SESSION, agent_events.c.event_type == "tool_call")+ ).mappings().all()+ card = json.loads(event["content_json"])["hosted"]+ assert card["fallback_from"] == {"source_id": refusing, "source_name": "Fake OpenAI A"}+ assert card["source_name"] == "Fake OpenAI B"+ assert "Fake OpenAI A" in event["content_text"] and refusing not in event["content_text"].replace("\\", "")++async def test_a_proxied_hosted_result_shows_once_its_result_is_committed(engine, session, tmp_path, published) -> None:"""The record the executor returned, read back from the committed tool-result row."""from modules.agents.vibey.agent import _Run