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.

fix(local-models): a picker lists what can do the job, and says which is fast enough

rubenluetke10-beep9995f9cc31d3
diff --git a/jarvis/brain/ollama_overview.py b/jarvis/brain/ollama_overview.py
index 260d4a2c84..ba9a5f66a4 100644
--- a/jarvis/brain/ollama_overview.py
+++ b/jarvis/brain/ollama_overview.py
@@ -124,6 +124,9 @@ def role_row(state: ollama_roles.RoleState) -> dict[str, Any]:
"note": state.note,
"context_tokens": state.context_tokens,
"context_source": state.context_source,
+ # The size class the job prefers (the voice brain answers within a
+ # breath, so it stays under 6 GB); ``None`` when the job has none.
+ "max_size_gb": spec.max_size_gb,
}
diff --git a/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts b/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts
index 9785a6fced..d179db1cd2 100644
--- a/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts
@@ -144,6 +144,11 @@ export interface RoleRow {
context_tokens?: number | null;
/** "automatic" (sized from memory) | "manual" (set in Tune) | "". */
context_source?: "" | "automatic" | "manual";
+ /**
+ * The size class this job prefers, in GB (the voice brain stays under 6 so
+ * a call answers within a breath); null/absent when the job has none.
+ */
+ max_size_gb?: number | null;
}
export interface IdleReleaseResponse {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json
index 1f87fb9f65..54f5b924b1 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json
@@ -300,6 +300,7 @@
"pick_missing_suffix": "(nicht installiert)",
"pick_group_fits": "Passt zu diesem Job",
"pick_group_others": "Weitere installierte Modelle",
+ "pick_group_over_size": "Kann den Job, ist aber über {gb} GB — antwortet langsamer",
"server_silent": "Der Server hat nicht geantwortet, daher kann diese Liste unvollständig sein. Aktualisiere, sobald er läuft.",
"use_recommended": "Empfehlung nutzen",
"download_recommended": "{model} herunterladen",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json
index 714c9a5ac8..66bed5943d 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json
@@ -300,6 +300,7 @@
"pick_missing_suffix": "(not installed)",
"pick_group_fits": "Fits this job",
"pick_group_others": "Other installed models",
+ "pick_group_over_size": "Has the skills, but over {gb} GB — slower to answer",
"server_silent": "The server did not answer, so this list may be incomplete. Refresh once it is running.",
"use_recommended": "Use recommended",
"download_recommended": "Download {model}",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json
index 4098550ced..f54ea48fb2 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json
@@ -300,6 +300,7 @@
"pick_missing_suffix": "(no instalado)",
"pick_group_fits": "Encaja con esta tarea",
"pick_group_others": "Otros modelos instalados",
+ "pick_group_over_size": "Tiene la capacidad, pero supera {gb} GB: responde más despacio",
"server_silent": "El servidor no respondió, así que esta lista puede estar incompleta. Actualiza cuando esté en marcha.",
"use_recommended": "Usar el recomendado",
"download_recommended": "Descargar {model}",
diff --git a/jarvis/ui/web/frontend/src/views/local-models/RolePicker.test.tsx b/jarvis/ui/web/frontend/src/views/local-models/RolePicker.test.tsx
index 4d90d65d95..1f9666eb7b 100644
--- a/jarvis/ui/web/frontend/src/views/local-models/RolePicker.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/local-models/RolePicker.test.tsx
@@ -1,10 +1,12 @@
/**
- * The role picker's job is to always have something to pick.
+ * The role picker's job is to offer every REAL choice and no fake one.
*
- * `qualifying` alone leaves a user stranded twice over — an unreachable
- * server empties it, and an unprobed download reports no capabilities — and
- * both read as "my pick jumped back" (BUG-188). These tests pin the two
- * groups and the fact that neither list can swallow an installed model.
+ * Two ways it went wrong: `qualifying` alone left one option after an
+ * offline sweep (BUG-188), and offering every installed download then put
+ * an embedding-only model in the speech list. These tests pin the rule that
+ * replaced both — a download is listed when it has the job's capabilities,
+ * called a fit when it also sits inside the job's size class, and never
+ * listed when it lacks a capability.
*/
import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
@@ -19,6 +21,8 @@ vi.mock("@/i18n", () => ({
`${template}${Object.values(values).join("|")}`,
}));
+const GIB = 1024 ** 3;
+
function role(extra: Partial<RoleRow> = {}): RoleRow {
return {
id: "chat",
@@ -26,7 +30,7 @@ function role(extra: Partial<RoleRow> = {}): RoleRow {
config_key: "brain.providers.ollama.model",
current: "",
installed: false,
- required: [],
+ required: ["completion"],
recommended_capabilities: [],
qualifying: [],
recommended: "",
@@ -37,28 +41,66 @@ function role(extra: Partial<RoleRow> = {}): RoleRow {
} as RoleRow;
}
-const model = (name: string): LocalModelRow =>
- ({ name, capabilities: [], probed: true, used_by: [] }) as unknown as LocalModelRow;
+function model(
+ name: string,
+ caps: string[] = ["completion", "tools"],
+ sizeGb = 4,
+ probed = true,
+): LocalModelRow {
+ return {
+ name,
+ capabilities: caps,
+ probed,
+ size_bytes: sizeGb * GIB,
+ used_by: [],
+ } as unknown as LocalModelRow;
+}
describe("splitChoices", () => {
- it("puts the qualifying models first and every other download after them", () => {
- const { fits, others } = splitChoices(
- role({ qualifying: ["gemma4:12b", "qwen3.5:4b"] }),
- [model("gemma4:12b"), model("qwen3.5:4b"), model("deepseek-r1:14b")],
- );
- expect(fits).toEqual(["gemma4:12b", "qwen3.5:4b"]);
- expect(others).toEqual(["deepseek-r1:14b"]);
+ it("lists only downloads that have the job's capabilities", () => {
+ const { fits, others } = splitChoices(role({ required: ["completion"] }), [
+ model("ornith:9b"),
+ model("bge-m3:latest", ["embedding"], 1),
+ model("deepseek-llm:latest", ["completion"]),
+ ]);
+ // An embedding-only model cannot answer; it is not a choice at all.
+ expect(fits).toEqual(["ornith:9b", "deepseek-llm:latest"]);
+ expect(others).toEqual([]);
});
- it("still offers the installed models when nothing qualifies", () => {
- // The state the section used to get stuck in: no shortlist, so the only
- // option was the tag already configured.
- const { fits, others } = splitChoices(
- role({ current: "ornith:9b", qualifying: [] }),
- [model("gemma4:12b"), model("qwen3.5:4b"), model("ornith:9b")],
- );
- expect(fits).toEqual([]);
- expect(others).toEqual(["gemma4:12b", "qwen3.5:4b", "ornith:9b"]);
+ it("calls a download a fit only inside the job's size class", () => {
+ // The voice brain must answer within a breath: under 6 GB.
+ const voice = role({ id: "voice", required: ["completion"], max_size_gb: 6 });
+ const { fits, others } = splitChoices(voice, [
+ model("ornith:9b", ["completion", "tools"], 5.2),
+ model("qwen3.5:4b", ["completion", "tools"], 3.2),
+ model("nemotron-cascade-2:latest", ["completion", "tools"], 22.6),
+ model("deepseek-r1:14b", ["completion", "tools"], 8.4),
+ model("bge-m3:latest", ["embedding"], 1.1),
+ ]);
+ expect(fits).toEqual(["ornith:9b", "qwen3.5:4b"]);
+ // Still able, still offered — under a heading that says what it costs.
+ expect(others).toEqual(["nemotron-cascade-2:latest", "deepseek-r1:14b"]);
+ });
+
+ it("requires every capability, not any", () => {
+ const tools = role({ id: "tools_screen", required: ["tools", "vision"] });
+ const { fits, others } = splitChoices(tools, [
+ model("gemma4:12b-it-qat", ["completion", "vision", "tools"]),
+ model("ornith:9b", ["completion", "tools"]),
+ model("qwen3-vl:2b", ["completion", "vision"]),
+ ]);
+ expect(fits).toEqual(["gemma4:12b-it-qat"]);
+ expect(others).toEqual([]);
+ });
+
+ it("offers an unprobed download without calling it a fit", () => {
+ const { fits, others } = splitChoices(role(), [
+ model("known:7b"),
+ model("mystery:7b", [], 4, false),
+ ]);
+ expect(fits).toEqual(["known:7b"]);
+ expect(others).toEqual(["mystery:7b"]);
});
it("keeps a configured tag that is gone from disk, exactly once", () => {
@@ -72,12 +114,17 @@ describe("splitChoices", () => {
it("treats a bare tag and its :latest as one download", () => {
const { fits, others } = splitChoices(
- role({ current: "bge-m3", qualifying: ["bge-m3:latest"] }),
- [model("bge-m3:latest")],
+ role({ current: "bge-m3", required: ["embedding"], qualifying: ["bge-m3:latest"] }),
+ [model("bge-m3:latest", ["embedding"], 1)],
);
expect(fits).toEqual(["bge-m3:latest"]);
expect(others).toEqual([]);
});
+
+ it("trusts the backend's qualifying list for a row the inventory has not caught up with", () => {
+ const { fits } = splitChoices(role({ qualifying: ["fresh:1b"] }), []);
+ expect(fits).toEqual(["fresh:1b"]);
+ });
});
describe("RolePicker", () => {
@@ -86,7 +133,7 @@ describe("RolePicker", () => {
render(
<RolePicker
row={role({ current: "gemma4:12b", qualifying: ["gemma4:12b"] })}
- models={[model("gemma4:12b"), model("deepseek-r1:14b")]}
+ models={[model("gemma4:12b"), model("mystery:7b", [], 4, false)]}
onPick={onPick}
/>,
);
@@ -94,7 +141,7 @@ describe("RolePicker", () => {
expect([...select.options].map((o) => o.value)).toEqual([
"",
"gemma4:12b",
- "deepseek-r1:14b",
+ "mystery:7b",
]);
expect(
[...select.querySelectorAll("optgroup")].map((g) => g.label),
@@ -103,8 +150,30 @@ describe("RolePicker", () => {
"local_models.roles.pick_group_others",
]);
- fireEvent.change(select, { target: { value: "deepseek-r1:14b" } });
- expect(onPick).toHaveBeenCalledWith("deepseek-r1:14b");
+ fireEvent.change(select, { target: { value: "mystery:7b" } });
+ expect(onPick).toHaveBeenCalledWith("mystery:7b");
+ });
+
+ it("names the size class on the second heading when the job has one", () => {
+ render(
+ <RolePicker
+ row={role({ id: "voice", current: "ornith:9b", max_size_gb: 6 })}
+ models={[
+ model("ornith:9b", ["completion"], 5.2),
+ model("deepseek-r1:14b", ["completion"], 8.4),
+ ]}
+ onPick={vi.fn()}
+ />,
+ );
+ const select = screen.getByTestId("role-picker-voice") as HTMLSelectElement;
+ expect(
+ [...select.querySelectorAll("optgroup")].map((g) => g.label),
+ ).toEqual([
+ "local_models.roles.pick_group_fits",
+ "local_models.roles.pick_group_over_size6",
+ ]);
+ // The voice server cannot discover a model: no "Let Jarvis pick".
+ expect([...select.options].map((o) => o.value)).not.toContain("");
});
it("marks a configured model that is no longer on the server", () => {
@@ -125,8 +194,8 @@ describe("RolePicker", () => {
it("offers no discovery option for the embedding role once one is set", () => {
render(
<RolePicker
- row={role({ id: "embedding", current: "bge-m3:latest" })}
- models={[model("bge-m3:latest")]}
+ row={role({ id: "embedding", required: ["embedding"], current: "bge-m3:latest" })}
+ models={[model("bge-m3:latest", ["embedding"], 1)]}
onPick={vi.fn()}
/>,
);
diff --git a/jarvis/ui/web/frontend/src/views/local-models/RolePicker.tsx b/jarvis/ui/web/frontend/src/views/local-models/RolePicker.tsx
index 761b3e0d1b..17ed9f99c9 100644
--- a/jarvis/ui/web/frontend/src/views/local-models/RolePicker.tsx
+++ b/jarvis/ui/web/frontend/src/views/local-models/RolePicker.tsx
@@ -1,26 +1,35 @@
/**
- * The model picker of one role row.
+ * The model picker of one job.
*
- * It used to list `row.qualifying` only — the installed downloads that
- * declare every capability the job requires — plus the configured tag when
- * that had gone missing. Two ways that leaves a user stuck with a value they
- * did not choose (BUG-188):
+ * Two failures shaped it. The first (BUG-188): the list was `row.qualifying`
+ * alone, so an offline sweep left one option and a pick "jumped back". The
+ * over-correction then offered EVERY installed download, which put an
+ * embedding-only model in the speech list — a model that cannot answer a
+ * call is not a choice, it is a trap that looks like one.
*
- * * the sweep behind the payload found no server, so `qualifying` is empty
- * and the list holds exactly one entry: the tag already configured;
- * * a download Jarvis could not probe (`probed: false`) reports no
- * capabilities, so it silently never appears — even though it runs.
+ * The list is therefore built from the job's own requirements, on the
+ * client, from the inventory it can see:
*
- * Both read as "I picked something else and it jumped back". The picker
- * therefore offers EVERY installed download, in two groups: the ones that
- * fit the job first, the rest under "Other installed models" with the
- * consequence spelled out rather than hidden. Choosing one is a real choice
- * a user is allowed to make; the section says what it costs, it does not
- * decide for them.
+ * * `fits` — every installed download that declares each capability the
+ * job requires AND sits inside the job's size class when it
+ * has one (the voice brain answers within a breath, so it
+ * stays under 6 GB);
+ * * `others` — downloads that have the capabilities but fall outside the
+ * size class, or that Jarvis could not probe (`probed: false`
+ * means "unknown", never "unable"). A real choice with a
+ * stated cost, so it is offered under its own heading.
+ *
+ * A download that lacks a required capability is not listed at all. The
+ * configured tag stays listed even when it is gone from disk, or the row
+ * would show a value the picker cannot express.
*/
import { useMemo } from "react";
-import { canonicalModelName, type LocalModelRow, type RoleRow } from "@/hooks/useLocalModels";
+import {
+ canonicalModelName,
+ type LocalModelRow,
+ type RoleRow,
+} from "@/hooks/useLocalModels";
import { fill, useT } from "@/i18n";
import { cn } from "@/lib/utils";
@@ -34,7 +43,24 @@ export interface RolePickerProps {
className?: string;
}
-/** `qualifying`, then every other installed tag, each list de-duplicated. */
+const GIB = 1024 ** 3;
+
+/** Whether `model` declares every capability `row` requires. */
+export function hasRequired(row: RoleRow, model: LocalModelRow): boolean {
+ return row.required.every((cap) => model.capabilities.includes(cap));
+}
+
+/** Whether `model` sits inside the job's size class (no class = always). */
+export function inSizeClass(row: RoleRow, model: LocalModelRow): boolean {
+ const cap = row.max_size_gb;
+ if (cap == null || cap <= 0) return true;
+ return model.size_bytes / GIB <= cap;
+}
+
+/**
+ * `fits` first, then `others`, both in inventory order, de-duplicated
+ * across `:latest`. Nothing that lacks a required capability appears.
+ */
export function splitChoices(
row: RoleRow,
models: LocalModelRow[],
@@ -48,10 +74,18 @@ export function splitChoices(
seen.add(key);
into.push(name);
};
+ for (const m of models) {
+ if (m.probed) {
+ if (!hasRequired(row, m)) continue;
+ take(m.name, inSizeClass(row, m) ? fits : others);
+ } else {
+ // Unknown capabilities: offered, not hidden, and not called a fit.
+ take(m.name, others);
+ }
+ }
+ // The backend's own verdict wins for anything it named that the client
+ // could not see (a row the inventory has not caught up with yet).
for (const name of row.qualifying) take(name, fits);
- for (const m of models) take(m.name, others);
- // A configured tag that is gone from disk still belongs in the list, or
- // the row would silently show a value the picker cannot express.
if (row.current) take(row.current, others);
return { fits, others };
}
@@ -76,6 +110,14 @@ export function RolePicker({
? name
: `${name} ${t("local_models.roles.pick_missing_suffix")}`;
+ // The second heading says what "other" costs for THIS job.
+ const othersLabel =
+ row.max_size_gb != null && row.max_size_gb > 0
+ ? fill(t("local_models.roles.pick_group_over_size"), {
+ gb: String(row.max_size_gb),
+ })
+ : t("local_models.roles.pick_group_others");
+
return (
<select
aria-label={fill(t("local_models.roles.pick_label"), {
@@ -92,10 +134,10 @@ export function RolePicker({
className,
)}
>
- {row.id !== "embedding" && (
+ {row.id !== "embedding" && row.id !== "voice" && (
<option value="">{t("local_models.roles.pick_discovery")}</option>
)}
- {row.id === "embedding" && !row.current && (
+ {(row.id === "embedding" || row.id === "voice") && !row.current && (
<option value="">{t("local_models.roles.pick_none")}</option>
)}
{fits.length > 0 && (
@@ -108,7 +150,7 @@ export function RolePicker({
</optgroup>
)}
{others.length > 0 && (
- <optgroup label={t("local_models.roles.pick_group_others")}>
+ <optgroup label={othersLabel}>
{others.map((name) => (
<option key={name} value={name}>
{label(name)}
diff --git a/jarvis/ui/web/local_models_routes.py b/jarvis/ui/web/local_models_routes.py
index 196e12e36b..a2fe38a5e4 100644
--- a/jarvis/ui/web/local_models_routes.py
+++ b/jarvis/ui/web/local_models_routes.py
@@ -357,6 +357,9 @@ class RoleRow(BaseModel):
context_tokens: int | None = None
#: "automatic" | "manual" | "".
context_source: str = ""
+ #: The size class the job prefers, in GB (the voice brain stays under 6
+ #: so a call answers within a breath); ``None`` when the job has none.
+ max_size_gb: float | None = None
class RolesResponse(BaseModel):
diff --git a/tests/unit/ui/web/test_local_models_routes.py b/tests/unit/ui/web/test_local_models_routes.py
index fa687d0c97..e3cf51cb04 100644
--- a/tests/unit/ui/web/test_local_models_routes.py
+++ b/tests/unit/ui/web/test_local_models_routes.py
@@ -324,13 +324,15 @@ def test_put_role_drops_the_memoised_overview(server, fake, writes, monkeypatch)
first = client.get(f"{BASE}/overview").json()
assert first["source"] == "live"
assert client.put(f"{BASE}/roles/deep", json={"model": "qwen3.5:4b"}).status_code == 200
- # The memo is gone: a plain read is no longer a stale "live" answer,
- # and a fresh read carries the new pick.
+ # The memo and the disk snapshot are both known stale now: even a
+ # plain read builds live and carries the new pick — every client
+ # sees the write, not only one that asks for ``fresh``.
after = client.get(f"{BASE}/overview").json()
- assert after["source"] == "cache"
- fresh = client.get(f"{BASE}/overview", params={"fresh": 1}).json()
- deep = next(r for r in fresh["roles"]["roles"] if r["id"] == "deep")
+ assert after["source"] == "live"
+ deep = next(r for r in after["roles"]["roles"] if r["id"] == "deep")
assert deep["current"] == "qwen3.5:4b"
+ # And the next plain read is the memo again, not another build.
+ assert client.get(f"{BASE}/overview").json()["source"] == "live"
ollama_overview._reset_for_tests()
@@ -707,6 +709,10 @@ def test_roles_carry_the_voice_brains_context(server: WebServer, fake, monkeypat
assert rows["voice"]["context_source"] == "automatic"
assert rows["chat"]["context_tokens"] is None
assert rows["chat"]["context_source"] == ""
+ # The size class reaches the picker, so it can say which downloads are
+ # "fast enough for a call" rather than listing every chat model as a fit.
+ assert rows["voice"]["max_size_gb"] == 6.0
+ assert rows["chat"]["max_size_gb"] is None
# ═════════════════════════════════════════════════════════════════════════