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(brain): offer Grok 4.7 in the Grok Build picker

rubenluetke10-beep5748ee632f0d
diff --git a/jarvis/agent_chat/catalog.py b/jarvis/agent_chat/catalog.py
index 7f281a350d..2ad41283bd 100644
--- a/jarvis/agent_chat/catalog.py
+++ b/jarvis/agent_chat/catalog.py
@@ -58,7 +58,7 @@ from dataclasses import dataclass, field
from typing import Any, Final, Literal
from jarvis.agent_chat.effort import default_effort, effort_levels
-from jarvis.brain.model_catalog import CURATED_MODELS
+from jarvis.brain.model_catalog import CURATED_MODELS, GROK_BUILD_MODELS
Runner = Literal[
"api",
@@ -271,8 +271,8 @@ PROVIDER_ROWS: Final[tuple[ProviderRow, ...]] = (
family="xai",
runner="grok-cli",
models_source="curated",
- curated_models=_curated("grok"),
- default_model="",
+ curated_models=tuple(CuratedModel(mid, label) for mid, label in GROK_BUILD_MODELS),
+ default_model=GROK_BUILD_MODELS[0][0],
agent="grok-build",
),
ProviderRow(
diff --git a/jarvis/agent_chat/effort.py b/jarvis/agent_chat/effort.py
index e2873f7c7e..5d616ce91e 100644
--- a/jarvis/agent_chat/effort.py
+++ b/jarvis/agent_chat/effort.py
@@ -60,10 +60,11 @@ _LADDERS: Final[dict[str, tuple[tuple[str, ...], str]]] = {
"antigravity": (("low", "medium", "high"), "medium"),
# OpenRouter forwards reasoning.effort to whatever sits behind the slug.
"openrouter": (("", "none", "low", "medium", "high", "xhigh"), ""),
- # xAI reasoning_effort: grok-4.6 low..xhigh, grok-4.5 low..high; "" leaves
- # a model that reasons on its own alone.
+ # xAI reasoning_effort: grok-4.7 and grok-4.6 take low..xhigh (their own
+ # default is high). grok-4.5 stops at high and treats xhigh as high.
+ # "" leaves the model's own default alone.
"grok": (("", "low", "medium", "high", "xhigh"), ""),
- "grok-build": (("", "low", "medium", "high"), ""),
+ "grok-build": (("", "low", "medium", "high", "xhigh"), ""),
# No knob to offer: OpenCode's ``--variant`` names are the model's own
# and differ per provider, Kimi sets effort in its config, GLM's endpoint
# takes no effort flag and the DeepSeek harness has none — so the pick
diff --git a/jarvis/agent_chat/runner_cli.py b/jarvis/agent_chat/runner_cli.py
index cc3c8cec0b..dda4178187 100644
--- a/jarvis/agent_chat/runner_cli.py
+++ b/jarvis/agent_chat/runner_cli.py
@@ -70,7 +70,7 @@ from typing import Any, Final
from jarvis.agent_chat import jarvis_harness
from jarvis.agent_chat.approval_bridge import approval_ref
-from jarvis.agent_chat.effort import normalize_effort, snap_to_ladder
+from jarvis.agent_chat.effort import ORDER, normalize_effort, snap_to_ladder
from jarvis.agent_chat.events import make_event
from jarvis.agent_chat.permissions import normalize_permission
from jarvis.agent_chat.runner_api import TurnHandle
@@ -754,6 +754,66 @@ def read_codex_models() -> list[dict[str, Any]] | None:
return [r[1] for r in rows] or None
+def read_grok_models() -> list[dict[str, Any]] | None:
+ """Grok Build's account catalog from ``$GROK_HOME/models_cache.json``.
+
+ The CLI refreshes that file itself. It is the same list the Grok Build
+ picker shows for this login (verified against grok 1.0.40: a dict of
+ model id to ``{info: {id, name, hidden, reasoning_efforts}}``). ``None``
+ when the file is missing or unreadable — the caller keeps
+ ``GROK_BUILD_MODELS``.
+ """
+ env = _account_env("grok-build")
+ home = Path(env.get("GROK_HOME") or Path.home() / ".grok")
+ path = home / "models_cache.json"
+ try:
+ data = json.loads(path.read_text(encoding="utf-8"))
+ except (OSError, ValueError) as exc:
+ log.debug("agent chat: grok models cache unreadable at %s: %s", path, exc)
+ return None
+ models = data.get("models") if isinstance(data, dict) else None
+ if isinstance(models, dict):
+ entries = list(models.values())
+ elif isinstance(models, list):
+ entries = models
+ else:
+ return None
+ rows: list[dict[str, Any]] = []
+ for entry in entries:
+ info = entry.get("info") if isinstance(entry, dict) else None
+ if not isinstance(info, dict):
+ info = entry if isinstance(entry, dict) else None
+ if not isinstance(info, dict) or info.get("hidden") is True:
+ continue
+ slug = str(info.get("id") or info.get("model") or "").strip()
+ if not slug:
+ continue
+ seen: list[str] = []
+ for level in info.get("reasoning_efforts") or []:
+ if isinstance(level, dict):
+ value = str(level.get("value") or level.get("id") or "")
+ else:
+ value = str(level)
+ value = value.strip().lower()
+ if value and value not in seen:
+ seen.append(value)
+ ordered = [level for level in ORDER if level in seen]
+ ordered += [level for level in seen if level not in ordered]
+ # "" stays the "leave the CLI's own effort alone" choice. The levels
+ # after it are the ones this model actually accepts.
+ efforts = [""] + ordered if ordered else []
+ row: dict[str, Any] = {
+ "id": slug,
+ "label": str(info.get("name") or slug),
+ "efforts": efforts,
+ }
+ note = str(info.get("description") or "").strip()
+ if note:
+ row["note"] = note
+ rows.append(row)
+ return rows or None
+
+
_AGY_CATALOG: dict[str, Any] = {"at": 0.0, "rows": None}
_AGY_CATALOG_TTL_S: Final[float] = 600.0
diff --git a/jarvis/brain/cost.py b/jarvis/brain/cost.py
index b2708c6706..e751e93409 100644
--- a/jarvis/brain/cost.py
+++ b/jarvis/brain/cost.py
@@ -139,6 +139,14 @@ PRICING_USD_PER_MTOK: dict[str, tuple[float, float]] = {
# (2026-08-25): $2 uncached in / $0.50 cached / $6 out.
"grok-4.6": (2.0, 6.0),
"grok-4.6-build": (2.0, 6.0),
+ # Grok 4.7, released 2026-09-21. Same list price as 4.6 below 200k
+ # prompt tokens ($2 in / $0.50 cached / $6 out). The long-context band
+ # is double; this row is the short-context rate, matching 4.6 above.
+ # ``-build`` is the suffix Grok Build transcripts used for 4.6.
+ "grok-4.7": (2.0, 6.0),
+ "grok-4.7-build": (2.0, 6.0),
+ # Grok Build only. Same model, twice the token rate (xAI, 2026-09-21).
+ "grok-4.7-build-fast": (4.0, 12.0),
"grok-4.20": (2.0, 6.0),
"grok-4-0709": (5.0, 15.0),
"grok-4": (5.0, 15.0),
diff --git a/jarvis/brain/model_catalog.py b/jarvis/brain/model_catalog.py
index 8586d2f3c7..e7d3e53862 100644
--- a/jarvis/brain/model_catalog.py
+++ b/jarvis/brain/model_catalog.py
@@ -245,6 +245,7 @@ CURATED_MODELS: dict[str, list[ModelInfo]] = {
("openai/gpt-5.6-luna", "GPT-5.6 Luna"),
("google/gemini-3.5-flash", "Gemini 3.5 Flash"),
("google/gemini-3.1-pro-preview", "Gemini 3.1 Pro"),
+ ("x-ai/grok-4.7", "Grok 4.7"),
("x-ai/grok-4.20", "Grok 4.20"),
("deepseek/deepseek-v4-pro", "DeepSeek V4 Pro"),
]
@@ -256,10 +257,13 @@ CURATED_MODELS: dict[str, list[ModelInfo]] = {
# (pinned by test_grok_has_authenticated_live_model_catalog): 4.6 was
# inserted at the head without moving the default, which offered a model
# as the pre-selected one that the client would not actually have used.
+ # Grok 4.7 (2026-09-21) is in the list, not at its head, for that reason.
# The authenticated live catalog replaces this fallback entirely.
+ # Grok Build does not use this order: ``GROK_BUILD_MODELS`` leads with 4.7.
"grok": _curated(
[
("grok-4.3", "Grok 4.3"),
+ ("grok-4.7", "Grok 4.7"),
("grok-4.6", "Grok 4.6"),
("grok-4.5", "Grok 4.5"),
]
@@ -284,6 +288,20 @@ CURATED_MODELS: dict[str, list[ModelInfo]] = {
}
+#: Grok Build's picker. The subscription login has no /v1/models, so this
+#: list is what the create-agent dialog and the IDE pane offer. grok-4.7
+#: leads: it is the current default of the Grok Build CLI (xAI, 2026-09-21).
+#: The API fallback in ``CURATED_MODELS["grok"]`` must not copy this order —
+#: its head is the client default, ``grok-4.3``.
+GROK_BUILD_MODELS: tuple[tuple[str, str], ...] = (
+ ("grok-4.7", "Grok 4.7"),
+ ("grok-4.7-build-fast", "Grok 4.7 Fast"),
+ ("grok-4.6", "Grok 4.6"),
+ ("grok-4.5", "Grok 4.5"),
+ ("grok-4.3", "Grok 4.3"),
+)
+
+
@dataclass(frozen=True, slots=True)
class CatalogResult:
"""The model list for one provider, with an honest provenance flag."""
@@ -766,20 +784,12 @@ def _build_provider_catalog() -> dict[str, CatalogSpec]:
live=False,
)
# Grok Build — SuperGrok / X Premium+ CLI worker. No public /v1/models over
- # the subscription login, so curated only. Grok 4.6 is the current Grok
- # Build default (official docs, 2026-08).
+ # the subscription login, so curated only. grok-4.7 leads: it is the
+ # current Grok Build default (xAI, 2026-09-21).
cat["grok-build"] = CatalogSpec(
"brain",
"model",
- tuple(
- _curated(
- [
- ("grok-4.6", "Grok 4.6"),
- ("grok-4.3", "Grok 4.3"),
- ("grok-4.5", "Grok 4.5"),
- ]
- )
- ),
+ tuple(_curated(list(GROK_BUILD_MODELS))),
live=False,
)
# Claude CLI — the Anthropic-subscription writer (``claude -p``); no
diff --git a/jarvis/missions/workers/grok_build_direct_worker.py b/jarvis/missions/workers/grok_build_direct_worker.py
index 3bc113ab39..bf6c344019 100644
--- a/jarvis/missions/workers/grok_build_direct_worker.py
+++ b/jarvis/missions/workers/grok_build_direct_worker.py
@@ -30,6 +30,7 @@ from contextlib import suppress
from pathlib import Path
from typing import Any, ClassVar, Literal
+from jarvis.brain.model_catalog import GROK_BUILD_MODELS
from jarvis.grok_build_auth import grok_home, prepare_worker_home
from .capabilities import WorkerCapabilityInventory
@@ -42,7 +43,7 @@ _DEFAULT_TIMEOUT_S: float = 1200.0
_DEFAULT_FIRST_OUTPUT_TIMEOUT_S: float = 120.0
_STREAM_READLINE_LIMIT: int = 8 * 1024 * 1024
_HARDCAP_GRACE_S: float = 30.0
-_DEFAULT_GROK_BUILD_MODEL: str = "grok-4.6"
+_DEFAULT_GROK_BUILD_MODEL: str = GROK_BUILD_MODELS[0][0]
_DROP_ENV: tuple[str, ...] = ("XAI_API_KEY", "GROK_API_KEY")
diff --git a/jarvis/workspace/launch_picks.py b/jarvis/workspace/launch_picks.py
index 500eff19d5..789670f2b6 100644
--- a/jarvis/workspace/launch_picks.py
+++ b/jarvis/workspace/launch_picks.py
@@ -227,9 +227,9 @@ async def live_models() -> dict[str, list[dict[str, Any]]]:
"""The model lists the installed CLIs publish, keyed by runner.
``agy`` answers ``agy models`` and OpenCode ``opencode models`` (each a
- ~2 s subprocess, cached ten minutes in the runner module); Codex keeps
- ``models_cache.json`` in its home. All are read off the event loop, and a
- failure simply leaves the curated fallback standing.
+ ~2 s subprocess, cached ten minutes in the runner module); Codex and
+ Grok Build keep ``models_cache.json`` in their home. All are read off
+ the event loop, and a failure simply leaves the curated fallback standing.
One reader for both surfaces on purpose: the chat composer and a workspace
pane offer the same CLI, so a list either of them read alone would be a
@@ -241,6 +241,7 @@ async def live_models() -> dict[str, list[dict[str, Any]]]:
from jarvis.agent_chat.runner_cli import (
read_agy_models,
read_codex_models,
+ read_grok_models,
read_opencode_models,
)
@@ -258,6 +259,14 @@ async def live_models() -> dict[str, list[dict[str, Any]]]:
rows = None
if rows:
out["codex-cli"] = rows
+ if _installed("grok-cli"):
+ try:
+ rows = await asyncio.to_thread(read_grok_models)
+ except Exception as exc: # noqa: BLE001 — the fallback list stands in
+ _log.debug("launch picks: grok model list unavailable: %s", exc)
+ rows = None
+ if rows:
+ out["grok-cli"] = rows
if _installed("opencode-cli"):
# ``opencode models`` — the providers this install configured.
try:
@@ -387,9 +396,17 @@ def offered(agent: str, live: Mapping[str, list[dict[str, Any]]] | None = None)
handing it rows it already knows how to draw is what keeps the two
surfaces from growing two different model pickers.
"""
+ picks = picks_for(agent)
+ default_model = ""
+ if picks is not None and picks.provider:
+ from jarvis.agent_chat.catalog import provider_row
+
+ row = provider_row(picks.provider)
+ if row is not None:
+ default_model = row.default_model
return {
"models": offered_models(agent, live),
- "default_model": "",
+ "default_model": default_model,
"effort_levels": list(effort_levels(agent)),
"default_effort": default_effort(agent),
"permission_modes": permission_modes(agent),
diff --git a/tests/unit/agent_chat/test_agent_chat_ladders.py b/tests/unit/agent_chat/test_agent_chat_ladders.py
index a0e63f3617..8e4b54f3ac 100644
--- a/tests/unit/agent_chat/test_agent_chat_ladders.py
+++ b/tests/unit/agent_chat/test_agent_chat_ladders.py
@@ -470,6 +470,53 @@ def test_read_codex_models_reads_the_account_cache(monkeypatch, tmp_path: Path):
assert CODEX_FALLBACK_MODELS[0].id == "gpt-5.6-sol"
+def test_read_grok_models_reads_the_account_cache(monkeypatch, tmp_path: Path):
+ home = tmp_path / "grok-home"
+ home.mkdir()
+ (home / "models_cache.json").write_text(
+ json.dumps(
+ {
+ "models": {
+ "grok-4.7": {
+ "info": {
+ "id": "grok-4.7",
+ "name": "Grok 4.7",
+ "description": "SpaceXAI's latest frontier model",
+ "hidden": False,
+ "reasoning_efforts": [
+ {"value": "xhigh"},
+ {"value": "high"},
+ {"value": "low"},
+ ],
+ }
+ },
+ "grok-4.7-build-fast": {
+ "info": {
+ "id": "grok-4.7-build-fast",
+ "name": "Grok 4.7 Fast",
+ "description": "Fast variant. 2x the price.",
+ "hidden": False,
+ "reasoning_efforts": [{"value": "high"}],
+ }
+ },
+ "retired": {"info": {"id": "grok-old", "name": "Old", "hidden": True}},
+ }
+ }
+ ),
+ encoding="utf-8",
+ )
+ monkeypatch.setattr(runner_cli, "_account_env", lambda platform: {"GROK_HOME": str(home)})
+ rows = runner_cli.read_grok_models()
+ assert rows is not None
+ assert [row["id"] for row in rows] == ["grok-4.7", "grok-4.7-build-fast"]
+ assert rows[0]["label"] == "Grok 4.7"
+ assert rows[0]["efforts"] == ["", "low", "high", "xhigh"]
+ assert rows[0]["note"] == "SpaceXAI's latest frontier model"
+ assert rows[1]["note"] == "Fast variant. 2x the price."
+ monkeypatch.setattr(runner_cli, "_account_env", lambda platform: {"GROK_HOME": str(tmp_path)})
+ assert runner_cli.read_grok_models() is None
+
+
def test_catalog_rows_carry_per_model_efforts_for_cli_runners():
agy = provider_row("antigravity")
assert agy is not None
diff --git a/tests/unit/brain/test_grok_provider_wiring.py b/tests/unit/brain/test_grok_provider_wiring.py
index d1a17a955e..8ee7361e35 100644
--- a/tests/unit/brain/test_grok_provider_wiring.py
+++ b/tests/unit/brain/test_grok_provider_wiring.py
@@ -108,6 +108,37 @@ def test_grok_defaults_are_universal_and_tool_capable() -> None:
assert brain.supports_vision is True
+def test_grok_4_7_is_offered_and_leads_grok_build() -> None:
+ """Grok 4.7 is the Grok Build default; the API fallback still leads with 4.3."""
+ from jarvis.agent_chat.catalog import api_seat, provider_row
+ from jarvis.brain.cost import PRICING_USD_PER_MTOK
+ from jarvis.brain.model_catalog import CURATED_MODELS, GROK_BUILD_MODELS
+ from jarvis.missions.workers.grok_build_direct_worker import _DEFAULT_GROK_BUILD_MODEL
+ from jarvis.workspace import launch_picks
+
+ build_ids = [mid for mid, _label in GROK_BUILD_MODELS]
+ spec = catalog_spec("grok-build")
+ assert spec is not None
+ assert [model.id for model in spec.curated] == build_ids
+ assert spec.curated[0].id == "grok-4.7"
+ grok_ids = [model.id for model in CURATED_MODELS["grok"]]
+ assert grok_ids[0] == DEFAULT_MODEL == "grok-4.3"
+ assert "grok-4.7" in grok_ids
+ row = provider_row("grok-build")
+ assert row is not None
+ assert row.default_model == "grok-4.7"
+ assert [model.id for model in row.curated_models] == build_ids
+ assert api_seat("grok-build", "grok-4.7") == ("grok", "grok-4.7")
+ assert _DEFAULT_GROK_BUILD_MODEL == "grok-4.7"
+ offered = launch_picks.offered("grok-build")
+ assert offered["default_model"] == "grok-4.7"
+ assert offered["models"][0]["id"] == "grok-4.7"
+ assert "xhigh" in offered["effort_levels"]
+ assert PRICING_USD_PER_MTOK["grok-4.7"] == (2.0, 6.0)
+ assert PRICING_USD_PER_MTOK["grok-4.7-build-fast"] == (4.0, 12.0)
+ assert "x-ai/grok-4.7" in {model.id for model in CURATED_MODELS["openrouter"]}
+
+
def test_grok_has_authenticated_live_model_catalog() -> None:
spec = catalog_spec("grok")
assert spec is not None and spec.tier == "brain" and spec.live is True