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(threads): let coding threads spawn the sub-agents they are asked for (#1129)

Ruben Lütkedd716bbc9b2d
diff --git a/dodaios/agent_chat/dodaios_harness.py b/dodaios/agent_chat/dodaios_harness.py
index e3acd561b2..5bb2c3128d 100644
--- a/dodaios/agent_chat/dodaios_harness.py
+++ b/dodaios/agent_chat/dodaios_harness.py
@@ -78,7 +78,7 @@ SOCIETY_PREAMBLE: Final[str] = (
"only. You are this turn's worker: spawn no sub-agents."
)
-SYSTEM_PREAMBLE: Final[str] = (
+_SHARED_PREAMBLE: Final[str] = (
"You are the person's assistant (your name is stated at the top of this prompt) in "
"the chat of the Dodaios desktop app; they also talk to you by voice.\n\n"
+ CONVERSATIONAL_TURN_REMINDER
@@ -93,10 +93,21 @@ SYSTEM_PREAMBLE: Final[str] = (
"When the person selects the browser (@browser, @browser-use, [tools: core:browser]), "
f"use society_browser from the `{_SERVER_NAME}` MCP server, the live browser in the "
"Options rail; if it is unavailable, say so.\n\n"
- "Approval cards are pending work, not failures. You are this turn's worker: spawn no "
- "sub-agents."
+ "Approval cards are pending work, not failures."
)
+#: The closing block of the assistant's own chat (the Jarvis surface). There
+#: the turn itself is the worker: the background workers of old are retired.
+SYSTEM_PREAMBLE: Final[str] = _SHARED_PREAMBLE + " You are this turn's worker: spawn no sub-agents."
+
+#: The closing block of a coding thread in the Agentic IDE (a Claude Code seat
+#: with no assistant identity). The same transport facts, but the CLI keeps its
+#: own sub-agents: a coding agent splits its work into them, the person asks
+#: for them by name, and the thread lists each one under its row. The rule
+#: above, applied here, made Claude Code refuse sub-agents it was asked for
+#: (2026-11-02).
+CODING_PREAMBLE: Final[str] = _SHARED_PREAMBLE
+
#: The child environment variable the control key travels in — the SAME name
#: the app itself reads it from (``dodaios.core.control_key.ENV_VAR``), so one
@@ -634,6 +645,7 @@ __all__ = [
"COMPACT_MAX_CHARS",
"HEADER_NAME",
"KEY_ENV_VAR",
+ "CODING_PREAMBLE",
"SOCIETY_PREAMBLE",
"SYSTEM_PREAMBLE",
"TRANSCRIPT_MAX_CHARS",
diff --git a/dodaios/agent_chat/runner_cli.py b/dodaios/agent_chat/runner_cli.py
index b572556cf0..2f26c8d5e3 100644
--- a/dodaios/agent_chat/runner_cli.py
+++ b/dodaios/agent_chat/runner_cli.py
@@ -881,8 +881,11 @@ def _plan_claude_code(
argv += ["--mcp-config", mcp_config]
if identity is not None and identity.path is not None:
argv += ["--append-system-prompt-file", str(identity.path)]
- else:
+ elif identity is not None:
argv += ["--append-system-prompt", dodaios_harness.SYSTEM_PREAMBLE]
+ else:
+ # No assistant identity: a coding thread, which keeps its sub-agents.
+ argv += ["--append-system-prompt", dodaios_harness.CODING_PREAMBLE]
if resume:
argv += ["--resume", resume]
sid = resume
diff --git a/tests/unit/agent_chat/test_dodaios_identity.py b/tests/unit/agent_chat/test_dodaios_identity.py
index 760e37f2c6..b0a2aadb17 100644
--- a/tests/unit/agent_chat/test_dodaios_identity.py
+++ b/tests/unit/agent_chat/test_dodaios_identity.py
@@ -157,6 +157,44 @@ def test_claude_without_identity_spawns_exactly_as_before(monkeypatch, tmp_path:
assert dodaios_harness.HEADER_NAME not in plan.argv[plan.argv.index("--mcp-config") + 1]
+def test_a_coding_thread_may_spawn_sub_agents(monkeypatch, tmp_path: Path):
+ """A coding thread (no assistant identity) keeps the CLI's own sub-agents.
+
+ The assistant chat's "spawn no sub-agents" rule, appended here too, made
+ Claude Code refuse the sub-agents the person had asked for (2026-11-02).
+ """
+ monkeypatch.setattr(runner_cli, "claude_argv_prefix", lambda: ["claude"])
+ monkeypatch.setattr(runner_cli.dodaios_harness, "control_key", lambda: "k")
+ runtime_refs.set_api_base_url("http://127.0.0.1:47821")
+ plan = runner_cli.plan_claude(
+ prompt="hi", cwd=tmp_path, model="", effort="", permission_mode="ask", resume=None
+ )
+ appended = plan.argv[plan.argv.index("--append-system-prompt") + 1]
+ assert appended == dodaios_harness.CODING_PREAMBLE
+ assert "sub-agent" not in appended
+ # The assistant's own chat keeps its rule: there the turn is the worker.
+ assert dodaios_harness.SYSTEM_PREAMBLE.endswith("spawn no sub-agents.")
+ assert dodaios_harness.SYSTEM_PREAMBLE.startswith(dodaios_harness.CODING_PREAMBLE)
+
+
+def test_an_identity_without_a_file_keeps_the_assistant_rule(monkeypatch, tmp_path: Path):
+ monkeypatch.setattr(runner_cli, "claude_argv_prefix", lambda: ["claude"])
+ monkeypatch.setattr(runner_cli.dodaios_harness, "control_key", lambda: "k")
+ runtime_refs.set_api_base_url("http://127.0.0.1:47821")
+ ident = dodaios_harness.Identity(session_id="sess-1", text="x", compact="x", path=None)
+ plan = runner_cli.plan_claude(
+ prompt="hi",
+ cwd=tmp_path,
+ model="",
+ effort="",
+ permission_mode="ask",
+ resume=None,
+ identity=ident,
+ )
+ appended = plan.argv[plan.argv.index("--append-system-prompt") + 1]
+ assert appended == dodaios_harness.SYSTEM_PREAMBLE
+
+
def test_codex_gets_the_identity_on_stdin_and_the_session_header(monkeypatch, tmp_path: Path):
monkeypatch.setattr(runner_cli, "codex_argv_prefix", lambda: ["codex"])
monkeypatch.setattr(runner_cli, "read_codex_models", lambda: None)