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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(agentic-ide): let a new-agent request open a new workspace
rubenluetke10-beep6fea32e8e5ba
diff --git a/jarvis/agentic_ide/orchestration.py b/jarvis/agentic_ide/orchestration.pyindex 392203c30c..24051d1936 100644--- a/jarvis/agentic_ide/orchestration.py+++ b/jarvis/agentic_ide/orchestration.py@@ -725,10 +725,34 @@ class WorkspaceOrchestrator:"workspace": session.name,"agents": [t.name for t in session.terminals],}- # open_workspace: a folder by path, or a known project by name.+ scope = str(args.get("_dispatch_scope") or "")+ if not scope:+ return await self._open_workspace(args, graph, trace_id=trace_id, creation_id="")+ # One request scope opens at most one workspace: a retry, or a second+ # call in the same turn, reads the receipt instead of opening another.+ arguments = {k: v for k, v in args.items() if not k.startswith("_") and k != "request_id"}+ if args.get("image_refs"):+ arguments["image_scope"] = args.get("_image_scope", "")+ previous = await asyncio.to_thread(+ self.ledger.claim, "workspace-create", scope, "open_workspace", arguments, 0,+ )+ if previous is not None:+ return previous+ result = await self._open_workspace(args, graph, trace_id=trace_id, creation_id=scope)+ result["request_id"] = scope+ await asyncio.to_thread(self.ledger.finish, "workspace-create", scope, result)+ return result++ async def _open_workspace(+ self, args: dict[str, Any], graph: dict[str, Any], *, trace_id: str, creation_id: str,+ ) -> dict[str, Any]:+ """Open a folder by path, or a known project by name or ID, as a NEW workspace."""+ from .session import workspace_changed_event+folder = str(args.get("folder") or "").strip()- project_id: str | None = None- project_ref = str(args.get("project") or "").strip()+ # An explicit project_id with a folder is checked by registry.start.+ project_id: str | None = str(args.get("project_id") or "").strip() or None+ project_ref = str(args.get("project_id") or args.get("project") or "").strip()if not folder and project_ref:owners = _best(project_ref, graph["projects"], lambda p: ((p["id"], p["path"]), (p["name"],))@@ -770,6 +794,15 @@ class WorkspaceOrchestrator:session, "opened", source_layer="agentic_ide.orchestration"))+ targets = [+ {+ "project_id": session.project_id,+ "workspace_id": session.id,+ "terminal_id": "pane:" + t.history_id,+ }+ for t in session.terminals+ ]+ delivery_ids = [self._issue(target) for target in targets]result: dict[str, Any] = {"status": "opened","project_id": session.project_id,@@ -777,23 +810,29 @@ class WorkspaceOrchestrator:"workspace": session.name,"folder": session.folder,"agents": [- {"terminal_id": "pane:" + t.history_id, "name": t.name, "cli": t.agent}- for t in session.terminals+ {"terminal_id": target["terminal_id"], "name": t.name, "cli": t.agent,+ "request_id": request_id}+ for target, t, request_id in zip(+ targets, session.terminals, delivery_ids, strict=True+ )],}+ if creation_id:+ # Persist identity before the brief, as create does: a cancelled or+ # late result must never become permission to open another workspace.+ await asyncio.to_thread(+ self.ledger.finish, "workspace-create", creation_id,+ {**result, "status": "uncertain", "success": False, "request_id": creation_id,+ "reason": "The new workspace exists; startup/delivery is pending. Observe "+ "only these IDs. Do not reopen, reassign or send correction prompts."},+ )prompt = str(args.get("prompt") or "").strip()if prompt:result["deliveries"] = await self._brief(- [- {- "project_id": session.project_id,- "workspace_id": session.id,- "terminal_id": "pane:" + t.history_id,- }- for t in session.terminals- ],+ targets,prompt,trace_id,+ request_ids=delivery_ids,image_refs=args.get("image_refs", []),image_scope=args.get("_image_scope", ""),)@@ -835,7 +874,7 @@ class WorkspaceOrchestrator:async def _brief(self, targets: list[dict[str, str]], prompt: str, trace_id: str,- *, image_refs: list[str] | None = None, image_scope: str = "",+ *, request_ids: list[str], image_refs: list[str] | None = None, image_scope: str = "",) -> list[dict[str, Any]]:return list(await asyncio.gather(@@ -844,14 +883,14 @@ class WorkspaceOrchestrator:{"action": "send",**target,- "request_id": self._issue(target),+ "request_id": request_id,"prompt": prompt,"image_refs": image_refs or [],"_image_scope": image_scope,},trace_id=trace_id,)- for target in targets+ for target, request_id in zip(targets, request_ids, strict=True))))@@ -983,8 +1022,11 @@ class WorkspaceOrchestrator:await asyncio.to_thread(self.ledger.operation, "workspace-create", dispatch_scope)if dispatch_scope else None)+ # open_workspace always starts a NEW workspace with NEW panes, so it is+ # a creation like create (live 2026-10-07: a new-agent workspace request+ # was refused as pane reuse and nothing opened).if (args.get("_requires_new") or creation) and action not in {- "inspect", "create", "context", "observe",+ "inspect", "create", "open_workspace", "context", "observe",}:allowed = {a["terminal_id"] for a in (creation or {}).get("agents", [])@@ -994,8 +1036,9 @@ class WorkspaceOrchestrator:if action != "send" or str(args.get("terminal_id") or "") not in allowed:return {"status": "new_agent_required", "success": False,- "reason": "This request requires NEW panes. Use create; do not resolve, "- "reuse or send correction prompts to existing agents.",+ "reason": "This request requires NEW panes. Use create (or open_workspace "+ "for a new workspace); do not resolve, reuse or send "+ "correction prompts to existing agents.","creation": creation,}# create(prompt=...) already owns delivery, including uncertainty.diff --git a/jarvis/brain/workspace_tool.py b/jarvis/brain/workspace_tool.pyindex ed8144ee79..1f85c68bf9 100644--- a/jarvis/brain/workspace_tool.py+++ b/jarvis/brain/workspace_tool.py@@ -58,8 +58,9 @@ class WorkspaceOrchestrationTool:"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. ""Mixed CLIs in one request ('five Claude Code and three Codex') go in agents: "- "[{cli, count}, ...]. open_workspace opens a NEW workspace for folder (absolute "- "path) or a known project, with agents and an optional prompt; restore reopens a "+ "[{cli, count}, ...]. open_workspace opens a NEW workspace (with NEW panes) for "+ "folder (absolute path) or a known project (name or project_id), with agents and "+ "an optional prompt; restore reopens a ""closed workspace; show brings one on screen. For one pane (by agent call-sign or ""terminal_id): observe reads its screen, question and newest events; respond types ""the answer to the question or permission prompt it shows (prompt = the answer); keys "diff --git a/tests/contract/test_workspace_dispatch_isolation.py b/tests/contract/test_workspace_dispatch_isolation.pyindex 094775857b..c325f171e6 100644--- a/tests/contract/test_workspace_dispatch_isolation.py+++ b/tests/contract/test_workspace_dispatch_isolation.py@@ -354,3 +354,112 @@ async def test_live_retries_use_host_request_scope_and_old_revision_cannot_act(assert len(rig[2].calls) == 1finally:ledger.close()+++def project_of(rig, name="Personal Jarvis"):+ return next(p for p in rig[0].graph()["projects"] if p["name"] == name)+++OPEN_TEXT = "Open a new workspace with a new Claude Code agent to audit the startup instructions."++[email protected]("briefed", [True, False], ids=["agents-and-prompt", "bare"])+async def test_new_request_opens_one_new_workspace_and_never_touches_old_panes(+ rig, runnable, briefed+):+ # Live 2026-10-07: open_workspace for a NEW agent was refused as pane reuse+ # ("new_agent_required"), with and without agents/prompt; nothing opened.+ orchestrator, registry, sessions = rig+ project = project_of(rig)+ before = {w.id for w in registry.sessions}+ existing = {t.history_id for w in registry.sessions for t in w.terminals}+ args = {"action": "open_workspace", "project_id": project["id"], "name": "Agents.md"}+ if briefed:+ args |= {"agents": [{"cli": "Claude Code", "count": 1}], "prompt": "Audit the stack"}+ else:+ args |= {"folder": project["path"]}+ tool = WorkspaceOrchestrationTool(orchestrator)+ first = await tool.execute(args, context(OPEN_TEXT))+ assert first.success, first+ assert first.output["status"] == "opened"+ assert first.output["workspace"] == "Agents.md"+ assert first.output["workspace_id"] not in before+ new_ids = [a["terminal_id"] for a in first.output["agents"]]+ assert len(new_ids) == 1+ assert not {i.removeprefix("pane:") for i in new_ids} & existing+ assert [c["terminal_id"] for c in sessions.calls] == (new_ids if briefed else [])+ # A retry in the same request scope reads the receipt; no second workspace.+ reopened = WorkspaceOrchestrationTool(+ WorkspaceOrchestrator(registry, sessions, orchestrator.ledger)+ )+ repeated = await reopened.execute(args, context(OPEN_TEXT))+ assert repeated.output == first.output+ assert len(registry.sessions) == len(before) + 1+ assert len(sessions.calls) == (1 if briefed else 0)+ # The new-agent guard still keeps old panes out of this request.+ refused = await tool.execute({"action": "resolve"}, context(OPEN_TEXT))+ assert refused.output["status"] == "new_agent_required"+ old = next(t for w in registry.sessions if w.id in before for t in w.terminals)+ owner = next(w for w in registry.sessions if w.id in before)+ stolen = await tool.execute(+ {+ "action": "send",+ "project_id": owner.project_id,+ "workspace_id": owner.id,+ "terminal_id": "pane:" + old.history_id,+ "prompt": "Correction",+ },+ context(OPEN_TEXT),+ )+ assert stolen.output["status"] == "new_agent_required"+ assert len(sessions.calls) == (1 if briefed else 0)+++async def test_bare_new_workspace_pane_takes_one_assignment_only(rig, runnable):+ tool = WorkspaceOrchestrationTool(rig[0])+ project = project_of(rig)+ opened = await tool.execute(+ {"action": "open_workspace", "folder": project["path"], "name": "Agents.md"},+ context(OPEN_TEXT),+ )+ pane = opened.output["agents"][0]+ args = {+ "action": "send",+ "project_id": opened.output["project_id"],+ "workspace_id": opened.output["workspace_id"],+ "terminal_id": pane["terminal_id"],+ "request_id": pane["request_id"],+ "prompt": "Task",+ }+ first = await tool.execute(args, context(OPEN_TEXT))+ assert first.success, first+ assert not (+ await tool.execute({**args, "prompt": "Correction: another task"}, context(OPEN_TEXT))+ ).success+ assert len(rig[2].calls) == 1+++async def test_second_open_in_the_same_request_cannot_open_another_workspace(rig, runnable):+ tool = WorkspaceOrchestrationTool(rig[0])+ project = project_of(rig)+ count = len(rig[1].sessions)+ base = {"action": "open_workspace", "folder": project["path"]}+ assert (await tool.execute({**base, "name": "Agents.md"}, context(OPEN_TEXT))).success+ other = await tool.execute({**base, "name": "Another"}, context(OPEN_TEXT))+ assert not other.success+ assert len(rig[1].sessions) == count + 1+++async def test_open_workspace_by_project_id_alone_opens_that_project(rig, runnable):+ project = project_of(rig, "Other project")+ result = await rig[0].run({"action": "open_workspace", "project_id": project["id"]})+ assert result["status"] == "opened", result+ assert result["project_id"] == project["id"]++[email protected]("action", ["restore", "show"])+async def test_new_request_still_cannot_reopen_or_show_existing_workspaces(rig, action):+ result = await WorkspaceOrchestrationTool(rig[0]).execute(+ {"action": action, "workspace": "Personal Jarvis"}, context(OPEN_TEXT)+ )+ assert result.output["status"] == "new_agent_required"