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(agent-chat): stop agy society turns dying on the first shell call
rubenluetke10-beep810344c04059
diff --git a/jarvis/agent_chat/jarvis_harness.py b/jarvis/agent_chat/jarvis_harness.pyindex 750667519e..ac6c1ef74b 100644--- a/jarvis/agent_chat/jarvis_harness.py+++ b/jarvis/agent_chat/jarvis_harness.py@@ -179,6 +179,59 @@ def codex_config_args(session_id: str | None = None) -> list[str]:return []+#: Workspace plugin agy discovers under ``.agents/plugins/``. agy has no+#: ``--mcp-config`` flag; Claude-shaped JSON on argv is ignored.+_AGY_PLUGIN_DIRNAME: Final[str] = "jarvis-hands"+++def agy_mcp_server_entry(session_id: str | None = None) -> dict[str, Any] | None:+ """The Antigravity ``mcpServers`` row for this app's tool server.++ agy speaks ``serverUrl`` + ``headers`` (not Claude's ``type``/``url``).+ ``None`` when the app cannot offer the tools — same contract as+ :func:`mcp_config_json`.+ """+ try:+ url = endpoint()+ key = control_key()+ if not url or not key:+ return None+ headers: dict[str, str] = {"Authorization": f"Bearer {key}"}+ if session_id:+ headers[HEADER_NAME] = session_id+ return {"serverUrl": url, "headers": headers}+ except Exception: # noqa: BLE001 — see mcp_config_json+ log.warning("agent chat: could not build the Jarvis agy MCP entry", exc_info=True)+ return None+++def install_agy_jarvis_plugin(cwd: Path, session_id: str | None = None) -> Path | None:+ """Drop a workspace plugin so print-mode agy mounts Jarvis' tools.++ agy discovers MCP from ``.agents/plugins/<name>/mcp_config.json`` in the+ workspace (and from the global ``mcp_config.json``, which this does not+ touch). Additive: a failure here never fails the turn.+ """+ entry = agy_mcp_server_entry(session_id)+ if entry is None:+ return None+ try:+ plugin_dir = Path(cwd) / ".agents" / "plugins" / _AGY_PLUGIN_DIRNAME+ plugin_dir.mkdir(parents=True, exist_ok=True)+ (plugin_dir / "plugin.json").write_text(+ json.dumps({"name": "jarvis-hands"}, ensure_ascii=False),+ encoding="utf-8",+ )+ payload = {"mcpServers": {_SERVER_NAME: entry}}+ (plugin_dir / "mcp_config.json").write_text(+ json.dumps(payload, ensure_ascii=False), encoding="utf-8"+ )+ return plugin_dir+ except Exception: # noqa: BLE001 — see mcp_config_json+ log.warning("agent chat: could not install the Jarvis agy plugin", exc_info=True)+ return None++def apply_env(env: dict[str, str]) -> dict[str, str]:"""Put the control key into a child environment, if there is one to give."""key = control_key()@@ -373,6 +426,7 @@ __all__ = ["SYSTEM_PREAMBLE","TRANSCRIPT_MAX_CHARS","Identity",+ "agy_mcp_server_entry","apply_env","build_identity","codex_config_args",@@ -381,6 +435,7 @@ __all__ = ["endpoint","identity_dir","identity_prompt",+ "install_agy_jarvis_plugin","mcp_config_json","remove_identity_file","render_transcript",diff --git a/jarvis/agent_chat/permissions.py b/jarvis/agent_chat/permissions.pyindex 36f212286c..1b2f5534ae 100644--- a/jarvis/agent_chat/permissions.py+++ b/jarvis/agent_chat/permissions.py@@ -128,8 +128,10 @@ _AGY: Final[tuple[PermissionMode, ...]] = (PermissionMode("accept-edits","Auto-accept edits",- "Edits run on their own; commands that need a permission are declined "- "and reported to the model.",+ "Edits run on their own. In this chat the CLI cannot ask back — a "+ "command that still wanted a confirmation used to abort the whole "+ "turn — so commands run too (`--dangerously-skip-permissions`). "+ "Plan is the read-only stance.",),PermissionMode("plan",diff --git a/jarvis/agent_chat/runner_cli.py b/jarvis/agent_chat/runner_cli.pyindex 59b0784014..0665d12374 100644--- a/jarvis/agent_chat/runner_cli.py+++ b/jarvis/agent_chat/runner_cli.py@@ -39,9 +39,13 @@ Every CLI that keeps a conversation resumes it natively (``claude --resume``,in ``vendor_session`` and a later turn continues the same conversation — thetools, skills, MCP servers and permissions are the CLI's own, exactly as ina terminal. The person's permission mode maps onto the closest stance each-CLI offers; a print-mode CLI cannot ask back, so ``ask`` means "edits yes,-anything riskier is declined by the CLI and reported to the model", and-``auto`` bypasses.+CLI offers. A print-mode CLI cannot ask back: Claude answers permission+prompts over stdin; Codex has ``--approve-for-me``. agy 1.1.26 instead+soft-denies the tool and **exits**, so the chat shows ``run_command - failed``+and goes idle with no answer — ``accept-edits`` therefore also passes+``--dangerously-skip-permissions`` (the same flag the mission worker has+used since 2026-06). Jarvis tools reached over MCP still go through+:class:`~jarvis.core.protocols.SupervisorToolGateway`.Spawning follows the mission workers: shell-free argv, the prompt on stdinwhere the binary accepts it, ``NO_WINDOW_CREATIONFLAGS``, UTF-8 decoding,@@ -605,6 +609,19 @@ def _nearest_lower(effort: str, ladder: list[str]) -> str:return lower[-1] if lower else ladder[0]+def _resolved_cwd(raw: Path | str | None) -> Path:+ """Absolute working folder for a CLI spawn.++ agy refuses a relative ``--add-dir`` (``path is not absolute``) and a+ society session used to store ``data\\society\\<id>\\workspace`` relative+ to the app cwd. Resolve here so every planner sees the same folder.+ """+ path = Path(raw or Path.home()).expanduser()+ if not path.is_absolute():+ path = path.resolve()+ return path++def plan_agy(*,prompt: str,@@ -619,26 +636,35 @@ def plan_agy(# agy has no system-prompt flag: the identity rides in front of the prompt# on stdin, on a fresh conversation (a resumed one already knows).prompt = _with_identity(prompt, identity, resume)+ work = _resolved_cwd(cwd)+ if identity is not None:+ # agy has no --mcp-config; a workspace plugin is how print-mode+ # actually sees Jarvis' tools (gmail, linear, the rest of the gateway).+ jarvis_harness.install_agy_jarvis_plugin(work, identity.session_id)argv = [*agy_argv_prefix(),"--output-format","stream-json","--add-dir",- str(cwd),+ str(work),# agy's own print timeout is 5 min; ours is the long one."--print-timeout",f"{int(_TURN_TIMEOUT_S // 60)}m",]- if mode == "skip-permissions":- argv += ["--dangerously-skip-permissions"]- elif mode == "plan":+ if mode == "plan":argv += ["--mode", "plan"]else:- argv += ["--mode", "accept-edits"]+ # Print-mode agy 1.1.26: a tool that still wants a confirmation is+ # soft-denied and the process exits. ``accept-edits`` still asks for+ # RunCommand, so without this flag the turn dies after the first+ # shell call (live 2026-09-04, society:test / society:gamil-agent).+ argv += ["--dangerously-skip-permissions"]+ if mode == "accept-edits":+ argv += ["--mode", "accept-edits"]argv += agy_model_args(model, effort, _agy_catalog_cached())if resume:argv += ["--conversation", resume]- env = dict(os.environ)+ env = jarvis_harness.apply_env(_account_env("antigravity"))env.setdefault("AGY_CLI_HIDE_LOGO", "1")env.setdefault("PYTHONIOENCODING", "utf-8")# Prompt on stdin: no argv length limit, and no ``-p`` that could swallow@@ -2379,7 +2405,7 @@ async def _run_cli_once() -> _Outcome:session = handle.sessionchat_ref = approval_ref(session.session_id)- cwd = Path(session.cwd or Path.home())+ cwd = _resolved_cwd(session.cwd or Path.home())effort = normalize_effort(session.provider, session.effort)planner = _PLANNERS[runner]status = "done"diff --git a/jarvis/society/chat_binding.py b/jarvis/society/chat_binding.pyindex 3de1cfcde6..4062cf63b7 100644--- a/jarvis/society/chat_binding.py+++ b/jarvis/society/chat_binding.py@@ -68,6 +68,10 @@ def _workspace(cfg: Any, agent: AgentRecord) -> str:folder.mkdir(parents=True, exist_ok=True)except OSError:log.warning("society: workspace %s could not be created", folder, exc_info=True)+ try:+ folder = folder.resolve()+ except OSError:+ passreturn str(folder)diff --git a/tests/unit/agent_chat/test_agent_chat_ladders.py b/tests/unit/agent_chat/test_agent_chat_ladders.pyindex 48680db448..5bc7f4f2d3 100644--- a/tests/unit/agent_chat/test_agent_chat_ladders.py+++ b/tests/unit/agent_chat/test_agent_chat_ladders.py@@ -183,6 +183,9 @@ def test_agy_planner_speaks_agy(monkeypatch, tmp_path: Path):assert plan.shape == "agy"assert plan.stdin_text == "do it" and "-p" not in argv and "--print" not in argvassert argv[argv.index("--mode") + 1] == "accept-edits"+ # Print-mode agy exits after a soft-denied RunCommand; accept-edits+ # therefore also skips confirmations so the turn can finish.+ assert "--dangerously-skip-permissions" in argvassert argv[argv.index("--add-dir") + 1] == str(tmp_path)assert "--print-timeout" in argv# Pro knows only low/high: medium snaps to low, and the pair is sent.@@ -201,10 +204,30 @@ def test_agy_planner_speaks_agy(monkeypatch, tmp_path: Path):assert ("--dangerously-skip-permissions" in skip and skip[skip.index("--conversation") + 1] == "c1")+ assert "--mode" not in skipplanned = plan_agy(prompt="x", cwd=tmp_path, model="", effort="", permission_mode="plan", resume=None).argvassert planned[planned.index("--mode") + 1] == "plan"+ assert "--dangerously-skip-permissions" not in planned+++def test_agy_planner_resolves_a_relative_cwd(monkeypatch, tmp_path: Path):+ monkeypatch.setattr(runner_cli, "agy_argv_prefix", lambda: ["agy"])+ monkeypatch.setattr(runner_cli, "_agy_catalog_cached", lambda: None)+ monkeypatch.chdir(tmp_path)+ (tmp_path / "data" / "society" / "test" / "workspace").mkdir(parents=True)+ plan = plan_agy(+ prompt="x",+ cwd=Path("data") / "society" / "test" / "workspace",+ model="",+ effort="",+ permission_mode="accept-edits",+ resume=None,+ )+ added = Path(plan.argv[plan.argv.index("--add-dir") + 1])+ assert added.is_absolute()+ assert added.name == "workspace"def test_agy_model_args_respects_the_strict_pairing():diff --git a/tests/unit/agent_chat/test_jarvis_harness.py b/tests/unit/agent_chat/test_jarvis_harness.pyindex d514adc448..cfb4c68971 100644--- a/tests/unit/agent_chat/test_jarvis_harness.py+++ b/tests/unit/agent_chat/test_jarvis_harness.py@@ -82,13 +82,18 @@ def test_a_tool_result_becomes_text_the_model_can_read():def test_the_config_is_withheld_until_the_app_can_actually_serve_it(monkeypatch):"""Half a config is worse than none: the CLI would fail to connect mid-turn."""monkeypatch.setattr(jarvis_harness, "control_key", lambda: "k")+ monkeypatch.setattr(jarvis_harness, "endpoint", lambda: None)assert jarvis_harness.mcp_config_json() is None # no base URL yetassert jarvis_harness.codex_config_args() == []+ assert jarvis_harness.agy_mcp_server_entry() is None- runtime_refs.set_api_base_url("http://127.0.0.1:47821")+ monkeypatch.setattr(+ jarvis_harness, "endpoint", lambda: "http://127.0.0.1:47821/api/control/mcp/"+ )monkeypatch.setattr(jarvis_harness, "control_key", lambda: None)assert jarvis_harness.mcp_config_json() is None # no keyassert jarvis_harness.codex_config_args() == []+ assert jarvis_harness.agy_mcp_server_entry() is Nonedef test_the_key_travels_in_the_environment_never_in_argv(monkeypatch):@@ -113,6 +118,16 @@ def test_both_cli_shapes_point_at_the_same_endpoint(monkeypatch):url = "http://127.0.0.1:47921/api/control/mcp"assert url in (jarvis_harness.mcp_config_json() or "")assert any(url in arg for arg in jarvis_harness.codex_config_args())+ agy = jarvis_harness.agy_mcp_server_entry("sess-9")+ assert agy is not None+ assert url in agy["serverUrl"]+ assert agy["headers"][jarvis_harness.HEADER_NAME] == "sess-9"+++def test_agy_plugin_is_skipped_when_the_app_is_not_ready(tmp_path, monkeypatch):+ monkeypatch.setattr(jarvis_harness, "control_key", lambda: None)+ assert jarvis_harness.install_agy_jarvis_plugin(tmp_path, "sess") is None+ assert not (tmp_path / ".agents").exists()def test_the_preamble_names_the_prefix_the_tools_actually_get():diff --git a/tests/unit/agent_chat/test_jarvis_identity.py b/tests/unit/agent_chat/test_jarvis_identity.pyindex 68c2102684..a45289bf39 100644--- a/tests/unit/agent_chat/test_jarvis_identity.py+++ b/tests/unit/agent_chat/test_jarvis_identity.py@@ -7,6 +7,7 @@ tool server's approval surface for a request that names a chat.from __future__ import annotations+import jsonfrom pathlib import Pathfrom typing import Any@@ -205,6 +206,28 @@ def test_agy_takes_the_identity_on_stdin(monkeypatch, tmp_path: Path):assert plan.stdin_text and plan.stdin_text.startswith("<jarvis_identity>\nFULL IDENTITY")+def test_agy_with_identity_drops_a_workspace_plugin(monkeypatch, tmp_path: Path):+ monkeypatch.setattr(runner_cli, "agy_argv_prefix", lambda: ["agy"])+ monkeypatch.setattr(runner_cli, "_agy_catalog_cached", lambda: None)+ monkeypatch.setattr(runner_cli.jarvis_harness, "control_key", lambda: "k")+ runtime_refs.set_api_base_url("http://127.0.0.1:47821")+ runner_cli.plan_agy(+ prompt="hi",+ cwd=tmp_path,+ model="",+ effort="",+ permission_mode="accept-edits",+ resume=None,+ identity=_identity(tmp_path),+ )+ plugin = tmp_path / ".agents" / "plugins" / "jarvis-hands" / "mcp_config.json"+ payload = json.loads(plugin.read_text(encoding="utf-8"))+ server = payload["mcpServers"]["jarvis"]+ assert server["serverUrl"].endswith("/api/control/mcp/")+ assert server["headers"]["Authorization"] == "Bearer k"+ assert server["headers"][jarvis_harness.HEADER_NAME] == "sess-1"++# ------------------------------------------------------- the session headerdiff --git a/tests/unit/society/test_chat_binding.py b/tests/unit/society/test_chat_binding.pyindex 5d7bcf7a43..7673aeb1ea 100644--- a/tests/unit/society/test_chat_binding.py+++ b/tests/unit/society/test_chat_binding.py@@ -56,6 +56,7 @@ async def test_ensure_session_is_deterministic_and_reseats(world):assert first.permission_mode == "accept-edits"assert first.title == "Scout"assert Path(first.cwd).name == "workspace" and os.path.isdir(first.cwd) # noqa: ASYNC240+ assert Path(first.cwd).is_absolute()again = ensure_session(svc, cfg, scout)assert again.session_id == first.session_id