Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(vertex): chat and Live are different endpoints, so they get different regions
Harald629eb0bd8aaf
diff --git a/docs/product/personalize-and-connect/providers-and-api-keys.md b/docs/product/personalize-and-connect/providers-and-api-keys.mdindex 65c0f97e08..20f5512071 100644--- a/docs/product/personalize-and-connect/providers-and-api-keys.md+++ b/docs/product/personalize-and-connect/providers-and-api-keys.md@@ -108,9 +108,15 @@ on the AI Studio cards, which is what makes the mistake easy to make.Two more things that bite on a real project:-- **The region.** `global` reaches the most models, but an organisation policy- can block it (`constraints/gcp.restrictEndpointUsage`). Then name a real- region such as `europe-west4` or `us-central1`.+- **The region.** `global` is where the current Gemini generation lives; named+ regions lag behind, sometimes by a whole generation. An organisation policy+ can block `global` outright (`constraints/gcp.restrictEndpointUsage` with+ `aiplatform.googleapis.com` in its deny list) — the symptom is a 403 on every+ call while the same model works in a region.+- **Realtime uses a different endpoint than everything else.** `global` serves+ no Live session at all, so the voice socket needs a named region even when the+ brain runs on `global`. That is what `[google].vertex_realtime_location` is+ for; leave it empty and Jarvis picks a region and logs which one.- **The model.** Which models a region serves, and which of them your project isallowed to use, are separate gates — a region can list a model your projectstill gets a 404 for. Regions also differ a lot from one another. If a modeldiff --git a/jarvis.toml.example b/jarvis.toml.exampleindex a3d8d0672a..a257ca1dee 100644--- a/jarvis.toml.example+++ b/jarvis.toml.example@@ -96,10 +96,19 @@ service_account_path = "~/.config/jarvis/vertex-sa.json"# and the same slug as a subagent). Leave vertex_project empty to authenticate# with a Vertex API key; set it to use a Google Cloud project with Application# Default Credentials and no key at all.+# Note that Vertex takes an API key ONLY in express mode (AQ.). A normal Cloud+# project authenticates via Application Default Credentials — no key at all:+# gcloud auth application-default login[google]vertex_mode = "auto"vertex_project = ""-vertex_location = "global" # "global" = widest Gemini availability; or e.g. "europe-west4"+# "global" carries the current Gemini generation; a named region (europe-west4,+# us-central1, …) is what data residency needs — and regions lag on new models.+vertex_location = "global"+# The Live/realtime socket is a DIFFERENT endpoint: "global" serves no Live+# session at all, so realtime needs a region. Empty = follow vertex_location+# when it names a region, else fall back to a region and log which one.+vertex_realtime_location = ""service_account_path = "" # only when this machine is not signed in with gcloud# ── Brain (multi-provider; never hardcode a single vendor) ──diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex ab3915a805..e1468a21b5 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -3547,6 +3547,13 @@ class GoogleAuthConfig(BaseModel):#: with the broadest Gemini availability; a single region (``us-central1``,#: ``europe-west4``, …) is what a data-residency requirement needs.vertex_location: str = "global"+ #: Region for the DUPLEX (Live) socket, which is a different endpoint from+ #: the one ordinary requests use: measured 2026-08-17, ``global`` serves the+ #: current Gemini generation for normal calls and opens NO Live session at+ #: all. Empty = follow ``vertex_location`` when that names a region, and+ #: fall back to a documented region (with a warning) when it is ``global``.+ #: Set it explicitly when the audio must be processed somewhere specific.+ vertex_realtime_location: str | None = None#: Service-account JSON for the project path. Exported as#: ``GOOGLE_APPLICATION_CREDENTIALS`` so the Cloud SDK auth chain finds it.#: ``None`` = use whatever Application Default Credentials already resolvediff --git a/jarvis/core/google_genai.py b/jarvis/core/google_genai.pyindex f6f102ce5b..9a723631b2 100644--- a/jarvis/core/google_genai.py+++ b/jarvis/core/google_genai.py@@ -56,7 +56,7 @@ import hashlibimport loggingimport osimport threading-from dataclasses import dataclass+from dataclasses import dataclass, replacefrom pathlib import Pathfrom typing import Any, Literal@@ -127,6 +127,13 @@ def classify_google_key(api_key: str) -> KeyRoute | None:return "aistudio"+#: Region the Live socket falls back to when ``vertex_location`` is ``global``.+#: Not a preference: ``global`` opens no Live session, so SOME region has to be+#: named. us-central1 carries the widest published model set, which makes it the+#: least surprising default — and the warning above tells the user it happened.+_REALTIME_FALLBACK_LOCATION = "us-central1"++@dataclass(frozen=True, slots=True)class VertexProject:"""The full-Vertex (Google Cloud project) half of ``[google]``.@@ -140,11 +147,45 @@ class VertexProject:project: str | Nonelocation: strservice_account_path: str | None+ #: Where the DUPLEX (Live) socket is opened. Separate from ``location``+ #: because the two are genuinely different endpoints — see+ #: :meth:`realtime_location`.+ realtime_location: str | None = None@propertydef configured(self) -> bool:return bool(self.project)+ def for_realtime(self) -> VertexProject:+ """The same project, pointed at an endpoint that can serve Live.++ Measured 2026-08-17: the ``global`` endpoint serves the current Gemini+ generation for ordinary requests but opens NO Live session at all — not+ even the ``gemini-live-*`` id its own catalogue lists there; every+ attempt closes with 1008 "Publisher model not found". Regional endpoints+ do open it. So one location cannot serve both tiers, and a config with a+ single knob would force the user to choose between a current brain and a+ working voice.++ Precedence: an explicit ``[google].vertex_realtime_location`` wins; a+ regional ``vertex_location`` is used as-is; only a ``global``+ ``vertex_location`` falls back to :data:`_REALTIME_FALLBACK_LOCATION`,+ and says so in the log — a silent region change is a data-residency+ decision nobody asked for.+ """+ if self.realtime_location:+ return replace(self, location=self.realtime_location)+ if self.location.lower() != "global":+ return self+ log.warning(+ "Vertex realtime: the global endpoint serves no Live session, so "+ "the socket falls back to %s. Set [google].vertex_realtime_location "+ "to choose the region yourself — it decides where the audio is "+ "processed.",+ _REALTIME_FALLBACK_LOCATION,+ )+ return replace(self, location=_REALTIME_FALLBACK_LOCATION)+def vertex_project_settings() -> VertexProject:"""Read the Vertex project path from ``[google]``; never raises.@@ -160,6 +201,7 @@ def vertex_project_settings() -> VertexProject:project = str(getattr(google, "vertex_project", "") or "").strip() or Nonelocation = str(getattr(google, "vertex_location", "") or "").strip() or "global"sa_path = str(getattr(google, "service_account_path", "") or "").strip() or None+ rt_location = str(getattr(google, "vertex_realtime_location", "") or "").strip() or Noneexcept Exception as exc: # noqa: BLE001 — config trouble must never break clientslog.debug("Vertex project settings unreadable (%s: %s) — using express mode.",@@ -167,7 +209,12 @@ def vertex_project_settings() -> VertexProject:exc,)return VertexProject(project=None, location="global", service_account_path=None)- return VertexProject(project=project, location=location, service_account_path=sa_path)+ return VertexProject(+ project=project,+ location=location,+ service_account_path=sa_path,+ realtime_location=rt_location,+ )def _export_service_account(path: str | None) -> None:@@ -440,18 +487,23 @@ def _project_for(route: KeyRoute) -> VertexProject | None:return settings-def build_vertex_client(api_key: str = "", *, http_options: Any | None = None) -> Any:+def build_vertex_client(+ api_key: str = "", *, http_options: Any | None = None, realtime: bool = False+) -> Any:"""Build a client PINNED to Vertex AI — no probe, no AI Studio fallback.The dedicated ``vertex`` provider family calls this instead of:func:`build_genai_client` because its endpoint is a user decision, not a- guess: a Google Cloud API key restricted to ``aiplatform.googleapis.com``- carries the ordinary ``AIza`` shape, so the shape classifier would send it- to AI Studio and it would fail on every call with an auth error that names- nothing useful. Pinning also skips the probe round-trip entirely.+ guess: an ``AIza``-shaped key would be classified as AI Studio and sent to+ the wrong host. Pinning also skips the probe round-trip entirely.``api_key`` may be empty on the Cloud project path, where ApplicationDefault Credentials do the authenticating.++ ``realtime=True`` resolves the DUPLEX endpoint instead of the ordinary one+ (:meth:`VertexProject.for_realtime`). The two differ: ``global`` serves the+ current Gemini generation for normal requests and no Live session at all, so+ a single location cannot drive both tiers."""from google import genai@@ -461,17 +513,21 @@ def build_vertex_client(api_key: str = "", *, http_options: Any | None = None) -"Vertex AI is not configured: store a Vertex AI API key (or set ""[google].vertex_project for the Google Cloud project path).")+ if realtime and settings is not None and settings.configured:+ settings = settings.for_realtime()return genai.Client(**_client_kwargs(api_key, "vertex", http_options, settings))-async def build_vertex_client_async(api_key: str = "", *, http_options: Any | None = None) -> Any:+async def build_vertex_client_async(+ api_key: str = "", *, http_options: Any | None = None, realtime: bool = False+) -> Any:"""Async twin of :func:`build_vertex_client`.Pinning means there is no probe to keep off the event loop, so this is athin wrapper — it exists so realtime callers reach the Vertex path throughthe same await-shaped door as :func:`build_genai_client_async`."""- return build_vertex_client(api_key, http_options=http_options)+ return build_vertex_client(api_key, http_options=http_options, realtime=realtime)def build_genai_client(diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.pyindex 4d1a38f2e7..eb67a05128 100644--- a/jarvis/plugins/realtime/gemini_live.py+++ b/jarvis/plugins/realtime/gemini_live.py@@ -821,8 +821,15 @@ class VertexLiveProvider(GeminiLiveProvider):return bool(config.vertex_credential_configured())async def _build_client(self) -> Any:- """Pinned to Vertex — no probe, and the Cloud project path included."""+ """Pinned to Vertex, and pointed at the endpoint that serves Live.++ ``realtime=True`` matters: the ``global`` endpoint a Vertex brain wants+ (it is where the current Gemini generation lives) opens no Live session+ whatsoever, so the socket resolves its own region.+ """import importlib # lazy (AP-26)google_genai = importlib.import_module("jarvis.core.google_genai")- return await google_genai.build_vertex_client_async(self._api_key)+ return await google_genai.build_vertex_client_async(+ self._api_key, realtime=True+ )diff --git a/tests/unit/core/test_google_vertex_project_path.py b/tests/unit/core/test_google_vertex_project_path.pyindex b08d364629..a5585a1715 100644--- a/tests/unit/core/test_google_vertex_project_path.py+++ b/tests/unit/core/test_google_vertex_project_path.py@@ -42,8 +42,67 @@ def _no_ambient_adc(monkeypatch: pytest.MonkeyPatch):monkeypatch.delenv("GOOGLE_APPLICATION_CREDENTIALS", raising=False)-def _project(project: str | None, location: str = "global", sa: str | None = None):- return gg.VertexProject(project=project, location=location, service_account_path=sa)+def _project(+ project: str | None,+ location: str = "global",+ sa: str | None = None,+ realtime_location: str | None = None,+):+ return gg.VertexProject(+ project=project,+ location=location,+ service_account_path=sa,+ realtime_location=realtime_location,+ )+++# ── chat and Live are different endpoints ────────────────────────────────────+#+# Measured 2026-08-17 against a live Cloud project: `global` serves the current+# Gemini generation for ordinary requests and opens NO Live session at all —+# every attempt closes with 1008, including the gemini-live-* id its own+# catalogue lists there. Regional endpoints do open it. One location therefore+# cannot drive both tiers, and the split below is what stops a user from having+# to choose between a current brain and a working voice.+++def test_an_explicit_realtime_region_always_wins() -> None:+ settings = _project("p", location="global", realtime_location="europe-west4")+ assert settings.for_realtime().location == "europe-west4"+ assert settings.location == "global", "the chat endpoint must be untouched"+++def test_a_regional_location_is_used_for_live_as_is() -> None:+ """No second setting needed when the user already named a region."""+ settings = _project("p", location="europe-west4")+ assert settings.for_realtime().location == "europe-west4"+++def test_a_global_location_falls_back_to_a_region_for_live() -> None:+ """Otherwise the socket would be opened where nothing answers."""+ settings = _project("p", location="global")+ resolved = settings.for_realtime()+ assert resolved.location == gg._REALTIME_FALLBACK_LOCATION+ assert resolved.location.lower() != "global"+++def test_the_fallback_keeps_the_rest_of_the_project_identical() -> None:+ settings = _project("p", location="global", sa="~/.config/jarvis/vertex-sa.json")+ resolved = settings.for_realtime()+ assert resolved.project == "p"+ assert resolved.service_account_path == "~/.config/jarvis/vertex-sa.json"+ assert resolved.configured is True+++def test_the_region_fallback_is_announced(caplog) -> None:+ """A silent region change is a data-residency decision nobody asked for."""+ import logging++ with caplog.at_level(logging.WARNING, logger="jarvis.google_genai"):+ _project("p", location="global").for_realtime()+ assert any(gg._REALTIME_FALLBACK_LOCATION in record.message for record in caplog.records), (+ "the fallback must say which region it picked"+ )# ── kwargs assembly: the two shapes never mix ────────────────────────────────@@ -200,6 +259,21 @@ def test_build_vertex_client_never_probes(assert stub_genai.calls == [{"api_key": "AIza-cloud-restricted", "vertexai": True}]+def test_the_realtime_build_resolves_its_own_endpoint(+ monkeypatch: pytest.MonkeyPatch, stub_genai: _StubGenaiModule+) -> None:+ """One config, two endpoints — the whole point of the split."""+ monkeypatch.setattr(+ gg,+ "vertex_project_settings",+ lambda: _project("prod-proj", location="global", realtime_location="us-central1"),+ )+ gg.build_vertex_client("")+ gg.build_vertex_client("", realtime=True)+ assert stub_genai.calls[0]["location"] == "global"+ assert stub_genai.calls[1]["location"] == "us-central1"++def test_build_vertex_client_uses_the_project_when_configured(monkeypatch: pytest.MonkeyPatch, stub_genai: _StubGenaiModule) -> None: