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(agentic-ide): let the TURN decide the spawn, not the coding mode

Ruben Lütkeb884d643aa3d
diff --git a/jarvis/agentic_ide/intent.py b/jarvis/agentic_ide/intent.py
index 119c17d9dc..eac23f0c9b 100644
--- a/jarvis/agentic_ide/intent.py
+++ b/jarvis/agentic_ide/intent.py
@@ -285,13 +285,31 @@ def _canonical_text(text: str, candidates: list[str]) -> str:
branch where ordinary speech collides with the pool ("allen" scores 0.750
against "Alex"), and rewriting it here would hand every template a name the
user never said.
+
+ ONE position is exempt, because there the sentence itself vouches for the
+ word: whatever directly follows a briefing verb ("prompt …", "brief …",
+ "beauftrage …") is being named as the addressee. Nothing else can stand
+ there. So a garbled call-sign is admitted on the FUZZY band at that spot and
+ at no other — which is what rescues the maintainer's own example, "hey,
+ prompte adex" (2026-07-28): "adex" reaches "Alex" only fuzzily, so every
+ template missed it, the last-resort branch rejected it for not being
+ certain, and the turn addressed nothing at all.
+
+ The collision risk that makes fuzzy matching dangerous elsewhere does not
+ reach here: "unten"/"keine" score into the pool as ordinary sentence words,
+ and an ordinary sentence word does not sit immediately behind "prompte".
"""
if not candidates:
return text
+ briefed: set[int] = {
+ match.start("word")
+ for match in _BRIEFED_NAME_RE.finditer(text)
+ }
+
def _replace(match: re.Match[str]) -> str:
word = match.group(0)
- hit = resolve(word, candidates, fuzzy=False)
+ hit = resolve(word, candidates, fuzzy=match.start() in briefed)
return hit if hit is not None else word
return _WORD_RE.sub(_replace, text)
@@ -419,6 +437,23 @@ _BRIEFING_VERB_RE = re.compile(
re.IGNORECASE,
)
+#: The ADDRESSEE SLOT: the word a briefing verb hands its work to. Whatever
+#: stands here is being named as the pane — that is the only thing the position
+#: admits — so ``_canonical_text`` may repair a garbled call-sign here on the
+#: fuzzy band without opening the door to the collisions that band causes
+#: elsewhere. The optional filler is exactly what people put between the verb
+#: and the name and nothing more: an article and/or a pane noun
+#: ("prompt THE TERMINAL Alex"), each at most once.
+_BRIEFED_NAME_RE = re.compile(
+ r"\b(?:prompt\w*|anprompt\w*|instruct\w*|instruy\w*|anweis\w*|" # i18n-allow: input vocab
+ r"beauftrag\w*|briefe\w*|assign\w*|encarga\w*)\b\s+" # i18n-allow: input vocab
+ r"(?:(?:this|that|the|dieses?|diesem|den|dem|" # i18n-allow: input vocab
+ r"das|der|el|la|ese|este)\s+)?" # i18n-allow: input vocab
+ r"(?:(?:terminals?|terminales|panes?|tabs?)\s+)?"
+ r"(?P<word>[^\W\d_]+)",
+ re.IGNORECASE,
+)
+
def _mentions(
text: str, candidates: list[str], *, fuzzy: bool = True
@@ -1726,16 +1761,11 @@ def spawn_vehicle_outranks_workspace(
gate refuses the mission, the fast path refuses to type, and the user is
left with silence — the failure this whole area exists to end.
"""
- from jarvis.brain.spawn_gate import coding_mode_blocks_spawn, names_spawn_vehicle
+ from jarvis.brain.spawn_gate import names_spawn_vehicle
text = (user_text or "").strip()
if not names_spawn_vehicle(text):
return False
- if coding_mode_blocks_spawn():
- # No wording reaches a background worker in this mode, so letting the
- # vocabulary win here would only take the turn away from the pane that
- # can still serve it.
- return False
candidates = _running_names() if names is None else list(names)
return not _spawn_words_describe_pane_work(text, candidates)
@@ -1753,16 +1783,13 @@ def owns_turn(user_text: str, *, names: list[str] | None = None) -> bool:
spawn vehicle ("spawne … Terminals"). The mandatory pane noun is what
makes claiming it safe, and it holds with no workspace open too — the
feature then opens one, so a background mission would be just as wrong.
- 2. Coding mode owns every turn it can serve. While the user is IN the
- Agentic IDE, Jarvis does not dispatch its own workers at all
- (``spawn_gate.coding_mode_blocks_spawn``), so an addressed pane must not
- lose the turn to vocabulary that can no longer reach a spawn anyway —
- that would strand the work in the gap between the two gates.
- 3. Otherwise an utterance that explicitly names the spawn vehicle is NOT
+ 2. Otherwise an utterance that explicitly names the spawn vehicle is NOT
owned here — asking for a background agent while a workspace happens to
be open is a real request, and stealing it would be the mirror image of
- the bug this module fixes. The one exception is an utterance whose spawn
- words describe a PANE's work; see ``_spawn_words_describe_pane_work``.
+ the bug this module fixes. That holds INSIDE coding mode too: the mode
+ is not a reason to refuse a delegation the user asked for. The one
+ exception is an utterance whose spawn words describe a PANE's work; see
+ ``_spawn_words_describe_pane_work``.
"""
text = (user_text or "").strip()
if not text:
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index c4d586f8a6..ef4018510d 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -6543,23 +6543,6 @@ class BrainManager:
# _heavy_worker_provider_viable.
if not self._heavy_worker_provider_viable():
return False
- # Agentic-IDE coding mode forbids an internal worker outright — ahead of
- # the explicit-trigger hoist below, which is negation- AND context-blind
- # and would otherwise read the CLI agent's own fan-out vocabulary
- # ("they should spawn sub-agents") as an order to dispatch a Jarvis
- # mission. Maintainer mandate 2026-07-27; the LLM-chosen path is closed
- # by the same predicate in ``spawn_gate.llm_spawn_allowed``.
- try:
- from jarvis.brain.spawn_gate import coding_mode_blocks_spawn
-
- if coding_mode_blocks_spawn():
- log.info(
- "force-spawn skipped: Agentic-IDE coding mode is on — "
- "the terminals do this work, no background agent"
- )
- return False
- except Exception as exc: # noqa: BLE001 — optional surface, never fatal
- log.debug("coding-mode spawn check failed, ignoring: %s", exc)
# Explicit spawn DECLINE wins over EVERYTHING below, including the
# negation-blind explicit-trigger hoist: when the user literally says
# "don't spawn a subagent" / "talk to me directly", the trigger word
diff --git a/jarvis/brain/spawn_gate.py b/jarvis/brain/spawn_gate.py
index b7f02ee08c..02053ca627 100644
--- a/jarvis/brain/spawn_gate.py
+++ b/jarvis/brain/spawn_gate.py
@@ -201,49 +201,36 @@ def spawn_vehicle_spans(user_text: str) -> list[tuple[int, int]]:
]
-def coding_mode_blocks_spawn() -> bool:
- """True while the Agentic IDE is the active mode, which forbids a spawn.
+def addressed_pane_blocks_spawn(user_text: str) -> bool:
+ """True when this turn is aimed at a workspace terminal, which owns it.
- Maintainer mandate 2026-07-27: inside the coding workspace, "sub-agent" is
- the CLI agent's own fan-out vocabulary — every agentic coding tool has the
- feature and users ask for it constantly. Reading those words as an order to
- dispatch a JARVIS mission worker is a collision the user cannot phrase their
- way out of, so the mode decides instead of the wording: while coding mode is
- on, work goes to the panes on screen and no internal worker is dispatched.
+ The scope correction to the first attempt at this (maintainer, 2026-07-28).
+ That version blocked EVERY spawn while coding mode was on, which bought the
+ fix by deleting a feature: brainstorming inside the IDE and asking for a
+ background agent is a legitimate, common thing to do, and the mode is not a
+ reason to refuse it.
- The mode is deliberately the toggle a user can see (the app-wide coding-mode
- badge), not the mere presence of a workspace: an open workspace with the
- toggle off is "terminals on a screen", and delegation there is a legitimate
- request. Turning the toggle off restores the background agent in full.
+ What actually decides is the TURN, not the mode. Addressing a pane is an
+ instruction to that pane — "sub-agents" inside it is the CLI agent's own
+ fan-out vocabulary, describing work that happens once the brief arrives in
+ the terminal. A turn that addresses no pane is unaffected, in or out of
+ coding mode, so the background agent stays fully available.
+
+ Delegated to ``intent.owns_turn`` rather than re-deciding here: that is the
+ ONE precedence rule the router's force-spawn guard and this gate already
+ share, and a second opinion would drift.
Never raises — the workspace is an optional surface and must never be able
to break spawn routing; a fault answers "does not block".
"""
try:
- from jarvis.agentic_ide.session import coding_mode_active # noqa: PLC0415
+ from jarvis.agentic_ide.intent import owns_turn # noqa: PLC0415
- return coding_mode_active()
+ return owns_turn(user_text)
except Exception: # noqa: BLE001 — optional surface, never fatal to routing
return False
-def _agentic_ide_claims_turn(text: str) -> bool:
- """True when an open Agentic-IDE terminal is being addressed instead.
-
- An agent already runs in a pane the user can see and named; typing the work
- into it is what they asked for, and dispatching an invisible background
- worker instead is the live 2026-07-25 defect this guard closes. Import is
- local and failure-tolerant: the workspace is an optional surface and must
- never be able to break spawn routing.
- """
- try:
- from jarvis.agentic_ide.intent import owns_turn
-
- return owns_turn(text)
- except Exception: # noqa: BLE001 - optional surface, never fatal to routing
- return False
-
-
def llm_spawn_allowed(user_text: str) -> bool:
"""Gate an LLM-chosen spawn tool call against the user's ACTUAL turn.
@@ -256,22 +243,17 @@ def llm_spawn_allowed(user_text: str) -> bool:
text = (user_text or "").strip()
if not text:
return False
- # Coding mode outranks EVERYTHING below, including explicit delegation
- # vocabulary. See ``coding_mode_blocks_spawn`` — inside the Agentic IDE the
- # word "sub-agent" belongs to the CLI agent in the pane, so no wording may
- # unlock an internal worker while that mode is on.
- if coding_mode_blocks_spawn():
- log.info("spawn gate: Agentic-IDE coding mode is on — no background agent")
- return False
if _is_decline_or_feature_talk(text):
log.info("spawn gate: decline / feature talk — spawn blocked")
return False
# An addressed Agentic-IDE terminal outranks a spawn. Checked before the
# delegation marker so a depth word inside a terminal instruction ("let Kai
# do a deep dive") cannot dispatch a background mission — but AFTER the
- # decline guard, and ``owns_turn`` itself stands down when the user named the
- # vehicle, so an explicit "spawn an agent" still spawns.
- if _agentic_ide_claims_turn(text):
+ # decline guard. ``owns_turn`` still stands down for a turn that ASKS for a
+ # background agent ("spawn an agent that helps Kai"), which is what keeps
+ # delegation available inside the workspace; what it no longer stands down
+ # for is a pane being told to fan out ("Alex should spawn sub-agents").
+ if addressed_pane_blocks_spawn(text):
log.info(
"spawn gate: an open Agentic-IDE terminal is addressed — "
"the workspace handles this turn, no background agent"
@@ -312,41 +294,41 @@ SPAWN_BLOCKED_MODEL_FEEDBACK: str = (
)
-# The coding-mode variant. The generic text above would mislead here: it invites
-# the model to OFFER a background agent, and in the Agentic IDE that offer is
-# exactly the wrong next move — the work belongs in a pane the user is looking
-# at. "Sub-agents" in this mode means the CLI agent's own fan-out, which happens
-# inside the terminal once the brief arrives there.
-SPAWN_BLOCKED_CODING_MODE_FEEDBACK: str = (
- "spawn_worker was not executed: the Agentic-IDE coding mode is ON, and in "
- "that mode Jarvis never starts its own background workers. The coding "
- "agents in the named terminals do this work. Send the user's request to the "
- "right terminal with the agentic-ide-prompt function, in the user's own "
- "words — including any instruction to spawn sub-agents, which is an "
- "instruction for the agent IN that terminal to carry out itself. If no "
- "terminal is addressed, answer inline or ask which one should take it. Do "
- "not offer a background agent."
+# The addressed-pane variant. The generic text above would mislead here: it
+# invites the model to OFFER a background agent, and when the user has just told
+# a terminal to do something that offer is exactly the wrong next move — the
+# work belongs in the pane they named. "Sub-agents" in such a turn is the CLI
+# agent's own fan-out, which happens inside the terminal once the brief lands.
+SPAWN_BLOCKED_ADDRESSED_PANE_FEEDBACK: str = (
+ "spawn_worker was not executed: this turn is addressed to a coding "
+ "terminal in the open workspace, and that terminal does this work. Send "
+ "the user's request to it with the agentic-ide-prompt function, in the "
+ "user's own words — including any instruction to spawn sub-agents, which "
+ "is an instruction for the agent IN that terminal to carry out itself. You "
+ "may still use other functions to gather context for the brief. Do not "
+ "offer a background agent for this turn."
)
-def spawn_blocked_feedback() -> str:
+def spawn_blocked_feedback(user_text: str = "") -> str:
"""The tool-error text matching WHY the spawn was blocked.
One function so the classic and realtime paths cannot teach the model two
- different next moves for the same block.
+ different next moves for the same block. ``user_text`` is the verbatim turn
+ the gate just judged; without it the generic text is the honest answer.
"""
- if coding_mode_blocks_spawn():
- return SPAWN_BLOCKED_CODING_MODE_FEEDBACK
+ if user_text and addressed_pane_blocks_spawn(user_text):
+ return SPAWN_BLOCKED_ADDRESSED_PANE_FEEDBACK
return SPAWN_BLOCKED_MODEL_FEEDBACK
__all__ = [
"OFFER_WINDOW",
- "SPAWN_BLOCKED_CODING_MODE_FEEDBACK",
+ "SPAWN_BLOCKED_ADDRESSED_PANE_FEEDBACK",
"SPAWN_BLOCKED_MODEL_FEEDBACK",
"SPAWN_VEHICLE_TOOL_NAMES",
"DelegationOfferWindow",
- "coding_mode_blocks_spawn",
+ "addressed_pane_blocks_spawn",
"llm_spawn_allowed",
"names_spawn_vehicle",
"spawn_blocked_feedback",
diff --git a/jarvis/brain/tool_use_loop.py b/jarvis/brain/tool_use_loop.py
index a5512b81db..be504e4cab 100644
--- a/jarvis/brain/tool_use_loop.py
+++ b/jarvis/brain/tool_use_loop.py
@@ -927,7 +927,7 @@ class ToolUseLoop:
tool_result_payload = {
"success": False,
"output": None,
- "error": spawn_blocked_feedback(),
+ "error": spawn_blocked_feedback(user_utterance),
}
elif (
tool_name in CU_VEHICLE_TOOL_NAMES
diff --git a/jarvis/realtime/tools.py b/jarvis/realtime/tools.py
index 9d41d45249..a4eaab8038 100644
--- a/jarvis/realtime/tools.py
+++ b/jarvis/realtime/tools.py
@@ -410,7 +410,7 @@ class RealtimeToolBridge:
# spoken turn asks for one (or confirms an offer one turn later).
# Deterministic — prompt-side discouragement failed repeatedly.
# See jarvis/brain/spawn_gate.py.
- message = spawn_blocked_feedback()
+ message = spawn_blocked_feedback(user_text)
elif name in CU_VEHICLE_TOOL_NAMES and not llm_computer_use_allowed(
user_text
):
diff --git a/tests/unit/agentic_ide/test_coding_mode_spawn_gate.py b/tests/unit/agentic_ide/test_coding_mode_spawn_gate.py
index 069e62e04e..10605bb849 100644
--- a/tests/unit/agentic_ide/test_coding_mode_spawn_gate.py
+++ b/tests/unit/agentic_ide/test_coding_mode_spawn_gate.py
@@ -1,22 +1,20 @@
-"""Coding mode forbids an internal worker; a pane's own fan-out stays its work.
-
-Two rules, one collision. "Sub-agent" is the vocabulary every agentic coding CLI
-uses for its own parallel helpers, and it is also the word that makes Jarvis
-dispatch a background mission worker. While the user is inside the Agentic IDE
-those two readings point in opposite directions, and the user cannot phrase
-their way out of it — so the MODE decides, not the wording.
-
-Live failure these pin (voice session 2026-07-27 20:00, maintainer mandate the
-same day): "let Alex and Ellis do a deep dive … and they should spawn swarms of
-sub-agents". Both call-signs named running panes, the addressing was detected
-correctly — and the turn went to an invisible background worker anyway because
-the sentence contained "sub-agents" and "spawn". Both terminals sat idle while
-the assistant reported that the agents had been briefed.
-
-The other direction is guarded just as hard: with coding mode off, asking for a
-background agent must still get one. That feature is the reason the vehicle
-stand-down exists at all, and breaking it while fixing the above would only swap
-which half of the user's intent gets lost.
+"""A pane's own sub-agent fan-out is the pane's work; delegation stays available.
+
+"Sub-agent" is what every agentic coding CLI calls its own parallel helpers, and
+it is also the word that makes Jarvis dispatch a background mission worker.
+Inside a coding workspace those two readings point in opposite directions.
+
+Live failure these pin (voice session 2026-07-27 20:00): "let Alex and Ellis do
+a deep dive … and they should spawn swarms of sub-agents". Both call-signs named
+running panes, the addressing was detected correctly — and the turn went to an
+invisible background worker anyway because the sentence contained "sub-agents"
+and "spawn". Both terminals sat idle while the assistant reported them briefed.
+
+The TURN decides, not the mode (maintainer, 2026-07-28). An earlier version of
+this fix blocked every spawn while coding mode was on, which bought the fix by
+deleting a feature — brainstorming inside the IDE and asking for a background
+agent is legitimate and common. So the guards below come in pairs: each one that
+pins "this reaches the pane" has a sibling pinning "and this still delegates".
"""
from __future__ import annotations
@@ -29,9 +27,9 @@ from jarvis.agentic_ide.intent import owns_turn, spawn_vehicle_outranks_workspac
from jarvis.agentic_ide.session import Registry, reset_registry
from jarvis.brain.spawn_gate import (
OFFER_WINDOW,
- SPAWN_BLOCKED_CODING_MODE_FEEDBACK,
+ SPAWN_BLOCKED_ADDRESSED_PANE_FEEDBACK,
SPAWN_BLOCKED_MODEL_FEEDBACK,
- coding_mode_blocks_spawn,
+ addressed_pane_blocks_spawn,
llm_spawn_allowed,
spawn_blocked_feedback,
)
@@ -50,9 +48,7 @@ LIVE_TURN = (
PANES = ["Alex", "Ellis", "Casey"]
-# The strongest delegation wording the gate knows, spoken. If THIS reaches a
-# mission worker while coding mode is on, nothing said inside the IDE is safe
-# from the collision.
+# The strongest delegation wording the gate knows, spoken.
EXPLICIT_DELEGATION = "Spawne bitte einen Agenten im Hintergrund" # i18n-allow: input vocab
# The mirror cases: the vehicle word comes FIRST, so these are orders to Jarvis
@@ -63,8 +59,7 @@ GENUINE_DELEGATIONS = [
"Delegiere das im Hintergrund an einen Worker", # i18n-allow: input vocab
]
-# "Open five more panes" — the pane-noun path, which is decided before any of
-# the vehicle logic and must stay exactly as it was.
+# "Open five more panes" — the pane-noun path, decided before any vehicle logic.
MORE_TERMINALS = "Öffne bitte fünf neue Claude Code Terminals" # i18n-allow: input vocab
@@ -85,130 +80,124 @@ def wired(monkeypatch: pytest.MonkeyPatch) -> Registry:
return registry
-async def _coding_mode(registry: Registry, folder: Path) -> None:
+async def _coding_mode(registry: Registry, folder: Path) -> str:
+ """Open a workspace in coding mode; returns the one pane's call-sign."""
await registry.start(str(folder), [{"agent": "claude"}])
registry.set_focus_mode(True)
+ return registry.session.terminals[0].name
# --------------------------------------------------------------------------- #
-# Part A — the mode is the switch #
+# The feature that must NOT be deleted #
# --------------------------------------------------------------------------- #
-async def test_coding_mode_blocks_even_an_explicit_spawn_request(
+async def test_coding_mode_still_allows_an_explicit_spawn(
wired: Registry, tmp_path: Path
) -> None:
- """The clearest possible delegation request still starts no worker.
+ """The scope correction, pinned: coding mode is not a reason to refuse.
- Deliberately the strongest wording the gate knows: if THIS reaches a mission
- worker, nothing the user says inside the IDE is safe from the collision.
+ Brainstorming inside the IDE and asking for a background agent is a normal
+ thing to do. The first version of this fix blocked it outright; this test
+ exists so that never comes back silently.
"""
await _coding_mode(wired, tmp_path)
- assert coding_mode_blocks_spawn() is True
- assert llm_spawn_allowed(EXPLICIT_DELEGATION) is False
+ assert llm_spawn_allowed(EXPLICIT_DELEGATION) is True
-async def test_workspace_without_the_toggle_still_delegates(
+async def test_coding_mode_allows_a_research_delegation(
wired: Registry, tmp_path: Path
) -> None:
- """Terminals on a screen are not the mode — the background agent stays.
+ """Naming no pane means the workspace has no claim, mode or not."""
+ await _coding_mode(wired, tmp_path)
+ assert llm_spawn_allowed("Spawn a background agent that audits the wiki") is True
- The toggle is what the user can see (the app-wide coding-mode badge), so it
- is what may take a feature away from them.
- """
- await wired.start(str(tmp_path), [{"agent": "claude"}])
- assert coding_mode_blocks_spawn() is False
- assert llm_spawn_allowed(EXPLICIT_DELEGATION) is True
[email protected]("text", GENUINE_DELEGATIONS)
+def test_genuine_delegation_still_outranks_an_open_workspace(text: str) -> None:
+ """The vehicle word FIRST is an order to Jarvis, even when a pane is named.
-async def test_leaving_coding_mode_restores_the_background_agent(
- wired: Registry, tmp_path: Path
-) -> None:
- """The block is a mode, not a latch — turning it off gives the feature back."""
- await _coding_mode(wired, tmp_path)
- assert llm_spawn_allowed("Spawn a background worker for this") is False
- wired.set_focus_mode(False)
- assert llm_spawn_allowed("Spawn a background worker for this") is True
+ "Spawn an agent that helps Alex" names a pane too — as what the new agent is
+ FOR. Reading it as an instruction to Alex would swallow a background request
+ the user genuinely made.
+ """
+ assert spawn_vehicle_outranks_workspace(text, names=PANES) is True
+ assert owns_turn(text, names=PANES) is False
def test_no_workspace_leaves_the_gate_untouched() -> None:
"""With no workspace at all, the gate behaves exactly as it always did."""
- assert coding_mode_blocks_spawn() is False
assert llm_spawn_allowed("Spawn an agent to research this") is True
assert llm_spawn_allowed("What is the capital of Portugal?") is False
-async def test_blocked_feedback_tells_the_model_to_use_a_terminal(
- wired: Registry, tmp_path: Path
-) -> None:
- """A block inside the IDE must not invite an offer of a background agent.
-
- The generic text asks the model to OFFER delegation on the next turn, which
- is the wrong next move here — the work belongs in a pane on screen.
- """
- assert spawn_blocked_feedback() == SPAWN_BLOCKED_MODEL_FEEDBACK
- await _coding_mode(wired, tmp_path)
- message = spawn_blocked_feedback()
- assert message == SPAWN_BLOCKED_CODING_MODE_FEEDBACK
- assert "agentic-ide-prompt" in message
-
-
# --------------------------------------------------------------------------- #
-# Part B — a pane's own fan-out is the pane's work #
+# The turn that belongs to a pane #
# --------------------------------------------------------------------------- #
def test_live_turn_reaches_the_addressed_panes() -> None:
- """The 2026-07-27 20:00 utterance belongs to Alex and Ellis, not to a worker.
-
- Asserted with the toggle OFF on purpose: whether coding mode was on during
- the live session cannot be recovered, so the fix may not depend on it.
- """
- assert coding_mode_blocks_spawn() is False
+ """The 2026-07-27 20:00 utterance belongs to Alex and Ellis, not to a worker."""
assert owns_turn(LIVE_TURN, names=PANES) is True
def test_pane_told_to_fan_out_keeps_the_turn_in_english() -> None:
- """Same shape, plainly worded — the rule is about word order, not locale."""
+ """Same shape, plainly worded — the rule is word order, not locale."""
text = "Alex should spawn a swarm of sub-agents to map the codebase"
assert owns_turn(text, names=PANES) is True
+ assert spawn_vehicle_outranks_workspace(text, names=PANES) is False
[email protected]("text", GENUINE_DELEGATIONS)
-def test_genuine_delegation_still_outranks_an_open_workspace(text: str) -> None:
- """The mirror bug stays shut: the vehicle word FIRST is an order to Jarvis.
+async def test_addressed_pane_blocks_the_llm_spawn(
+ wired: Registry, tmp_path: Path
+) -> None:
+ """End to end through the gate the model actually hits."""
+ pane = await _coding_mode(wired, tmp_path)
+ text = f"{pane} should spawn sub-agents and analyze the wiki system"
+ assert addressed_pane_blocks_spawn(text) is True
+ assert llm_spawn_allowed(text) is False
- "Spawn an agent that helps Alex" names a pane too — as what the new agent is
- FOR. Reading it as an instruction to Alex would swallow a background request
- the user genuinely made, which is the failure the vehicle stand-down exists
- to prevent.
- """
- assert spawn_vehicle_outranks_workspace(text, names=PANES) is True
- assert owns_turn(text, names=PANES) is False
+async def test_plain_terminal_prompt_never_spawns(
+ wired: Registry, tmp_path: Path
+) -> None:
+ """The ordinary case the user cares about most: "prompt <pane> …"."""
+ pane = await _coding_mode(wired, tmp_path)
+ text = f"Prompt {pane} to review the wake pipeline"
+ assert addressed_pane_blocks_spawn(text) is True
+ assert llm_spawn_allowed(text) is False
-def test_spawn_vocabulary_without_any_named_pane_is_never_the_workspace() -> None:
- """No call-sign, no claim — the ordinary delegation request is untouched."""
- text = "Spawn a background agent that audits the wiki system"
- assert spawn_vehicle_outranks_workspace(text, names=PANES) is True
- assert owns_turn(text, names=PANES) is False
+
+# --------------------------------------------------------------------------- #
+# What the model is told when a spawn is refused #
+# --------------------------------------------------------------------------- #
-async def test_coding_mode_hands_the_turn_to_the_pane(
+async def test_blocked_feedback_points_at_the_terminal(
wired: Registry, tmp_path: Path
) -> None:
- """In coding mode the stand-down lifts entirely.
+ """A block caused by an addressed pane must not invite a background offer.
- Not cosmetic: with Part A blocking the spawn, a turn the workspace also
- refused would reach nothing at all — the spawn gate would decline the
- mission, the router's fast path would decline to type, and the user would
- get silence. The two gates have to agree in the same direction.
+ The generic text asks the model to OFFER delegation on the next turn, which
+ is the wrong next move here — the work belongs in the pane just named.
"""
+ pane = await _coding_mode(wired, tmp_path)
+ message = spawn_blocked_feedback(f"{pane} should spawn sub-agents")
+ assert message == SPAWN_BLOCKED_ADDRESSED_PANE_FEEDBACK
+ assert "agentic-ide-prompt" in message
+ # Gathering context for the brief stays explicitly allowed.
+ assert "other functions" in message
+
+
+async def test_blocked_feedback_stays_generic_without_a_pane(
+ wired: Registry, tmp_path: Path
+) -> None:
+ """A conversational block keeps the offer-delegation guidance."""
await _coding_mode(wired, tmp_path)
- pane = wired.session.terminals[0].name
- text = f"{pane} should spawn sub-agents and analyze the wiki system"
- assert spawn_vehicle_outranks_workspace(text, names=[pane]) is False
- assert owns_turn(text, names=[pane]) is True
+ assert spawn_blocked_feedback("What is the capital of Portugal?") == (
+ SPAWN_BLOCKED_MODEL_FEEDBACK
+ )
+ assert spawn_blocked_feedback() == SPAWN_BLOCKED_MODEL_FEEDBACK
def test_asking_for_more_terminals_is_still_the_workspace() -> None:
diff --git a/tests/unit/agentic_ide/test_intent_briefed_name.py b/tests/unit/agentic_ide/test_intent_briefed_name.py
new file mode 100644
index 0000000000..2ee94061fd
--- /dev/null
+++ b/tests/unit/agentic_ide/test_intent_briefed_name.py
@@ -0,0 +1,82 @@
+"""A garbled call-sign is repaired where the sentence vouches for it.
+
+Maintainer report 2026-07-28: "he sometimes prompts the wrong terminal". The
+measurable half of that is worse than wrong — it is NOTHING. "Hey, prompte adex"
+(the maintainer's own example) addressed no pane at all: "adex" reaches "Alex"
+only on the fuzzy band, so the canonicaliser left it alone, every addressing
+template is anchored on the exact spelling, and the last-resort branch rejects a
+name that is not certain. Three layers, one silent miss.
+
+Fuzzy matching cannot simply be switched on to fix that. Measured against the
+shipping name pool, ordinary words of the spoken language reach it — "unten"
+scores into "Hunter", "keine" into "Kai" — and a sentence rewritten on that
+evidence briefs a pane nobody named.
+
+What makes the difference is POSITION. Directly behind a briefing verb there is
+exactly one thing a word can be: the addressee. So the fuzzy band is admitted in
+that slot and nowhere else. These tests pin both halves — the repair, and the
+ordinary sentences that must stay untouched.
+"""
+from __future__ import annotations
+
+import pytest
+
+from jarvis.agentic_ide.intent import detect_all
+
+PANES = ["Alex", "Ellis", "Casey", "Dana"]
+
+
+def _addressed(text: str) -> list[str]:
+ return [found.terminal for found in detect_all(text, names=PANES)]
+
+
+ ("text", "expected"),
+ [
+ # The live example, and its English twin.
+ ("Hey, prompte adex mal die Wake-Pipeline zu prüfen", "Alex"), # i18n-allow: input vocab
+ ("prompt adex to review the wake path", "Alex"),
+ # A pane noun between the verb and the name changes nothing.
+ ("prompt the terminal adex to fix the tests", "Alex"),
+ # Other briefing verbs carry the same slot.
+ ("beauftrage elis mit dem Wiki-Audit", "Ellis"), # i18n-allow: input vocab
+ ("instruct elis to read the transcripts", "Ellis"),
+ ],
+)
+def test_briefing_verb_repairs_a_garbled_call_sign(text: str, expected: str) -> None:
+ assert _addressed(text) == [expected]
+
+
+def test_exact_spelling_is_unaffected() -> None:
+ """The ordinary path keeps working — this only ADDS a rescued spelling."""
+ spoken = "Prompte Alex, er soll die Tests fixen" # i18n-allow: input vocab
+ assert _addressed(spoken) == ["Alex"]
+
+
+ "text",
+ [
+ # A briefing verb whose object is a THING, not a pane. This is the case
+ # the position exemption could plausibly break, so it is pinned hardest.
+ "prompte die Dokumentation neu", # i18n-allow: input vocab
+ "prompt the user for input",
+ "assign the ticket to the backlog",
+ # No briefing verb at all — the fuzzy band must stay shut here.
+ "schreib mal die Doku", # i18n-allow: input vocab
+ "was ist die Hauptstadt von Portugal", # i18n-allow: input vocab
+ ],
+)
+def test_ordinary_speech_still_addresses_nothing(text: str) -> None:
+ assert _addressed(text) == []
+
+
+def test_a_word_far_from_the_verb_is_not_a_name() -> None:
+ """The exemption is the SLOT, not the sentence.
+
+ Without this bound, one briefing verb anywhere would license fuzzy matching
+ over every remaining word — which is exactly the collision the last-resort
+ branch spent a live session learning to refuse.
+ """
+ assert _addressed("prompt Alex and then check whether unten is still open") == [
+ "Alex"
+ ]