Skip to content

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.

feat(voice): one-step local voice setup that starts with Jarvis

rubenluetke10-beep9f5fb424e421
diff --git a/jarvis/local_models/autostart.py b/jarvis/local_models/autostart.py
index b87cd4f7d0..8fe01306b1 100644
--- a/jarvis/local_models/autostart.py
+++ b/jarvis/local_models/autostart.py
@@ -230,7 +230,10 @@ async def run_once(
if not ok:
return record
record["started"] = True
- model = _chat_model(cfg)
+ # Local voice owns its own model and load order. Warming a dormant chat
+ # pick here competes with speech models and can evict the voice brain.
+ primary = str(getattr(getattr(cfg, "brain", None), "primary", "") or "")
+ model = _chat_model(cfg) if primary == SERVER_PROVIDER_ID else ""
if model and await (warm or _default_warm)(root, model, _keep_alive(cfg, model)):
record["warmed"] = model
return record
diff --git a/jarvis/plugins/realtime/openai_realtime.py b/jarvis/plugins/realtime/openai_realtime.py
index 04b6da7f77..513ef0d4d2 100644
--- a/jarvis/plugins/realtime/openai_realtime.py
+++ b/jarvis/plugins/realtime/openai_realtime.py
@@ -362,6 +362,11 @@ class _OpenAIRealtimeSession:
_RESPONSE_STALL_S if response_start_timeout_s is None else response_start_timeout_s
),
)
+ # A local cascade can emit its text before the TTS has produced PCM.
+ # Its declared startup budget covers that first-audio preparation too.
+ self._first_audio_timeout_s = (
+ self._response_start_timeout_s if response_start_timeout_s is not None else None
+ )
# A capacity-one server must release the old pipeline before opening a
# replacement. Hosted endpoints retain make-before-break; self-hosted
# endpoints can opt into serial replacement plus bounded drain retries.
@@ -418,7 +423,7 @@ class _OpenAIRealtimeSession:
now = time.monotonic()
self._response_started_at = now
self._last_response_activity = now
- self._response_output_started = False
+ self._response_output_started = self._response_audio_started = False
self._last_item_id = ""
# Whether THIS response's transcript arrived as a delta stream. Servers
# split here: OpenAI streams it token by token, a self-hosted stack that
@@ -542,6 +547,8 @@ class _OpenAIRealtimeSession:
self._last_response_activity = time.monotonic()
if event_type in _RESPONSE_OUTPUT_EVENTS:
self._response_output_started = True
+ if event_type == "response.output_audio.delta":
+ self._response_audio_started = True
if event_type == "response.output_audio.delta":
self._last_item_id = str(getattr(event, "item_id", "") or "")
yield _ProviderEvent(
@@ -636,7 +643,7 @@ class _OpenAIRealtimeSession:
elif len(self._accepted_response_ids) == 1:
self._accepted_response_ids.pop()
self._response_idle.set()
- self._response_output_started = False
+ self._response_output_started = self._response_audio_started = False
usage = _usage_from_response(getattr(event, "response", None))
if usage is not None:
# Every response bills its own pass over the session context,
@@ -816,7 +823,7 @@ class _OpenAIRealtimeSession:
await self._conn.response.cancel()
finally:
self._response_idle.set()
- self._response_output_started = False
+ self._response_output_started = self._response_audio_started = False
async def send_tool_result(self, call_id: str, name: str, result: dict[str, Any]) -> None:
del name
@@ -848,7 +855,7 @@ class _OpenAIRealtimeSession:
now = time.monotonic()
self._response_started_at = now
self._last_response_activity = now
- self._response_output_started = False
+ self._response_output_started = self._response_audio_started = False
marker = uuid4().hex
self._pending_response_markers.add(marker)
response: dict[str, Any] = {
@@ -861,7 +868,7 @@ class _OpenAIRealtimeSession:
except BaseException:
self._pending_response_markers.discard(marker)
self._response_idle.set()
- self._response_output_started = False
+ self._response_output_started = self._response_audio_started = False
raise
@staticmethod
@@ -924,7 +931,7 @@ class _OpenAIRealtimeSession:
now = time.monotonic()
self._response_started_at = now
self._last_response_activity = now
- self._response_output_started = False
+ self._response_output_started = self._response_audio_started = False
self._server_heard_user_since_response = False
self._auto_adopted_unanswered_input = True
await self._rearm_session_contract()
@@ -1051,6 +1058,20 @@ class _OpenAIRealtimeSession:
return False
return time.monotonic() >= self._transcript_deadline
+ def _response_stall_budget_s(self) -> float:
+ contract = self._session_contract or {}
+ modalities = contract.get(
+ "output_modalities", contract.get("modalities", ["audio"])
+ )
+ if (
+ self._first_audio_timeout_s is not None
+ and not self._response_audio_started
+ and not self._response_had_tool_calls
+ and "audio" in modalities
+ ):
+ return self._first_audio_timeout_s
+ return _RESPONSE_STALL_S
+
def _response_lifecycle_stalled(self) -> bool:
"""Whether an in-flight response exceeded its current phase budget.
@@ -1068,7 +1089,8 @@ class _OpenAIRealtimeSession:
if self._response_idle.is_set():
return False
if self._response_output_started:
- return time.monotonic() - self._last_response_activity >= _RESPONSE_STALL_S
+ gap = time.monotonic() - self._last_response_activity
+ return gap >= self._response_stall_budget_s()
return time.monotonic() - self._response_started_at >= self._response_start_timeout_s
def _maybe_begin_rebuild(self) -> None:
@@ -1076,7 +1098,7 @@ class _OpenAIRealtimeSession:
if self._response_output_started:
reason = (
"in-flight response stopped producing events for "
- f"{_RESPONSE_STALL_S:.0f} s after output began — "
+ f"{self._response_stall_budget_s():.0f} s after output began — "
"response.done is not coming"
)
else:
@@ -1246,7 +1268,7 @@ class _OpenAIRealtimeSession:
now = time.monotonic()
self._response_started_at = now
self._last_response_activity = now
- self._response_output_started = False
+ self._response_output_started = self._response_audio_started = False
self._server_heard_user_since_response = False
self._auto_adopted_unanswered_input = False
self._response_idle.set()
@@ -1278,7 +1300,7 @@ class _OpenAIRealtimeSession:
self._pending_response_markers.clear()
self._accepted_response_ids.clear()
self._response_idle.set()
- self._response_output_started = False
+ self._response_output_started = self._response_audio_started = False
try:
if self._connection_is_open:
try:
@@ -1661,16 +1683,10 @@ class LocalRealtimeProvider:
# and quietly routing a call into one the user did not pick is the opposite
# of what a local card is for.
implicit_usage_fallback_allowed = False
- # Eagerly warmed even when configured as a FALLBACK. This card is a local
- # process: warming costs no account round-trip and no metered tokens,
- # while its cold start is the longest of any transport (45-90 s of model
- # loading). Live 2026-08-10: with a subscription primary whose token had
- # expired, the un-warmed local fallback was still stone cold when the
- # first call arrived — the call died with "try again in about a minute"
- # on a machine that could have answered it. The GPU-oversubscription
- # caveat behind opt-in fallback warming targets stacking MULTIPLE native
- # model stacks; this is the single local stack the user explicitly chose.
- eager_warm_as_fallback = True
+ # Keep the stack warm when selected as the primary voice provider. Merely
+ # configuring it as a fallback must not reserve several GB of GPU/RAM.
+ # A fallback can still start on demand through its normal open_session.
+ eager_warm_as_fallback = False
# Small self-hosted brains prefill the whole instruction block EVERY turn;
# the full ~24k-char profile cost 7.8 s of LLM time per answer against
# qwen2.5:7b (live 2026-08-07). The session builder honors this capability
diff --git a/jarvis/realtime/factory.py b/jarvis/realtime/factory.py
index da84e3b3ed..86f648b0b6 100644
--- a/jarvis/realtime/factory.py
+++ b/jarvis/realtime/factory.py
@@ -315,17 +315,14 @@ async def realtime_warm_selected_transports(cfg: Any) -> None:
async def realtime_prespawn_transports(cfg: Any) -> None:
- """Fire the spawn-only prestart for every explicitly selected provider.
+ """Prestart the selected primary and only explicitly lightweight fallbacks.
Runs BEFORE the warm worker's gates on purpose: the transport that
declares this capability today is the managed local server, whose models
load 45-90 s in a SEPARATE process — the earlier that spawn fires, the
earlier the first call can connect, and nothing on the boot path ever
- waits for it. Unlike eager warming, position does not matter here: a
- prespawn is bounded to starting a process, so an explicitly configured
- FALLBACK is prestarted too — that fallback sitting stone cold is exactly
- what stranded the first call of 2026-08-10, when the subscription primary
- was down and the local fallback had never been started. A capability
+ waits for it. The spawned process still loads models and consumes memory,
+ so fallback prestart follows the same opt-in as eager warming. A capability
probe, never a provider-id check (AP-21); an installed-but-unselected
plugin must never spawn a process on its own. Best-effort by contract —
one broken plugin never stops the others and no failure reaches the
@@ -340,9 +337,13 @@ async def realtime_prespawn_transports(cfg: Any) -> None:
"configured voice mode."
)
return
- for provider_id in _explicit_provider_ids(cfg):
+ for position, provider_id in enumerate(_explicit_provider_ids(cfg)):
try:
provider_cls = load(_GROUP, provider_id, protocol=RealtimeProvider)
+ if position > 0 and not bool(
+ getattr(provider_cls, "eager_warm_as_fallback", False)
+ ):
+ continue
prespawn = getattr(provider_cls, "prespawn_transport", None)
if callable(prespawn):
await prespawn(cfg)
diff --git a/jarvis/realtime/local_server/brain_link.py b/jarvis/realtime/local_server/brain_link.py
index 608ce3ddbc..9aebdf1911 100644
--- a/jarvis/realtime/local_server/brain_link.py
+++ b/jarvis/realtime/local_server/brain_link.py
@@ -217,6 +217,8 @@ def list_brain_choices(
base = _ollama_base()
if current_model.endswith(_MANAGED_VOICE_SUFFIX):
current_model = current_model[: -len(_MANAGED_VOICE_SUFFIX)]
+ from jarvis.brain.ollama_inventory import is_hidden_alias
+
served = _ollama_models(base, timeout)
reachable = served is not None
choices: list[dict[str, object]] = []
@@ -225,7 +227,7 @@ def list_brain_choices(
# The managed 8k alias is an implementation detail derived from its
# base tag. Listing both made one selection look like two models and
# encouraged users to select an alias that is recreated automatically.
- if name.endswith(_MANAGED_VOICE_SUFFIX) or not _usable_tag(name):
+ if (is_hidden_alias(name) and name != current_model) or not _usable_tag(name):
continue
seen.add(name)
fits = _fits(size, usable_gb)
diff --git a/jarvis/realtime/local_server/supervisor.py b/jarvis/realtime/local_server/supervisor.py
index cd1ec07f08..2dc3bfa26b 100644
--- a/jarvis/realtime/local_server/supervisor.py
+++ b/jarvis/realtime/local_server/supervisor.py
@@ -895,10 +895,10 @@ def _boot_status(*, booting: bool) -> dict[str, object]:
)
expected = boot_progress.expected_boot_s(stats)
remaining: float | None = None
- # Past twice the historical boot time the countdown would be a lie;
- # showing only the stage is the honest degradation.
- if expected is not None and elapsed <= 2.0 * expected:
- remaining = max(5.0, expected - elapsed)
+ # Once the measured estimate is exceeded, show the loading stage rather
+ # than an endless five-second countdown that promises imminent readiness.
+ if expected is not None and elapsed < expected:
+ remaining = expected - elapsed
payload.update(
{
"starting": True,
diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx
index 101abb60d0..61d8f867e5 100644
--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx
@@ -1145,6 +1145,40 @@ describe("managed local realtime model setup", () => {
expect(screen.getByText("MOSS-TTS-Nano 100M")).toBeTruthy();
expect(screen.getByText("Integration pending")).toBeTruthy();
});
+
+ it.each([true, false])("activates local voice only after a successful speech test (%s)", async (success) => {
+ const calls: string[] = [];
+ vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ calls.push(url);
+ const body = url.endsWith("/model-catalog") ? {
+ brain: { current: "voice-brain", models: [{ id: "voice-brain", label: "Voice brain", installed: true, fits: true, size_gb: 3 }] },
+ current: "voice-tts", models: [{ id: "voice-tts", label: "Voice TTS", selectable: true, runtime_ready: true, languages: ["en"] }],
+ hearing: { label: "Local recognition" },
+ } : url.endsWith("/setup") ? (success ? { smoke: { first_audio_ms: 100 } } : { detail: "Speech test failed" })
+ : url.endsWith("/realtime/switch") ? { ok: true, restart_required: false }
+ : {};
+ return { ok: success || !url.endsWith("/setup"), status: success ? 200 : 409,
+ json: async () => body, text: async () => JSON.stringify(body) } as Response;
+ }));
+ const card = localRealtimeCard();
+ card.active = false;
+ card.experimental = true;
+ card.managed_server!.ready = true;
+ renderCard(card);
+ fireEvent.click(await screen.findByRole("button", { name: "Apply, test & use local voice" }));
+ await waitFor(() => expect(calls.some((url) => url.endsWith("/setup"))).toBe(true));
+ if (success) {
+ await waitFor(() => expect(calls).toContain("/api/realtime/switch"));
+ await waitFor(() => expect(calls).toContain("/api/settings/voice-mode"));
+ expect(calls.findIndex((url) => url.endsWith("/setup"))).toBeLessThan(calls.indexOf("/api/realtime/switch"));
+ } else {
+ await screen.findByText("Speech test failed");
+ expect(calls).not.toContain("/api/realtime/switch");
+ expect(calls).not.toContain("/api/settings/voice-mode");
+ expect(screen.queryByText(enLocale.apikeys_view.managed_setup_testing)).toBeNull();
+ }
+ });
});
describe("managed server badge", () => {
diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
index eac63a0a5a..6a71fcf294 100644
--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
@@ -5,6 +5,7 @@ import { ApiKeyForm } from "@/components/ApiKeyForm";
import { BrainModelSelector } from "@/components/BrainModelSelector";
import { OpenRouterTtsControls } from "@/components/OpenRouterTtsVoicePicker";
import { RealtimeOptionsControl } from "@/components/RealtimeOptionsControl";
+import { putVoiceMode } from "@/lib/voiceEngineMode";
import { ProviderLogo } from "@/components/providers/ProviderLogo";
import { useRowGestures } from "@/components/providers/rowGestures";
import { Button } from "@/components/ui/button";
@@ -1593,10 +1594,18 @@ export function ProviderCard({
// probe so the card does not visibly flicker while saying
// "one moment".
descriptor.codex_status?.reason_code === "busy") && (
- <RealtimeOptionsControl
- providerId={descriptor.id}
- healthActive={descriptor.active}
- />
+ descriptor.managed_server ? (
+ <details className="text-xs text-muted-foreground">
+ <summary className="cursor-pointer">
+ {t("apikeys_view.managed_protocol_options")}
+ </summary>
+ <div className="pt-3">
+ <RealtimeOptionsControl providerId={descriptor.id} healthActive={descriptor.active} />
+ </div>
+ </details>
+ ) : (
+ <RealtimeOptionsControl providerId={descriptor.id} healthActive={descriptor.active} />
+ )
)}
{/* Footer: the live connectivity test, visually separated from the
@@ -2228,21 +2237,28 @@ function ManagedServerPanel({
useEffect(() => {
if (running || !installed) return;
let cancelled = false;
+ let timer: number | undefined;
const read = async () => {
+ let delay = 20_000;
try {
const next = await managedServerStatus();
if (!cancelled) setRuntime(next.runtime ?? null);
+ if (next.runtime?.boot?.starting || next.runtime?.ready === false || setupBusy || lifecycleBusy) {
+ delay = 1500;
+ }
} catch {
if (!cancelled) setRuntime(null);
+ delay = 5000;
+ } finally {
+ if (!cancelled) timer = window.setTimeout(read, delay + Math.random() * 500);
}
};
void read();
- const timer = window.setInterval(read, 20_000);
return () => {
cancelled = true;
- window.clearInterval(timer);
+ window.clearTimeout(timer);
};
- }, [running, installed]);
+ }, [running, installed, setupBusy, lifecycleBusy]);
if (!status) return null;
@@ -2364,7 +2380,7 @@ function ManagedServerPanel({
) => {
if (!brainModel || !voiceModel) return;
setError(null);
- setSetupNote(null);
+ setSetupNote(t("apikeys_view.managed_setup_testing"));
setSetupBusy(true);
try {
const choice = catalog?.brain.models.find((item) => item.id === brainModel);
@@ -2374,8 +2390,14 @@ function ManagedServerPanel({
await downloadBrain(brainModel);
}
const result = await managedServerSetup(brainModel, voiceModel);
+ if (!descriptor.active) {
+ await switchRealtimeProvider(descriptor.id, descriptor.experimental === true);
+ }
+ await putVoiceMode("realtime");
+ window.dispatchEvent(new CustomEvent("jarvis:realtime-switched"));
const latency = result.smoke.first_audio_ms;
setSelectedBrain(brainModel);
+ setSelectedVoice(voiceModel);
setSetupNote(
latency === null
? t("apikeys_view.managed_setup_complete")
@@ -2387,6 +2409,7 @@ function ManagedServerPanel({
await loadCatalog();
onChanged();
} catch (err) {
+ setSetupNote(null);
setError(err instanceof Error ? err.message : String(err));
} finally {
setSetupBusy(false);
@@ -2573,6 +2596,9 @@ function ManagedServerPanel({
{!running && catalog && (
<div className="space-y-3" data-testid="managed-model-picker">
+ <p className="text-xs text-muted-foreground" role="status">
+ {t(descriptor.active ? "apikeys_view.managed_selected" : "apikeys_view.managed_not_selected")}
+ </p>
<div className="grid gap-2 sm:grid-cols-3">
<label className="space-y-1.5">
<span className="flex items-center gap-1.5 text-xs font-medium">
diff --git a/jarvis/ui/web/provider_spec.py b/jarvis/ui/web/provider_spec.py
index 1051f0669d..8c5d96df96 100644
--- a/jarvis/ui/web/provider_spec.py
+++ b/jarvis/ui/web/provider_spec.py
@@ -953,7 +953,7 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
# and bundles no server.
ProviderSpec(
id="local-realtime",
- label="Self-hosted realtime (OpenAI-compatible)",
+ label="Local voice",
tier="realtime",
auth_mode="none",
secret_keys=(),
diff --git a/tests/unit/local_models/test_autostart.py b/tests/unit/local_models/test_autostart.py
index 4b144c2dca..865fd390a2 100644
--- a/tests/unit/local_models/test_autostart.py
+++ b/tests/unit/local_models/test_autostart.py
@@ -99,7 +99,7 @@ def test_the_default_is_on_even_without_an_ollama_card() -> None:
@pytest.mark.asyncio
async def test_run_once_starts_a_stopped_server_and_warms_the_chat_pick() -> None:
- cfg = _cfg(chat="qwen3.5:4b")
+ cfg = _cfg(primary="ollama", chat="qwen3.5:4b")
cfg.brain.providers["ollama"].models["qwen3.5:4b"] = OllamaModelOptions(keep_alive="2h")
started: list[str] = []
warmed: list[tuple[str, str, Any]] = []
@@ -129,7 +129,7 @@ async def test_run_once_only_warms_a_running_server() -> None:
return True
record = await autostart.run_once(
- _cfg(chat="qwen3.5:4b"),
+ _cfg(primary="ollama", chat="qwen3.5:4b"),
status=lambda: {"installed": True, "running": True},
start=lambda: (_ for _ in ()).throw(AssertionError("must not start")),
warm=_warm,
@@ -138,6 +138,23 @@ async def test_run_once_only_warms_a_running_server() -> None:
assert warmed == [f"qwen3.5:4b:{autostart.DEFAULT_KEEP_ALIVE}"]
+async def test_local_voice_does_not_prewarm_an_unselected_chat_model() -> None:
+ warmed: list[str] = []
+
+ async def warm(_root: str, model: str, _keep_alive: Any) -> bool:
+ warmed.append(model)
+ return True
+
+ result = await autostart.run_once(
+ _cfg(realtime="local-realtime", chat="unused-large-chat-model"),
+ status=lambda: {"installed": True, "running": True},
+ warm=warm,
+ )
+ assert result["warmed"] == ""
+ assert warmed == []
+
+
@pytest.mark.asyncio
async def test_run_once_never_installs_and_never_starts_a_remote_server() -> None:
absent = await autostart.run_once(
diff --git a/tests/unit/realtime/local_server/test_engine.py b/tests/unit/realtime/local_server/test_engine.py
index 5e7d68d5c5..796775e620 100644
--- a/tests/unit/realtime/local_server/test_engine.py
+++ b/tests/unit/realtime/local_server/test_engine.py
@@ -112,6 +112,9 @@ class TestBrainResolution:
"_ollama_models",
lambda base, timeout: [
("qwen3.5:4b", 3.4),
+ ("qwen3.5:4b-voice-32k", 3.4),
+ ("qwen3.5:4b-voice-64k", 3.4),
+ ("qwen3.5-4b-jarvis-ab12cd34:latest", 3.4),
("nemotron-cascade-2:latest", 24.0),
("nomic-embed-text:latest", 0.3), # never a voice brain
],
@@ -122,6 +125,7 @@ class TestBrainResolution:
assert payload["reachable"] is True
by_id = {entry["id"]: entry for entry in payload["models"]}
assert "nomic-embed-text:latest" not in by_id
+ assert not any("-voice-" in name or "-jarvis-" in name for name in by_id)
assert by_id["qwen3.5:4b"]["installed"] is True
assert by_id["qwen3.5:4b"]["fits"] is True
assert by_id["qwen3.5:4b"]["current"] is True
diff --git a/tests/unit/realtime/local_server/test_supervisor.py b/tests/unit/realtime/local_server/test_supervisor.py
index 3185469d60..a3a91d78d7 100644
--- a/tests/unit/realtime/local_server/test_supervisor.py
+++ b/tests/unit/realtime/local_server/test_supervisor.py
@@ -42,6 +42,13 @@ def _local_models_switch_on(monkeypatch: pytest.MonkeyPatch) -> None:
provider.autostart = True
cfg.brain.providers["ollama"] = provider
monkeypatch.setattr("jarvis.core.config.load_config", lambda: cfg)
+ # Lifecycle fixtures must not depend on or query the developer's GPU and
+ # live model server. Individual probe tests supply their own fake client.
+ monkeypatch.setattr(
+ "jarvis.hardware.detection.free_accelerator_gb",
+ lambda: (16.0, "nvidia-smi"),
+ )
+ monkeypatch.setattr(supervisor, "_probe_client", lambda: None)
def _spawn_ready(monkeypatch, tmp_path: Path) -> list[dict[str, Any]]:
@@ -160,16 +167,7 @@ def test_pool_url_normalizes_every_supported_input_shape() -> None:
def test_runtime_probe_requires_a_valid_loaded_pool(monkeypatch) -> None:
- import http.client
-
- class _Response:
- status = 200
-
- def __init__(self, payload: object) -> None:
- self._payload = json.dumps(payload).encode("utf-8")
-
- def read(self, limit: int) -> bytes:
- return self._payload[:limit]
+ import httpx
payload = {
"size": 4,
@@ -182,34 +180,24 @@ def test_runtime_probe_requires_a_valid_loaded_pool(monkeypatch) -> None:
],
}
- class _Connection:
- def __init__(self, *args: Any, **kwargs: Any) -> None:
- pass
-
- def request(self, *args: Any, **kwargs: Any) -> None:
- pass
-
- def getresponse(self) -> _Response:
- return _Response(payload)
-
- def close(self) -> None:
- pass
-
- monkeypatch.setattr(http.client, "HTTPConnection", _Connection)
- assert supervisor.probe_runtime("http://localhost:8765") == {
- "size": 4,
- "in_use": 3,
- "available": 1,
- "active": 1,
- "draining": 1,
- "stuck": 1,
- }
+ with httpx.Client(
+ transport=httpx.MockTransport(lambda request: httpx.Response(200, json=payload))
+ ) as client:
+ monkeypatch.setattr(supervisor, "_probe_client", lambda: client)
+ assert supervisor.probe_runtime("http://localhost:8765") == {
+ "size": 4,
+ "in_use": 3,
+ "available": 1,
+ "active": 1,
+ "draining": 1,
+ "stuck": 1,
+ }
- payload["in_use"] = 2
- assert supervisor.probe_runtime("http://localhost:8765") is None
- payload["in_use"] = 3
- payload["units"] = []
- assert supervisor.probe_runtime("http://localhost:8765") is None
+ payload["in_use"] = 2
+ assert supervisor.probe_runtime("http://localhost:8765") is None
+ payload["in_use"] = 3
+ payload["units"] = []
+ assert supervisor.probe_runtime("http://localhost:8765") is None
def test_only_an_abandoned_full_pool_has_no_usable_capacity() -> None:
@@ -2104,12 +2092,15 @@ def _write_booting_pidfile(tmp_path: Path, *, spawned_ago_s: float) -> None:
)
-def test_status_reports_stage_and_eta_while_an_owned_child_boots(monkeypatch, tmp_path) -> None:
[email protected]("spawned_ago_s", [20.0, 90.0])
+def test_status_reports_stage_and_eta_while_an_owned_child_boots(
+ monkeypatch, tmp_path, spawned_ago_s
+) -> None:
monkeypatch.setenv("JARVIS_DATA_DIR", str(tmp_path))
monkeypatch.setattr(supervisor, "_port_open", lambda port, timeout=1.0: False)
monkeypatch.setattr(supervisor, "probe_runtime", lambda *args, **kwargs: None)
monkeypatch.setattr(supervisor, "_process_create_time", lambda pid: 1000.0)
- _write_booting_pidfile(tmp_path, spawned_ago_s=20.0)
+ _write_booting_pidfile(tmp_path, spawned_ago_s=spawned_ago_s)
stamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
(tmp_path / "local_realtime_server.log").write_text(
f"{stamp},100 - speech_to_speech.TTS.qwen3_tts_handler - INFO - "
@@ -2131,7 +2122,10 @@ def test_status_reports_stage_and_eta_while_an_owned_child_boots(monkeypatch, tm
assert boot["stage"] == "voice-model"
assert boot["stage_label"] == "loading the speaking voice"
assert boot["expected_total_s"] == 80.0
- assert 50.0 <= boot["remaining_s"] <= 65.0
+ if spawned_ago_s < 80:
+ assert 50.0 <= boot["remaining_s"] <= 65.0
+ else:
+ assert boot["remaining_s"] is None
assert boot["failed_streak"] == 0
diff --git a/tests/unit/realtime/test_factory.py b/tests/unit/realtime/test_factory.py
index 4c5bfce21e..87ceaecdac 100644
--- a/tests/unit/realtime/test_factory.py
+++ b/tests/unit/realtime/test_factory.py
@@ -389,13 +389,14 @@ class _PrespawnProbe:
@pytest.mark.asyncio
-async def test_prespawn_reaches_every_explicit_slot(monkeypatch) -> None:
- """Unlike eager warming, the prestart is position-blind: a stone-cold
- explicitly configured FALLBACK is what stranded the 2026-08-10 first call
- when the primary was down. Providers without the capability are skipped
- (AP-21), and one broken plugin never stops the others."""
[email protected]("eager_fallback", [False, True])
+async def test_prespawn_only_starts_primary_and_opted_in_fallback(
+ monkeypatch, eager_fallback
+) -> None:
+ """A process spawn can load a whole GPU stack even without awaiting readiness."""
primary = _PrespawnProbe()
fallback = _PrespawnProbe()
+ fallback.eager_warm_as_fallback = eager_fallback
loaded = {"primary": primary, "plain": _NoWarmProbe(), "fallback": fallback}
def _load(_group, pid, protocol=None): # noqa: ANN001 - probe shape
@@ -413,7 +414,7 @@ async def test_prespawn_reaches_every_explicit_slot(monkeypatch) -> None:
await factory.realtime_prespawn_transports(_cfg())
assert primary.calls == 1
- assert fallback.calls == 1
+ assert fallback.calls == int(eager_fallback)
@pytest.mark.asyncio
diff --git a/tests/unit/realtime/test_local_realtime.py b/tests/unit/realtime/test_local_realtime.py
index e673c39aa9..e8485546b0 100644
--- a/tests/unit/realtime/test_local_realtime.py
+++ b/tests/unit/realtime/test_local_realtime.py
@@ -1097,12 +1097,9 @@ async def test_warm_transport_never_raises(monkeypatch) -> None:
# ── Boot-time prespawn (prespawn_transport capability) ───────────────────
-def test_local_realtime_is_eagerly_warmed_as_a_fallback() -> None:
- """Live 2026-08-10: with an expired subscription primary, the un-warmed
- local FALLBACK was still stone cold when the first call arrived — the
- call died on a machine that could have answered it. A local stack costs
- no account round-trip to warm, so it must not sit out fallback warming."""
- assert LocalRealtimeProvider.eager_warm_as_fallback is True
+def test_local_realtime_does_not_load_models_for_an_unselected_fallback() -> None:
+ """Local fallback configuration alone must not reserve the user's GPU/RAM."""
+ assert LocalRealtimeProvider.eager_warm_as_fallback is False
async def test_prespawn_spawns_and_arms_the_monitor_without_waiting(
diff --git a/tests/unit/realtime/test_openai_realtime.py b/tests/unit/realtime/test_openai_realtime.py
index c831e23af4..825ec248a7 100644
--- a/tests/unit/realtime/test_openai_realtime.py
+++ b/tests/unit/realtime/test_openai_realtime.py
@@ -1574,6 +1574,47 @@ async def test_slow_first_output_uses_the_declared_response_start_budget(
await session.close()
+async def test_local_text_does_not_expire_the_first_audio_budget(monkeypatch) -> None:
+ """A transcript may precede local TTS audio by more than eight seconds."""
+ client = _FakeAsyncOpenAI(api_key="local")
+ session = await openai_realtime._open_realtime_session(
+ client, RealtimeSessionConfig(model="local"), model="local",
+ response_start_timeout_s=90.0,
+ )
+ try:
+ await session.request_response()
+ marker = session._conn.response_create_payloads[0]["response"]["metadata"][
+ "jarvis_request_id"
+ ]
+ created = SimpleNamespace(
+ type="response.created",
+ response=SimpleNamespace(id="local-answer", metadata={"jarvis_request_id": marker}),
+ )
+ _ = [event async for event in session._dispatch_event(created)]
+ transcript = SimpleNamespace(
+ type="response.output_audio_transcript.delta", response_id="local-answer", delta="Five."
+ )
+ _ = [event async for event in session._dispatch_event(transcript)]
+ text_at = session._last_response_activity
+ monkeypatch.setattr(openai_realtime.time, "monotonic", lambda: text_at + 20)
+ assert not session._response_lifecycle_stalled()
+ monkeypatch.setattr(openai_realtime.time, "monotonic", lambda: text_at + 91)
+ assert session._response_lifecycle_stalled(), "Missing audio still has a finite deadline"
+ audio = SimpleNamespace(
+ type="response.output_audio.delta", response_id="local-answer", delta="AAA="
+ )
+ _ = [event async for event in session._dispatch_event(audio)]
+ audio_at = session._last_response_activity
+ monkeypatch.setattr(openai_realtime.time, "monotonic", lambda: audio_at + 9)
+ assert session._response_lifecycle_stalled(), "Started audio retains the strict guard"
+ session._response_idle.set()
+ await session.request_response()
+ assert not session._response_audio_started, "Every response gets a fresh audio clock"
+ finally:
+ await session.close()
+
+
@pytest.mark.asyncio
async def test_serial_rebuild_releases_single_slot_before_retrying() -> None:
"""The managed server owns one pipeline slot. A rebuild must disconnect