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.

feat(agentic-ide): "spawn five agents and split it" reaches the workspace

Ruben Lütkeb1f5f1248534
diff --git a/jarvis/agentic_ide/intent.py b/jarvis/agentic_ide/intent.py
index 70ba38da61..259f36427d 100644
--- a/jarvis/agentic_ide/intent.py
+++ b/jarvis/agentic_ide/intent.py
@@ -647,6 +647,56 @@ def _spoken_groups(text: str) -> tuple[SpawnGroup, ...]:
return tuple(out)
+#: The plural coding-agent noun, when the user does not say "terminal".
+_AGENT_NOUN_RE = re.compile(
+ r"\b(?:agents|agenten|agentes)\b", # i18n-allow: input vocab
+ re.IGNORECASE,
+)
+
+#: Wording that unambiguously asks for a BACKGROUND worker. Checked first and
+#: absolute: the whole reason the terminal noun is mandatory is that stealing a
+#: genuine mission request is invisible to the user.
+_BACKGROUND_RE = re.compile(
+ r"\b(?:hintergrund|background|worker\w*|mission\w*|" # i18n-allow: input vocab
+ r"sub-?agent\w*|subagent\w*|delegier\w*|delegate\w*|" # i18n-allow: input vocab
+ r"segundo\s+plano|trabajador\w*)\b", # i18n-allow: input vocab
+ re.IGNORECASE,
+)
+
+
+def _is_agent_fleet(text: str, names: list[str] | None) -> bool:
+ """True for a fleet request that says "agents" instead of "terminals".
+
+ The mandatory pane noun is what makes claiming a turn safe, and it stays
+ mandatory for everything but this one narrow shape. The maintainer's own
+ phrasing for a fleet does not contain it (2026-07-26): "can you spawn five
+ deep-dive agents that analyse X, and divide it across different areas" —
+ which opened nothing at all, because the sentence names no terminal and the
+ background path does not divide work across panes either.
+
+ All four conditions must hold, and each one removes a way of being wrong:
+
+ 1. a workspace is OPEN — with nowhere to put them, a fleet request really is
+ the background path's;
+ 2. the wording is not explicitly about a background worker;
+ 3. SEVERAL agents are asked for — one agent on one job is exactly what a
+ mission worker is;
+ 4. the sentence carries fleet semantics: divide the work between them, or
+ name the coding CLI to run. A background mission is never described as
+ "split across five agents by area".
+ """
+ running = _running_names() if names is None else list(names)
+ if not running:
+ return False
+ if _BACKGROUND_RE.search(text):
+ return False
+ if _AGENT_NOUN_RE.search(text) is None:
+ return False
+ if _spoken_count(text) < 2:
+ return False
+ return wants_split(text) or _AGENT_RE.search(text) is not None
+
+
def detect_spawn(
user_text: str, *, names: list[str] | None = None
) -> SpawnTerminalsRequest | None:
@@ -661,7 +711,7 @@ def detect_spawn(
text = (user_text or "").strip()
if len(text) < 6:
return None
- if _PANE_NOUN_RE.search(text) is None:
+ if _PANE_NOUN_RE.search(text) is None and not _is_agent_fleet(text, names):
return None
if _QUESTION_OPENER_RE.search(text) is not None:
return None
diff --git a/tests/unit/agentic_ide/test_fanout_route.py b/tests/unit/agentic_ide/test_fanout_route.py
index 85bca8bf22..940f1541e1 100644
--- a/tests/unit/agentic_ide/test_fanout_route.py
+++ b/tests/unit/agentic_ide/test_fanout_route.py
@@ -168,10 +168,10 @@ async def test_without_split_every_terminal_gets_the_same_brief(
assert prompts[0] == prompts[1]
-async def test_the_route_can_open_the_fleet_it_needs(
+async def test_the_route_opens_the_fleet_it_needs(
client: TestClient, registry: Registry, tmp_path: Path
) -> None:
- """ "Five Codex agents on this" with two panes open must open three more."""
+ """ "Four Codex agents on this" with two panes open must open four more."""
await _live_workspace(registry, tmp_path, 2)
body = client.post(
@@ -182,11 +182,39 @@ async def test_the_route_can_open_the_fleet_it_needs(
assert registry.session is not None
assert len(registry.session.terminals) == 6
assert [t.agent for t in registry.session.terminals[2:]] == ["codex"] * 4
- # Only the NEW panes are briefed: the two that were already working on
- # something else must not be interrupted by a fleet request.
+ # Only the NEW panes are addressed: the two already working on something
+ # else must not be interrupted by a fleet request.
+ assert len(body["opened"]) == 4
assert len(body["delivered"]) + len(body["undelivered"]) == 4
+async def test_a_freshly_opened_pane_is_reported_as_not_yet_running(
+ client: TestClient, registry: Registry, tmp_path: Path
+) -> None:
+ """KNOWN LIMIT, pinned so it cannot be mistaken for success.
+
+ A pane's agent process starts when the workspace VIEW mounts it, not when
+ the registry entry is created — so panes opened by this call are still
+ ``pending`` microseconds later and nothing can be typed into them yet.
+
+ The route reports that truthfully rather than claiming a briefed fleet, and
+ that honesty is what this test pins. What it does NOT yet do is wait for
+ the panes to come up and brief them once they have; until it does,
+ spawn+brief in one call opens the fleet and briefs nobody. Delivering after
+ the panes go live is the remaining piece of this feature.
+ """
+ await _live_workspace(registry, tmp_path, 1)
+
+ body = client.post(
+ "/api/agentic-ide/fanout",
+ json={"instruction": "analyse it", "spawn": [{"count": 2, "agent": "codex"}]},
+ ).json()
+
+ assert body["ok"] is False
+ assert len(body["undelivered"]) == 2
+ assert {d["reason_code"] for d in body["undelivered"]} == {"not_running"}
+
+
async def test_a_mixed_fleet_opens_both_kinds(
client: TestClient, registry: Registry, tmp_path: Path
) -> None:
diff --git a/tests/unit/agentic_ide/test_spawn_intent.py b/tests/unit/agentic_ide/test_spawn_intent.py
index a6b602c38f..aa26c20b62 100644
--- a/tests/unit/agentic_ide/test_spawn_intent.py
+++ b/tests/unit/agentic_ide/test_spawn_intent.py
@@ -203,6 +203,74 @@ def test_the_total_is_capped_at_the_workspace_maximum() -> None:
assert sum(g.count for g in found.groups) == found.count
+# --------------------------------------------------------------------------- #
+# "Spawn five deep-dive AGENTS" — no terminal noun, but still the workspace #
+# --------------------------------------------------------------------------- #
+# The mandatory terminal noun makes claiming a turn safe, and it is why asking
+# for "an agent" still reaches the background worker. But the maintainer's own
+# phrasing for a fleet does not contain it (2026-07-26): "can you spawn five
+# deep-dive agents that analyse X, and divide it across different areas"
+# opened nothing at all.
+#
+# The narrow opening: a workspace is OPEN, several AGENTS are asked for, and the
+# sentence asks for the work to be DIVIDED between them or names a coding CLI.
+# A background mission is one worker on one job — nobody says "split it across
+# five background agents by area". Explicit background wording still wins, so
+# every existing guard below keeps holding.
+
+FLEET_REQUEST = (
+ "Kannst du bitte fünf Deep Dive Agents spawnen, welche unsere Codebase " # i18n-allow: fixture
+ "analysieren, und teile das auf verschiedene Aufgabenbereiche auf" # i18n-allow: fixture
+)
+
+
+def test_an_agent_fleet_with_a_split_belongs_to_the_open_workspace() -> None:
+ found = intent.detect_spawn(FLEET_REQUEST, names=NAMES)
+ assert found is not None
+ assert found.count == 5
+ assert intent.owns_turn(FLEET_REQUEST, names=NAMES) is True
+
+
+def test_an_agent_fleet_naming_a_coding_cli_also_counts() -> None:
+ found = intent.detect_spawn("Spawn three Codex agents on this", names=NAMES)
+ assert found is not None
+ assert found.count == 3
+ assert found.agent == "codex"
+
+
+def test_without_an_open_workspace_an_agent_fleet_stays_a_mission() -> None:
+ """No panes to put them in: this is the background path's request."""
+ assert intent.detect_spawn(FLEET_REQUEST, names=[]) is None
+ assert intent.owns_turn(FLEET_REQUEST, names=[]) is False
+
+
+ "utterance",
+ [
+ "Spawne fünf Agenten im Hintergrund, die das aufteilen", # i18n-allow: fixture
+ "Start five background agents and split the work between them",
+ "Delegiere das an fünf Worker und teile es auf Bereiche auf", # i18n-allow: fixture
+ "Spawn five subagents and divide the areas between them",
+ ],
+)
+def test_explicit_background_wording_always_wins(utterance: str) -> None:
+ """Saying "background" is unambiguous and must never be stolen."""
+ assert intent.detect_spawn(utterance, names=NAMES) is None
+ assert intent.owns_turn(utterance, names=NAMES) is False
+
+
+def test_a_single_agent_without_a_terminal_noun_is_still_a_mission() -> None:
+ """One agent on one job is what the background worker is for."""
+ one_agent = "Spawne einen Agenten der das analysiert" # i18n-allow: fixture
+ assert intent.detect_spawn("Spawn an agent to review this", names=NAMES) is None
+ assert intent.detect_spawn(one_agent, names=NAMES) is None
+
+
+def test_an_agent_fleet_without_a_split_or_a_cli_stays_a_mission() -> None:
+ """Plural alone is not enough — the fleet semantics have to be spelled out."""
+ assert intent.detect_spawn("Spawn five agents on this", names=NAMES) is None
+
+
def test_an_addressed_terminal_still_wins_over_the_spawn_grammar() -> None:
"""Telling a named pane to open a terminal is a prompt FOR that pane.