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(agent-chat): run the Claude Agents slot on the signed-in subscription

rubenluetke10-beep7a71a8f56613
diff --git a/jarvis/agent_chat/service.py b/jarvis/agent_chat/service.py
index 87458c2ed8..bab97d7a94 100644
--- a/jarvis/agent_chat/service.py
+++ b/jarvis/agent_chat/service.py
@@ -548,10 +548,9 @@ class AgentChatService:
manager = get_brain_manager()
selection = worker_selection(getattr(manager, "_config", None))
if selection is not None:
- provider, selected_runner = subscription_seat(selection.provider) or (
- selection.provider,
- "brain",
- )
+ # The Claude slot probes the CLI login (cached); keep it off the loop.
+ seat = await asyncio.to_thread(subscription_seat, selection.provider)
+ provider, selected_runner = seat or (selection.provider, "brain")
if (session.provider, session.model) != (provider, selection.model or ""):
session = replace(
session,
diff --git a/jarvis/core/task_agent.py b/jarvis/core/task_agent.py
index 5fd74175cd..77a79d3a3e 100644
--- a/jarvis/core/task_agent.py
+++ b/jarvis/core/task_agent.py
@@ -45,10 +45,47 @@ def release_scope(session_id: str) -> None:
def subscription_seat(provider: str) -> tuple[str, str] | None:
- """Identity aliases, not model or feature gates."""
- return {
+ """Identity aliases, not model or feature gates.
+
+ ``claude-api`` is the one Claude slot of the Agents selection. Missions
+ run it on the signed-in Claude subscription whenever one exists
+ (``missions.init`` -> ``claude_direct``), so a chat or scheduled task on the
+ same slot does too; only without that login is it the per-token API row.
+ Live 2026-09-29: the front-page chat answered through a stale Anthropic
+ key while the Agents tab showed Claude Max as active.
+ """
+ seat = {
"codex": ("openai-codex", "codex-cli"),
"claude-cli": ("claude-api", "claude-cli"),
"antigravity": ("antigravity", "agy-cli"),
"grok-build": ("grok-build", "grok-cli"),
}.get(provider)
+ if seat is None and provider == "claude-api" and _claude_subscription_ready():
+ seat = ("claude-api", "claude-cli")
+ return seat
+
+
+_CLAUDE_LOGIN_TTL_S = 60.0
+_claude_login: tuple[float, bool] | None = None
+
+
+def _claude_subscription_ready() -> bool:
+ """Whether the Claude CLI is signed in with a subscription (cached 60 s)."""
+ import time
+
+ global _claude_login
+ now = time.monotonic()
+ if _claude_login is not None and now - _claude_login[0] < _CLAUDE_LOGIN_TTL_S:
+ return _claude_login[1]
+ try:
+ from jarvis.claude_auth import ClaudeAuthService
+
+ status = ClaudeAuthService().status()
+ ready = bool(status.connected and status.mode == "subscription")
+ except Exception: # noqa: BLE001 - no login readable means the API row answers
+ import logging
+
+ logging.getLogger(__name__).info("Claude login probe failed", exc_info=True)
+ ready = False
+ _claude_login = (now, ready)
+ return ready
diff --git a/tests/unit/core/test_task_agent_claude_seat.py b/tests/unit/core/test_task_agent_claude_seat.py
new file mode 100644
index 0000000000..8052309d11
--- /dev/null
+++ b/tests/unit/core/test_task_agent_claude_seat.py
@@ -0,0 +1,72 @@
+"""The Claude Agents slot answers on the subscription when one is signed in.
+
+Live 2026-09-29: Agents showed Claude Max as active, yet the front-page chat
+ran ``claude-api`` through the brain runner and replied with a stale
+Anthropic key's 401. Missions already run that slot on the subscription.
+"""
+
+from __future__ import annotations
+
+import pytest
+
+from jarvis.core import task_agent
+
+
[email protected](autouse=True)
+def _fresh_login_cache(monkeypatch):
+ monkeypatch.setattr(task_agent, "_claude_login", None)
+
+
+def test_claude_slot_uses_the_cli_when_the_subscription_is_signed_in(monkeypatch) -> None:
+ monkeypatch.setattr(task_agent, "_claude_subscription_ready", lambda: True)
+
+ assert task_agent.subscription_seat("claude-api") == ("claude-api", "claude-cli")
+
+
+def test_claude_slot_stays_on_the_api_row_without_a_subscription(monkeypatch) -> None:
+ monkeypatch.setattr(task_agent, "_claude_subscription_ready", lambda: False)
+
+ assert task_agent.subscription_seat("claude-api") is None
+
+
+def test_other_seats_never_probe_the_claude_login(monkeypatch) -> None:
+ def _unexpected() -> bool:
+ raise AssertionError("only the Claude slot may probe the Claude login")
+
+ monkeypatch.setattr(task_agent, "_claude_subscription_ready", _unexpected)
+
+ assert task_agent.subscription_seat("codex") == ("openai-codex", "codex-cli")
+ assert task_agent.subscription_seat("openai") is None
+
+
+def test_login_probe_is_cached(monkeypatch) -> None:
+ calls = []
+
+ class _Status:
+ connected = True
+ mode = "subscription"
+
+ class _Service:
+ def status(self):
+ calls.append(1)
+ return _Status()
+
+ import jarvis.claude_auth as claude_auth
+
+ monkeypatch.setattr(claude_auth, "ClaudeAuthService", _Service)
+
+ assert task_agent._claude_subscription_ready() is True
+ assert task_agent._claude_subscription_ready() is True
+ assert len(calls) == 1
+
+
+def test_unreadable_login_means_no_subscription(monkeypatch) -> None:
+ class _Broken:
+ def status(self):
+ raise OSError("claude binary vanished")
+
+ import jarvis.claude_auth as claude_auth
+
+ monkeypatch.setattr(claude_auth, "ClaudeAuthService", _Broken)
+
+ assert task_agent._claude_subscription_ready() is False