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(ide): let Jarvis open new coding agents in a named workspace

rubenluetke10-beep6bce77dd3849
diff --git a/jarvis/agentic_ide/orchestration.py b/jarvis/agentic_ide/orchestration.py
index f3ba570a73..2686098633 100644
--- a/jarvis/agentic_ide/orchestration.py
+++ b/jarvis/agentic_ide/orchestration.py
@@ -12,14 +12,20 @@ import hashlib
import re
import threading
import time
-from collections.abc import Callable, Iterable
+from collections.abc import Awaitable, Callable, Iterable
from typing import Any
from uuid import UUID, uuid4
from jarvis.core.protocols import CodingSessionGateway
from jarvis.live.state import LiveLedger
-from .session import Registry, SessionError, accepts_prompts
+from .session import (
+ MAX_TERMINALS,
+ Registry,
+ SessionError,
+ accepts_prompts,
+ terminals_added_event,
+)
from .workspace_catalog import project_graph
@@ -44,8 +50,39 @@ _NEAR_MISS = 3
_TARGET_KEYS = ("project_id", "workspace_id", "terminal_id")
+# An apostrophe inside a name joins, it does not split: the workspace "VM`s"
+# is spoken "VMs" (live 2026-10-01), and "vm s" never matched "vms".
+_JOINERS = re.compile("['`\u00b4\u2018\u2019]")
+# Words around a spoken CLI name that never name the CLI ("Claude Code agent").
+_CLI_FILLER = frozenset(
+ {
+ "agent", "agents", "agenten", "terminal", "terminals", "session", "sessions",
+ "pane", "panes", "coding", "cli", "new",
+ }
+) # fmt: skip
+
+
def _words(text: str) -> list[str]:
- return [w for w in re.sub(r"[\W_]+", " ", text.casefold()).split() if w not in _FILLER]
+ joined = _JOINERS.sub("", text.casefold())
+ return [w for w in re.sub(r"[\W_]+", " ", joined).split() if w not in _FILLER]
+
+
+def _coding_cli(spoken: str) -> str | None:
+ """The coding CLI a spoken or typed name means, or ``None``.
+
+ Reads it the way the spoken spawn path does (``intent.canonical_agent``),
+ then forgives what a transcript wraps around the name or garbles after it:
+ "Claude Code agent" and "Claude Cotec" both mean a Claude Code pane.
+ """
+ from .intent import canonical_agent
+
+ words = [w for w in re.split(r"[\s_-]+", spoken.casefold()) if w]
+ kept = [w for w in words if w not in _CLI_FILLER] or words
+ for attempt in (" ".join(words), " ".join(kept), *kept[:1]):
+ found = canonical_agent(attempt) if attempt else None
+ if found and accepts_prompts(found):
+ return found
+ return None
def _score(reference: str, ids: Iterable[str], names: Iterable[str]) -> int:
@@ -111,6 +148,8 @@ class WorkspaceOrchestrator:
# request_id -> (target IDs, issued at, prompt sent under it or "")
self._issued: dict[str, tuple[dict[str, str], float, str]] = {}
self._issued_lock = threading.Lock()
+ # Announces new panes to the open UI; set by the runtime that owns a bus.
+ self.publish: Callable[[Any], Awaitable[Any]] | None = None
def graph(self) -> dict[str, Any]:
from jarvis.workspace.agents import pty_available
@@ -143,11 +182,13 @@ class WorkspaceOrchestrator:
),
}
- def resolve(self, args: dict[str, Any], graph: dict[str, Any]) -> dict[str, Any]:
+ def _workspace(
+ self, args: dict[str, Any], graph: dict[str, Any], agent_ref: str
+ ) -> tuple[dict[str, Any], dict[str, Any]] | dict[str, Any]:
+ """The one open (project, workspace) a request names, or the reply saying why not."""
projects = graph["projects"]
project_ref = str(args.get("project") or "")
workspace_ref = str(args.get("workspace") or "")
- agent_ref = str(args.get("agent") or "")
project_found = False
if project_ref:
matched = _best(project_ref, projects, lambda p: ((p["id"], p["path"]), (p["name"],)))
@@ -200,6 +241,14 @@ class WorkspaceOrchestrator:
"project_id": project["id"],
"workspace_id": workspace["id"],
}
+ return project, workspace
+
+ def resolve(self, args: dict[str, Any], graph: dict[str, Any]) -> dict[str, Any]:
+ agent_ref = str(args.get("agent") or "")
+ picked = self._workspace(args, graph, agent_ref)
+ if isinstance(picked, dict):
+ return picked
+ project, workspace = picked
agents = [a for a in workspace["agents"] if a["accepts_tasks"]]
if agent_ref:
named = _best(agent_ref, agents, lambda a: ((a["id"],), (a["name"],)))
@@ -221,22 +270,22 @@ class WorkspaceOrchestrator:
if not agents:
return {
"status": "unavailable",
- "reason": "No idle coding agent is available in this workspace.",
+ # Without the way forward the model asked the user whether to
+ # borrow another workspace's agent or wait (live 2026-10-01).
+ "reason": (
+ "No idle coding agent is available in this workspace. To start a new one "
+ "here, call create with these IDs; never borrow another workspace's agent."
+ ),
"project_id": project["id"],
"workspace_id": workspace["id"],
}
agent = agents[0]
- request_id = uuid4().hex
target = {
"project_id": project["id"],
"workspace_id": workspace["id"],
"terminal_id": agent["id"],
}
- with self._issued_lock:
- now = time.monotonic()
- for stale in [k for k, (_, at, _) in self._issued.items() if now - at > _RESOLVE_TTL_S]:
- del self._issued[stale]
- self._issued[request_id] = (target, now, "")
+ request_id = self._issue(target)
return {
"status": "resolved",
"request_id": request_id,
@@ -249,6 +298,125 @@ class WorkspaceOrchestrator:
"selection": "explicit_agent" if agent_ref else "first_idle_agent",
}
+ def _issue(self, target: dict[str, str]) -> str:
+ """Mint a request_id for ``target`` and remember it for id repair."""
+ request_id = uuid4().hex
+ with self._issued_lock:
+ now = time.monotonic()
+ for stale in [k for k, (_, at, _) in self._issued.items() if now - at > _RESOLVE_TTL_S]:
+ del self._issued[stale]
+ self._issued[request_id] = (target, now, "")
+ return request_id
+
+ async def create(self, args: dict[str, Any], *, trace_id: str = "") -> dict[str, Any]:
+ """Open new coding agents in one workspace, then optionally brief them.
+
+ A request for a NEW agent must never land on an existing pane, nor on a
+ background mission worker the workspace cannot show (live 2026-10-01:
+ "spawn a new Claude Code agent in the VMs workspace" became an
+ invisible worker in a separate checkout). The panes join the named or
+ visible workspace, the open view is told so they appear at once, and a
+ given prompt reaches each new pane through the ordinary receipted send,
+ which starts the agent even when its workspace is not on screen.
+ """
+ graph = await asyncio.to_thread(self.graph)
+ refs = {
+ "project": str(args.get("project_id") or args.get("project") or ""),
+ "workspace": str(args.get("workspace_id") or args.get("workspace") or ""),
+ }
+ picked = self._workspace(refs, graph, "")
+ if isinstance(picked, dict):
+ return picked
+ project, workspace = picked
+ spoken_cli = str(args.get("cli") or "").strip()
+ cli = _coding_cli(spoken_cli) if spoken_cli else None
+ if spoken_cli and cli is None:
+ from jarvis.workspace import agents as workspace_agents
+
+ return {
+ "status": "needs_clarification",
+ "kind": "cli",
+ "reason": f"'{spoken_cli}' is not a coding CLI this app can open.",
+ "candidates": [
+ a.name for a in workspace_agents.coding_agents() if accepts_prompts(a.name)
+ ],
+ }
+ try:
+ count = int(args.get("count") or 1)
+ except (TypeError, ValueError):
+ count = 1
+ count = max(1, min(count, MAX_TERMINALS))
+ name = str(args.get("name") or "").strip()
+ try:
+ if count == 1 and name:
+ created = [
+ await self.registry.add_terminal(
+ workspace_id=workspace["id"], agent=cli, name=name
+ )
+ ]
+ capped = False
+ else:
+ created, capped = await self.registry.add_terminals(
+ count, agent=cli, workspace_id=workspace["id"]
+ )
+ except SessionError as exc:
+ return {
+ "status": "not_accepted",
+ "reason": str(exc),
+ "project_id": project["id"],
+ "workspace_id": workspace["id"],
+ }
+ owner = self.registry.get(workspace["id"])
+ if self.publish is not None and owner is not None and created:
+ try:
+ await self.publish(
+ terminals_added_event(owner, created, source_layer="agentic_ide.orchestration")
+ )
+ except Exception as exc: # noqa: BLE001 - the panes exist either way
+ from loguru import logger
+
+ logger.warning("New coding agents were not announced to the UI: {}", exc)
+ targets = [
+ {
+ "project_id": project["id"],
+ "workspace_id": workspace["id"],
+ "terminal_id": "pane:" + term.history_id,
+ }
+ for term in created
+ ]
+ result: dict[str, Any] = {
+ "status": "created",
+ "project": project["name"],
+ "workspace": workspace["name"],
+ "project_id": project["id"],
+ "workspace_id": workspace["id"],
+ "agents": [
+ {"terminal_id": target["terminal_id"], "name": term.name, "cli": term.agent}
+ for target, term in zip(targets, created, strict=True)
+ ],
+ "requested": count,
+ "capped": capped,
+ }
+ prompt = str(args.get("prompt") or "").strip()
+ if prompt:
+ result["deliveries"] = list(
+ await asyncio.gather(
+ *(
+ self.run(
+ {
+ "action": "send",
+ **target,
+ "request_id": self._issue(target),
+ "prompt": prompt,
+ },
+ trace_id=trace_id,
+ )
+ for target in targets
+ )
+ )
+ )
+ return result
+
@staticmethod
def _choice(
kind: str, choices: list[dict], graph: dict[str, Any], *, unmatched: str = ""
@@ -344,6 +512,8 @@ class WorkspaceOrchestrator:
if action in {"inspect", "resolve"}:
graph = await asyncio.to_thread(self.graph)
return graph if action == "inspect" else self.resolve(args, graph)
+ if action == "create":
+ return await self.create(args, trace_id=trace_id)
if action not in {"send", "context"}:
raise ValueError("Unknown workspace orchestration action.")
target, request_id = self._reconcile(args, action)
diff --git a/jarvis/brain/factory.py b/jarvis/brain/factory.py
index 3ad9e1e25e..869554a8b9 100644
--- a/jarvis/brain/factory.py
+++ b/jarvis/brain/factory.py
@@ -845,6 +845,10 @@ def _register_runtime_manager(manager: Any) -> None:
from jarvis.agentic_ide.orchestration import get_orchestrator
orchestrator = await asyncio.to_thread(get_orchestrator)
+ bus = getattr(manager, "_bus", None)
+ if orchestrator.publish is None and bus is not None:
+ # New panes must reach the open workspace view at once.
+ orchestrator.publish = bus.publish
return await orchestrator.run(args, trace_id=trace_id)
async def session_tool(session_id: str) -> Any:
diff --git a/jarvis/brain/workspace_tool.py b/jarvis/brain/workspace_tool.py
index fb93829738..e0a57bcf5d 100644
--- a/jarvis/brain/workspace_tool.py
+++ b/jarvis/brain/workspace_tool.py
@@ -13,7 +13,12 @@ class WorkspaceOrchestrationTool:
risk_tier = "monitor"
is_action_tool = True
description = (
- "Route coding tasks to Projects > Workspaces > coding agents. Inspect the current graph; "
+ "Route coding tasks to Projects > Workspaces > coding agents. "
+ "When the user asks for a NEW agent, terminal or session (for example 'spawn two "
+ "Claude Code agents in the VMs workspace'), call create: it opens count new panes of "
+ "the named cli in the named or visible workspace and, with prompt, hands each the "
+ "task. Never reuse an existing agent and never use spawn_worker for that. "
+ "Inspect the current graph; "
"resolve explicit project/workspace/agent references (names or IDs) before sending. "
"With no named workspace resolve uses the visible workspace, and selects an idle agent "
"without requiring a focused terminal. On needs_clarification pick from the returned "
@@ -30,7 +35,10 @@ class WorkspaceOrchestrationTool:
"type": "object",
"additionalProperties": False,
"properties": {
- "action": {"type": "string", "enum": ["inspect", "resolve", "send", "context"]},
+ "action": {
+ "type": "string",
+ "enum": ["inspect", "resolve", "send", "context", "create"],
+ },
**{
key: {"type": "string"}
for key in (
@@ -50,6 +58,23 @@ class WorkspaceOrchestrationTool:
"description": "request_id from resolve; keep it unchanged on retries.",
},
"limit": {"type": "integer", "minimum": 1, "maximum": 100},
+ "cli": {
+ "type": "string",
+ "description": (
+ "create: the coding CLI as the user said it, e.g. 'Claude Code' or "
+ "'Codex'; omitted, the workspace's usual CLI."
+ ),
+ },
+ "count": {
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 16,
+ "description": "create: how many new agents to open (default 1).",
+ },
+ "name": {
+ "type": "string",
+ "description": "create: optional name for a single new agent.",
+ },
},
"required": ["action"],
}
@@ -65,7 +90,12 @@ class WorkspaceOrchestrationTool:
"level": "read" if self.risk_tier_for_args(args) == "safe" else "modify",
"project": str(args.get("project_id") or args.get("project") or ""),
"workspace": str(args.get("workspace_id") or args.get("workspace") or ""),
- "agent": str(args.get("terminal_id") or args.get("agent") or ""),
+ "agent": str(args.get("terminal_id") or args.get("agent") or "")
+ or (
+ f"{args.get('count') or 1} new {args.get('cli') or 'agent'}"
+ if args.get("action") == "create"
+ else ""
+ ),
"task": str(args.get("prompt") or "")[:240],
}
diff --git a/jarvis/live/config.py b/jarvis/live/config.py
index 5e8daaf3e6..835ce871a6 100644
--- a/jarvis/live/config.py
+++ b/jarvis/live/config.py
@@ -48,6 +48,9 @@ class LiveConfig(BaseModel):
"project or workspace references override visible context. Do not switch the UI "
"to dispatch elsewhere. Ask when resolution is ambiguous. Reuse the same "
"request_id for a retry and never replay uncertain delivery. "
+ "A request for a NEW coding agent (or several: 'two Claude Code agents') is "
+ "workspace-orchestrate create in the named or visible workspace, with cli, "
+ "count and the task as prompt; never an existing agent and never spawn_worker. "
"Computer-use tasks use the selected thinking model and the same credential. "
+ self.backend_instructions
),
diff --git a/jarvis/live/native.py b/jarvis/live/native.py
index 69ad81552d..7acf2099c1 100644
--- a/jarvis/live/native.py
+++ b/jarvis/live/native.py
@@ -69,6 +69,8 @@ class NativeLiveVoiceSession(LiveVoiceSession):
"explicit approval. A started job is not complete. Never invent tool results. "
"Use workspace-orchestrate for coding tasks: inspect and resolve project, "
"workspace and agent references, then send to the returned stable IDs. "
+ "For a NEW coding agent call workspace-orchestrate create (cli, count, "
+ "prompt) in the named or visible workspace; never spawn_worker. "
"Explicit references override the visible workspace; ask on ambiguity. "
"Do not switch the UI to address another workspace. Reuse request_id on "
"retries and never replay uncertain delivery."
diff --git a/jarvis/plugins/tool/spawn_worker.py b/jarvis/plugins/tool/spawn_worker.py
index c56cac7ef0..8427359212 100644
--- a/jarvis/plugins/tool/spawn_worker.py
+++ b/jarvis/plugins/tool/spawn_worker.py
@@ -340,7 +340,10 @@ class SpawnWorkerTool:
"it on your own initiative during ordinary conversation: questions, "
"remarks, news, quick lookups, single web searches, or anything you "
"can answer inline in this turn. Without an explicit request, answer "
- "inline yourself and at most OFFER to start a background agent. Pass "
+ "inline yourself and at most OFFER to start a background agent. "
+ "It runs in its own checkout and NEVER appears in the user's "
+ "workspaces: a new coding agent (Claude Code, Codex, ...) in a "
+ "workspace is workspace-orchestrate create, not this tool. Pass "
"the user utterance verbatim plus optional 3-5 short brainstorm "
"notes as ``context_hints``."
)
diff --git a/tests/contract/test_workspace_orchestration.py b/tests/contract/test_workspace_orchestration.py
index 517e55ac84..ffd80bdbae 100644
--- a/tests/contract/test_workspace_orchestration.py
+++ b/tests/contract/test_workspace_orchestration.py
@@ -356,3 +356,83 @@ async def test_an_unmatched_reference_lists_every_open_workspace(rig):
names = {c["workspace"] for c in result["candidates"]}
assert names == {"Personal Jarvis", "Other project"}
assert "Something else entirely" in result["reason"]
+
+
+def runnable(monkeypatch):
+ from jarvis.agentic_ide import session as session_mod
+
+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))
+
+
+async def test_new_agents_open_in_the_named_background_workspace(rig, runnable):
+ # Live 2026-10-01: "spawn a new Claude Code agent in the VMs workspace"
+ # became an invisible mission worker; no pane ever appeared there.
+ orchestrator, registry, sessions = rig
+ owner = registry.sessions[0]
+ owner.name = "VM`s"
+ before_active = registry.active_id
+ existing = [t.history_id for t in owner.terminals]
+ published = []
+
+ async def publish(event):
+ published.append(event)
+
+ orchestrator.publish = publish
+ result = await orchestrator.run(
+ {"action": "create", "workspace": "VMs Workspace", "cli": "Claude Cotec", "count": 2}
+ )
+ assert result["status"] == "created", result
+ assert result["workspace_id"] == owner.id
+ assert [a["cli"] for a in result["agents"]] == ["claude", "claude"]
+ assert len(owner.terminals) == len(existing) + 2
+ assert [t.history_id for t in owner.terminals[: len(existing)]] == existing
+ assert registry.active_id == before_active
+ assert not sessions.calls
+ assert published and published[0].session_id == owner.id
+ assert len(published[0].names) == 2
+
+
+async def test_a_new_agent_with_a_task_is_briefed_through_a_receipted_send(rig, runnable):
+ orchestrator, registry, sessions = rig
+ result = await orchestrator.run(
+ {
+ "action": "create",
+ "workspace": "Personal Jarvis",
+ "cli": "Claude Code",
+ "prompt": "Deep-dive the update path",
+ }
+ )
+ assert result["status"] == "created", result
+ new_pane = result["agents"][0]["terminal_id"]
+ assert [d["status"] for d in result["deliveries"]] == ["accepted"]
+ assert sessions.calls[0]["terminal_id"] == new_pane
+ assert sessions.calls[0]["prompt"] == "Deep-dive the update path"
+
+
+async def test_an_unknown_cli_asks_instead_of_opening_a_substitute(rig, runnable):
+ owner = rig[1].sessions[0]
+ count = len(owner.terminals)
+ result = await rig[0].run(
+ {"action": "create", "workspace": "Personal Jarvis", "cli": "Banana"}
+ )
+ assert result["status"] == "needs_clarification" and result["kind"] == "cli"
+ assert len(owner.terminals) == count
+
+
+async def test_no_idle_agent_points_to_create(rig):
+ for term in rig[1].session.terminals:
+ term.activity = "working"
+ result = await rig[0].run({"action": "resolve"})
+ assert result["status"] == "unavailable"
+ assert "create" in result["reason"]
+
+
+def test_create_is_a_logged_action_with_a_valid_live_schema(rig):
+ import jsonschema
+
+ tool = WorkspaceOrchestrationTool(rig[0])
+ args = {"action": "create", "workspace": "VMs", "cli": "Codex", "count": 3, "prompt": "x"}
+ jsonschema.validate(args, tool.schema)
+ assert tool.risk_tier_for_args(args) == "monitor"
+ assert tool.describe_args(args)["agent"] == "3 new Codex"