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): cap spoken briefs at 1.2s instead of a CLI rewrite
Haralde34761a7b156
diff --git a/jarvis/agentic_ide/context.py b/jarvis/agentic_ide/context.pyindex bdb92085d3..7ec2ed572d 100644--- a/jarvis/agentic_ide/context.py+++ b/jarvis/agentic_ide/context.py@@ -26,6 +26,7 @@ in-memory state — the session's cached project profile and each terminal's rinbuffer. No disk read, no subprocess, no network. The project profile wascomputed ONCE when the session started, precisely so this path stays free."""+from __future__ import annotationsimport time@@ -53,9 +54,9 @@ _HEADER = ("T2, T3. The user says that number, and so do you.\n""\n""How to behave while this mode is on:\n"- "- When the user tells a terminal to do something (\"tell T1 to …\", "- "\"T2 soll …\", \"prompt terminal three\", \"let the second one " # i18n-allow: quoted addressing example- "refactor …\"), send it to THAT terminal with "+ '- When the user tells a terminal to do something ("tell T1 to …", '+ '"T2 soll …", "prompt terminal three", "let the second one ' # i18n-allow: quoted addressing example+ 'refactor …"), send it to THAT terminal with '"the agentic-ide-prompt function. That is the whole point of this mode. ""NEVER spawn a background agent for work aimed at a terminal, and never ""answer with what you WOULD have sent — send it.\n"@@ -71,20 +72,21 @@ _HEADER = ("printed. Never guess, never take a screenshot — the terminals are readable ""directly.\n""- NEVER claim you sent, forwarded, passed on or told a terminal anything "- "unless a function call in THIS turn actually did it. Saying \"I have let "- "T1 know\" while nothing reached T1 is the worst failure this mode has: "+ 'unless a function call in THIS turn actually did it. Saying "I have let '+ 'T1 know" while nothing reached T1 is the worst failure this mode has: '"the user walks away believing an agent is working, and only finds the idle ""terminal later. If the work did not go out, say plainly that it did not and "- "why — an honest \"I could not reach that terminal\" is always better than a "+ 'why — an honest "I could not reach that terminal" is always better than a '"confident sentence that turns out to be false.\n""- A pane listed below as STILL BEING WRITTEN has received NOTHING yet. The "- "prompt writer takes 10-30 seconds, and the earlier prompts counted for that "- "pane are OLD ones, not this one. Say the work is still going out — never "- "that it arrived, and never that the agent has started.\n"+ "brief is still going out (usually about a second; a slow writer is capped), "+ "and the earlier prompts counted for that pane are OLD ones, not this one. "+ "Say the work is still going out — never that it arrived, and never that "+ "the agent has started.\n""- Brainstorming, architecture, and 'what should we do next' are answered ""inline, against this codebase, and you may propose which terminal should ""take which part.\n"- "- Say the terminal's number out loud in your answers (\"T2 is on it\"), so "+ '- Say the terminal\'s number out loud in your answers ("T2 is on it"), so '"the user always knows which pane is doing what.\n""\n""The facts below are the live state of that workspace. It is context, not a "@@ -168,11 +170,7 @@ def focus_context_block(max_chars: int = _MAX_CHARS) -> str:writing = {}parts.append(f"Terminals in this workspace ({len(session.terminals)}):")for term in session.terminals:- parts.extend(- _terminal_block(- term, tail_lines, writing_for_s=writing.get(term.name)- )- )+ parts.extend(_terminal_block(term, tail_lines, writing_for_s=writing.get(term.name)))else:parts.append("No terminals are open in this workspace yet.")diff --git a/jarvis/agentic_ide/prompt_composer.py b/jarvis/agentic_ide/prompt_composer.pyindex 9f5033ffc8..d49f87c215 100644--- a/jarvis/agentic_ide/prompt_composer.py+++ b/jarvis/agentic_ide/prompt_composer.py@@ -51,25 +51,22 @@ API key at all (§3):The composer is honest about which layer produced the result (``composed_by``),because the readback the user hears should not claim more than happened.-**On latency (maintainer decision 2026-08-18, supersedes 2026-07-25).** The-2026-07-25 trade sent this through a thinking model and asked for a 1400-2400-character specification of the code. Live that was 10-30 s of writing for a-job that is: clean the spoken sentence, attach the neighbouring ``@files``.-A competitor Flash call did the same job in about a second, at comparable-quality. The tolerance is therefore 1-5 s. Thinking is off-(``reasoning_effort="none"``), the brief is lean (see ``prompt_blueprint``),-and house rules stay out of the writer prompt because the receiving agent-already has them. What must still never happen is a silent demotion to a-weaker *quality tier* — a fast Flash/Tool-Model writer is the intended-rung, not a fallback.--Preparation still overlaps: resolving the writer and reading a slim outline-of the top files run together so the model call starts as soon as the-slowest single piece is done.--A slow writer is still hedged after ``HEDGE_AFTER_S`` / ``HEDGE_AFTER_API_S``-and the first valid brief wins. The hedge is insurance against a hang, not-the path to a 1 s brief.+**On latency (maintainer decision 2026-08-19, supersedes 2026-08-18).** The+job is: clean the spoken sentence, point at the neighbouring ``@files`` from+the in-memory tree index. BridgeVoice lands that in about a second by pasting+the transcript; we do the same, with a bounded Flash rewrite in front when it+fits the budget. Live 2026-08-19 18:10 the previous chain did not: Flash sat+through an 8 s hedge, OpenRouter failed (no key), then a coding CLI wrote a+376-character brief in 9.9 s — 22 s end to end, while recap jobs were spawning+the same CLI. File *bodies* were never the wait, but sending AST outlines+plus a CLI rescue made the wait look like "reading the repo".++The spoken budget is therefore ``FAST_BUDGET_S`` (about a second). Thinking+is off. The writer sees candidate *paths* from the tree, not file contents —+the receiving agent opens those files. A coding CLI is not a rescue on this+path: if Flash is not done when the budget expires, the deterministic brief+ships. What must still never happen is a silent demotion to a weaker+*quality tier* while the user waits.**On the silence.** The beats below (``start`` → ``thinking``/``drafting`` →``ready``, and ``sent`` once the pane took it) are printed as they happen,@@ -119,8 +116,17 @@ from .task_kind import (# 10-12 s for a trivial prompt and 26.6 s for a real structured brief on the# fastest model. At 45 s a slower model or a loaded machine would have expired# routinely, and every expiry buys the regex prompt — never a faster good one.+#+# Spoken deliveries no longer wait this out — see ``FAST_BUDGET_S``. This+# ceiling remains for tests and for a caller that patches it.COMPOSE_TIMEOUT_S = 90.0+# Hard cap the user actually waits. BridgeVoice lands a transcript in ~1 s;+# a Flash rewrite of the same sentence plus tree ``@files`` either beats that+# or we ship the deterministic brief. Measured live 2026-08-19 18:10: the+# 90 s ceiling plus an 8 s API hedge plus a CLI rescue was 22 s of silence.+FAST_BUDGET_S = 1.2+# How many files may be attached. Enough to point the agent at a feature's# surface; few enough that the agent's context is not flooded with guesses.MAX_FILE_REFERENCES = 5@@ -155,10 +161,11 @@ HEDGE_AFTER_S = 30.0# healthy band, so the double spend stays as rare as it is for the CLI.## Since 2026-08-18 the CEILING for an API writer — see ``_hedge_after_s``.-# Tightened 20 → 8 s the same day: a no-thinking Flash/Tool-Model brief is-# supposed to land inside 5 s, so a 20 s first-boot ceiling let a hung-# writer sit four times the tolerance before insurance even started.-HEDGE_AFTER_API_S = 8.0+# Tightened 20 → 8 s (2026-08-18) then 8 → 1 s: a no-thinking Flash brief+# is supposed to land inside the spoken budget, so an 8 s first-boot+# ceiling let a hung writer sit through the whole wait before anyone else+# was allowed to start — and the next rung was a coding CLI.+HEDGE_AFTER_API_S = 1.0# The insurance threshold calibrates itself to the writer actually in use.#@@ -403,7 +410,7 @@ _START_PHRASES: dict[str, tuple[str, ...]] = {_THINKING_PHRASES = ("Thinking {name}'s brief through - {context}.",- "Reading the code before {name} is briefed - {context}.",+ "Matching files from the tree for {name} - {context}.","Working out what {name} needs to know - {context}.",)@@ -427,15 +434,15 @@ def _start_message(kind: str, instruction: str, terminal_name: str) -> str:def _thinking_message(- instruction: str, terminal_name: str, *, outlines: int, writer_label: str+ instruction: str, terminal_name: str, *, files: int, writer_label: str) -> str:"""The line that stands while the model works — with what it was handed."""- if outlines == 1:- context = "one file outline to go on"- elif outlines:- context = f"{outlines} file outlines to go on"+ if files == 1:+ context = "one starting file from the tree"+ elif files:+ context = f"{files} starting files from the tree"else:- context = "no matching files, so your words alone"+ context = "your words alone"if writer_label:context = f"{context}, via {writer_label}"return _variant(_THINKING_PHRASES, instruction).format(name=terminal_name, context=context)@@ -616,19 +623,36 @@ def _resolve_writer(): # noqa: ANN202 - (Brain | None, str), avoid an import cydef _rescue_writer(tried: Sequence[str]): # noqa: ANN202 - (Brain | None, str)- """The next writer to try after one accepted the job and failed inside it."""+ """The next writer to try after one accepted the job and failed inside it.++ A coding CLI is not a rescue here: its cold start is the 10-20 s wait+ the spoken path exists to avoid. Flash or the API tier, or the+ deterministic brief — never a subscription process on the user's clock.+ """from .writer import resolve_rescue_writer- return resolve_rescue_writer(cli_timeout_s=COMPOSE_TIMEOUT_S, exclude=tuple(tried))+ return resolve_rescue_writer(+ cli_timeout_s=COMPOSE_TIMEOUT_S,+ exclude=tuple(tried),+ allow_subscription=False,+ )+++# No file bodies. The tree index already named the candidates; the receiving+# agent opens those @files. Sending AST outlines made the writer prompt+# thousands of characters and looked like "reading the repo" while the wait+# was the model. Paths stay in the candidate list.+_OUTLINE_FILES = 0+_OUTLINE_CHARS = 0+# Spoken compositions currently in ``compose()``. Recap jobs read this so+# they do not spawn a coding CLI on the same machine the user is waiting on.+_live_composes = 0-# Slim outlines only. The receiving agent opens the @files itself; a handful-# of signatures is enough for the writer to name a real symbol. The previous-# 5 × 9 k / 34 k budget (plus a 1200-char house-rules dump) was most of the-# input tokens on every call, and house rules already live in the agent's-# own system prompt.-_OUTLINE_FILES = 3-_OUTLINE_CHARS = 1_800++def compose_busy() -> bool:+ """True while a brief is being written. Cheap, in-memory (AP-9)."""+ return _live_composes > 0async def _llm_compose(@@ -678,23 +702,14 @@ async def _read_context(session, # noqa: ANN001 - Session, avoid an import cyclecandidates: list[str],) -> tuple[dict[str, str], str]:- """Slim file outlines for the writer. House rules are not included.+ """No file bodies. Candidate paths travel separately in the user block.- The receiving agent already has the repository's instruction files in its- own prompt; pasting them here cost tokens and thinking time without- changing what the pane does. Outlines stay, tightly bounded, so the- writer can name a real symbol in ``## Key files``.+ Kept as an awaitable so cancellation still reaps a sibling task, and so+ tests can patch this hook. Production reads nothing: the tree index+ already picked the paths, and the agent opens them."""- from .code_skeleton import skeletons as read_skeletons-- outlines = await asyncio.to_thread(- read_skeletons,- session.folder,- candidates,- max_files=_OUTLINE_FILES,- max_total=_OUTLINE_CHARS,- )- return outlines, ""+ del session, candidates+ return {}, ""async def _compose_once(@@ -728,7 +743,7 @@ async def _compose_once(_thinking_message(base_instruction or said,terminal_name,- outlines=len(outlines),+ files=len(candidates),writer_label=_writer_label(brain),),)@@ -874,6 +889,48 @@ async def compose(started = time.monotonic()notify(STAGE_START, _start_message(kind, subject, terminal_name))+ global _live_composes+ _live_composes += 1+ try:+ return await _compose_after_start(+ said=said,+ base_instruction=base_instruction,+ subject=subject,+ kind=kind,+ session=session,+ terminal_name=terminal_name,+ agent_display=agent_display,+ max_files=max_files,+ brain=brain,+ attached=attached,+ spoken_before=spoken_before,+ notify=notify,+ deterministic=_deterministic,+ started=started,+ )+ finally:+ _live_composes -= 1+++async def _compose_after_start(+ *,+ said: str,+ base_instruction: str,+ subject: str,+ kind: str,+ session: object,+ terminal_name: str,+ agent_display: str,+ max_files: int,+ brain: object,+ attached: list,+ spoken_before: tuple,+ notify: Callable[[str, str], None],+ deterministic: Callable[..., ComposedPrompt],+ started: float,+) -> ComposedPrompt:+ from . import prompt_blueprint as blueprint+# The writer probe goes first and runs on its own: it is the one piece of# preparation that can take seconds (a config load plus a sign-in probe per# subscription CLI), it needs nothing from the disk work below, and running@@ -895,10 +952,9 @@ async def compose(def degrade(note: str) -> ComposedPrompt:notify(STAGE_FALLBACK, f"{terminal_name} gets the plain brief instead: {note}.")- return _deterministic("fallback", note, candidates=candidates)+ return deterministic("fallback", note, candidates=candidates)- # Reading the outlines starts NOW, not once the writer is known — on a cold- # subscription CLI the probe is the longer of the two.+ # Candidate paths are enough; file bodies stay out (see `_read_context`).context_task = asyncio.create_task(_read_context(session, candidates))try:@@ -936,7 +992,8 @@ async def compose(# All attempts share ONE budget. The user is waiting through the whole# sequence, and three full timeouts in a row is not a rescue — it is the# same fallback three times slower.- deadline = started + COMPOSE_TIMEOUT_S+ budget_s = min(COMPOSE_TIMEOUT_S, FAST_BUDGET_S)+ deadline = started + budget_stried: list[str] = [writer_source] if writer_source else []attempts: dict[asyncio.Task[str], str] = {}spawned_at: dict[asyncio.Task[str], float] = {}@@ -945,11 +1002,19 @@ async def compose(hedged = not may_substitutecomposed = ""reason = ""+ spawned = 0def _spawn_attempt(brn, source: str) -> bool: # noqa: ANN001 - Brain"""Start one writer on the brief, unless the budget says otherwise."""+ nonlocal spawnedremaining = deadline - time.monotonic()- if remaining < _MIN_ATTEMPT_S:+ # The first attempt always starts: `_MIN_ATTEMPT_S` is sized for a+ # coding CLI rescue (20 s), and a 1.2 s spoken budget would otherwise+ # skip Flash entirely. Later attempts still need a CLI-sized window+ # or they become the wait we are cutting.+ if remaining <= 0:+ return False+ if spawned and remaining < _MIN_ATTEMPT_S:return Falsetask = asyncio.create_task(asyncio.wait_for(@@ -972,6 +1037,7 @@ async def compose()attempts[task] = sourcespawned_at[task] = time.monotonic()+ spawned += 1return Truedef _cancel_attempts() -> None:@@ -981,7 +1047,7 @@ async def compose(if not _spawn_attempt(writer, writer_source):_discard(context_task)- return degrade(f"composer timed out after {COMPOSE_TIMEOUT_S:g}s")+ return degrade(f"composer timed out after {budget_s:g}s")try:while attempts and not composed:@@ -1023,7 +1089,7 @@ async def compose(try:candidate = _strip_wrapper(task.result())except (TimeoutError, asyncio.CancelledError):- reason = f"composer timed out after {COMPOSE_TIMEOUT_S:g}s"+ reason = f"composer timed out after {budget_s:g}s"except Exception as exc: # noqa: BLE001 - any failure crosses overlogger.info("Agentic IDE prompt composer failed on {}: {}",@@ -1096,7 +1162,7 @@ async def compose(_cancel_attempts()if not composed:_discard(context_task)- return degrade(reason or f"composer timed out after {COMPOSE_TIMEOUT_S:g}s")+ return degrade(reason or f"composer timed out after {budget_s:g}s")# Keep only the references that survive an existence check — the model may# echo a candidate that was renamed, or invent one outright. A dead @path@@ -1130,6 +1196,7 @@ async def compose(__all__ = ["COMPOSE_TIMEOUT_S",+ "FAST_BUDGET_S","HEDGE_AFTER_API_S","HEDGE_AFTER_S","MAX_FILE_REFERENCES",@@ -1146,5 +1213,6 @@ __all__ = ["ProgressSink","announce_delivery","compose",+ "compose_busy","print_notice",]diff --git a/jarvis/agentic_ide/recap_engine.py b/jarvis/agentic_ide/recap_engine.pyindex ba15ad9b94..b81dc5826c 100644--- a/jarvis/agentic_ide/recap_engine.py+++ b/jarvis/agentic_ide/recap_engine.py@@ -560,6 +560,16 @@ def refresh_soon(term: Any, *, lines: Sequence[str], folder: str = "") -> None:returnif _inflight >= MAX_CONCURRENT:return+ try:+ from .prompt_composer import compose_busy++ if compose_busy():+ # A spoken brief is on the clock. Recaps that walk OpenRouter →+ # Codex → Gemini → Claude CLI steal the same writers (live+ # 2026-08-19 18:10: 22 s prompt while recaps spawned the CLI).+ return+ except Exception: # noqa: BLE001 - recap never blocks a composition+ logger.debug("Agentic IDE recap: compose-busy check failed", exc_info=True)try:loop = asyncio.get_running_loop()except RuntimeError:@@ -917,6 +927,14 @@ async def summarize_with_model(return Nonefirst_failure: Exception | None = Nonefor brain in brains:+ try:+ from .prompt_composer import compose_busy++ if compose_busy():+ logger.info("Agentic IDE recap: standing down, a brief is being written")+ break+ except Exception: # noqa: BLE001 - a missed pause never costs the brief+ logger.debug("Agentic IDE recap: compose-busy check failed", exc_info=True)try:return await _summarize_on(brain, term, rows, folder=folder)except Exception as exc: # noqa: BLE001 - the next family is the handling@@ -926,7 +944,8 @@ async def summarize_with_model(getattr(brain, "model", "") or getattr(brain, "name", "") or type(brain).__name__,type(exc).__name__,)- assert first_failure is not None # noqa: S101 - the loop above ran at least once+ if first_failure is None:+ return Noneraise first_failurediff --git a/jarvis/agentic_ide/writer.py b/jarvis/agentic_ide/writer.pyindex f707f9f121..ca9854fb49 100644--- a/jarvis/agentic_ide/writer.py+++ b/jarvis/agentic_ide/writer.py@@ -239,7 +239,10 @@ def _fastest_writer(config: Any, cli_timeout_s: float | None) -> tuple[Any | Nondef resolve_rescue_writer(- *, cli_timeout_s: float | None = None, exclude: Sequence[str] = ()+ *,+ cli_timeout_s: float | None = None,+ exclude: Sequence[str] = (),+ allow_subscription: bool = True,) -> tuple[Any | None, str]:"""The next writer to try after one accepted the job and failed inside it.@@ -248,6 +251,11 @@ def resolve_rescue_writer(re-probing the same tier with a different model name would just spend thesame dead credential twice.+ ``allow_subscription=False`` skips the coding CLI. The spoken path uses+ that: a CLI cold start is 10-20 s, which is the wait the fast budget+ exists to cut, so a dead Flash writer becomes the deterministic brief+ rather than a subscription spawn.+Returns ``(None, "")`` when nothing is left, and the caller then uses itsdeterministic layer. Only reached AFTER a real failure — an unhonourablepin still degrades at resolution time rather than quietly landing on a@@ -266,6 +274,8 @@ def resolve_rescue_writer(for rung in _AUTO_ORDER:if rung in tried:continue+ if rung == "subscription" and not allow_subscription:+ continuebrain, source = _writer_for_rung(rung, config, cli_timeout_s)if brain is not None:logger.info("Agentic IDE brief falls across to {} after a failed writer", source)diff --git a/tests/unit/agentic_ide/test_composer_hedge.py b/tests/unit/agentic_ide/test_composer_hedge.pyindex ececde6681..d9e4b639d5 100644--- a/tests/unit/agentic_ide/test_composer_hedge.py+++ b/tests/unit/agentic_ide/test_composer_hedge.py@@ -18,6 +18,14 @@ import pytestfrom jarvis.agentic_ide import file_index, prompt_composer+[email protected](autouse=True)+def _spoken_budget_does_not_clip_hedge_tests(monkeypatch: pytest.MonkeyPatch) -> None:+ """Hedge tests need a long enough ceiling that a 1.2 s spoken cap would+ cancel the primary before the second writer is allowed to start."""+ monkeypatch.setattr(prompt_composer, "FAST_BUDGET_S", 90.0)++BRIEF = "## Task\nMake the wake path faster.\n\n## Done when\n- It is faster."HEDGE_BRIEF = "## Task\nMake the wake path quick.\n\n## Done when\n- It is quick."@@ -362,11 +370,11 @@ async def test_the_hedge_respects_the_shared_budget(# ----------------------------------------------------------------------------def test_the_api_first_boot_ceiling_is_eight_seconds() -> None:- """A no-thinking Flash brief is supposed to land inside 5 s. The old- 20 s first-boot ceiling let a hung writer sit four times the tolerance- before insurance started. Behaviour tests below still monkeypatch."""- assert prompt_composer.HEDGE_AFTER_API_S == 8.0+def test_the_api_first_boot_ceiling_is_one_second() -> None:+ """A no-thinking Flash brief is supposed to land inside the spoken+ budget. The old 8 s first-boot ceiling let a hung writer sit through+ the whole wait before insurance started, and the next rung was a CLI."""+ assert prompt_composer.HEDGE_AFTER_API_S == 1.0def test_without_history_the_ceilings_apply(monkeypatch: pytest.MonkeyPatch) -> None:@@ -395,7 +403,12 @@ def test_the_floor_keeps_one_quick_brief_from_arming_a_hair_trigger(monkeypatch: pytest.MonkeyPatch,) -> None:"""One 0.8 s rewrite must not insure the next, bigger brief at 2 s: a brief- that reads five outlines legitimately takes longer than a plain rewrite."""+ that reads five outlines legitimately takes longer than a plain rewrite.++ The spoken ceiling (1 s) would hide this floor; lift it so the floor is+ the binding constraint, which is what this test names.+ """+ monkeypatch.setattr(prompt_composer, "HEDGE_AFTER_API_S", 20.0)monkeypatch.setattr(prompt_composer, "_HEDGE_FLOOR_S", 6.0)prompt_composer._remember_writer_seconds("api", 0.8) # noqa: SLF001@@ -603,9 +616,11 @@ async def test_a_healthy_hedge_recruits_nobody_else(monkeypatch.setattr(prompt_composer,"_rescue_writer",- lambda tried: (_Writer("hedge"), "api")- if len(tried) == 1- else pytest.fail("recruited a third writer while the hedge was alive"),+ lambda tried: (+ (_Writer("hedge"), "api")+ if len(tried) == 1+ else pytest.fail("recruited a third writer while the hedge was alive")+ ),)monkeypatch.setattr(prompt_composer, "_llm_compose", _compose)diff --git a/tests/unit/agentic_ide/test_composer_progress.py b/tests/unit/agentic_ide/test_composer_progress.pyindex eed83fc07b..06706ed4c1 100644--- a/tests/unit/agentic_ide/test_composer_progress.py+++ b/tests/unit/agentic_ide/test_composer_progress.py@@ -1,9 +1,10 @@"""The composer says what it is doing while it does it.-Writing a brief takes 10-27 s — a quality-tier model reading file outlines,-and on a subscription CLI a cold process start before it thinks at all. For all-of that the terminal used to show nothing, which makes a working composer and a-wedged one look identical, and makes the wait feel longer than it is.+Writing a brief is capped at about a second — a Flash rewrite of the spoken+sentence plus tree ``@files``, or the deterministic brief if that misses.+For that wait the terminal used to show nothing, which makes a working+composer and a wedged one look identical, and makes the wait feel longer+than it is.So the beats are part of the contract now, and these guards pin the threeproperties that make them worth printing rather than noise: they arrive in@@ -11,6 +12,7 @@ order, every line names the pane it belongs to (a fleet composes at once, andan unattributed line is worse than none), and none of them can ever cost theprompt itself."""+from __future__ import annotationsfrom types import SimpleNamespace@@ -44,9 +46,7 @@ def _writer_available(monkeypatch: pytest.MonkeyPatch) -> None:def _session(tmp_path) -> object: # noqa: ANN001 - pytest tmp_path- profile = SimpleNamespace(- instruction_files=[], summary_lines=lambda: ["Test workspace"]- )+ profile = SimpleNamespace(instruction_files=[], summary_lines=lambda: ["Test workspace"])return SimpleNamespace(folder=str(tmp_path), profile=profile)@@ -101,9 +101,11 @@ async def test_the_first_token_says_the_model_started_writing(# It lands between "thinking" and "ready", and only once however many# deltas arrive.assert stages.count(prompt_composer.STAGE_DRAFTING) == 1- assert stages.index(prompt_composer.STAGE_THINKING) < stages.index(- prompt_composer.STAGE_DRAFTING- ) < stages.index(prompt_composer.STAGE_READY)+ assert (+ stages.index(prompt_composer.STAGE_THINKING)+ < stages.index(prompt_composer.STAGE_DRAFTING)+ < stages.index(prompt_composer.STAGE_READY)+ )async def test_the_opening_line_follows_the_instruction(@@ -123,9 +125,7 @@ async def test_the_opening_line_follows_the_instruction(await prompt_composer.compose(spoken, session=session, terminal_name="Kate", on_progress=seen.append)- opening = next(- n.message for n in seen if n.stage == prompt_composer.STAGE_START- )+ opening = next(n.message for n in seen if n.stage == prompt_composer.STAGE_START)lines.append(opening)# The user's own words come back, so a misheard instruction is visible# before the model has spent 20 s on it.@@ -226,9 +226,7 @@ async def test_the_closing_line_keeps_typed_and_started_apart("""A prompt sitting in an input box looks exactly like a running task."""seen: list[prompt_composer.ComposeNotice] = []- prompt_composer.announce_delivery(- "Kate", delivered=True, submitted=submitted, sink=seen.append- )+ prompt_composer.announce_delivery("Kate", delivered=True, submitted=submitted, sink=seen.append)assert len(seen) == 1assert seen[0].stage == prompt_composer.STAGE_SENT@@ -240,7 +238,9 @@ async def test_an_undelivered_pane_says_why() -> None:seen: list[prompt_composer.ComposeNotice] = []prompt_composer.announce_delivery(- "Kate", delivered=False, reason="its agent is exited, not running",+ "Kate",+ delivered=False,+ reason="its agent is exited, not running",sink=seen.append,)diff --git a/tests/unit/agentic_ide/test_composer_writer_rescue.py b/tests/unit/agentic_ide/test_composer_writer_rescue.pyindex 9a9fc24000..23718f4070 100644--- a/tests/unit/agentic_ide/test_composer_writer_rescue.py+++ b/tests/unit/agentic_ide/test_composer_writer_rescue.py@@ -8,6 +8,7 @@ handed the agent the raw spoken sentence for days while a signed-insubscription sat unused. One dead credential must not brick the feature whenanother provider is right there (AP-22)."""+from __future__ import annotationsfrom dataclasses import dataclass, field@@ -17,6 +18,14 @@ import pytestfrom jarvis.agentic_ide import file_index, prompt_composer+[email protected](autouse=True)+def _spoken_budget_does_not_clip_rescue_tests(monkeypatch: pytest.MonkeyPatch) -> None:+ """Rescue tests need a window wider than `_MIN_ATTEMPT_S` after the first+ writer dies. The spoken 1.2 s cap would skip the second writer entirely."""+ monkeypatch.setattr(prompt_composer, "FAST_BUDGET_S", 90.0)++BRIEF = "## Task\nMake the wake path faster.\n\n## Done when\n- It is faster."@@ -50,9 +59,7 @@ def workspace(tmp_path: Path) -> _Session:return _Session(folder=str(tmp_path))-def _writers(- monkeypatch: pytest.MonkeyPatch, first: str, rescue: tuple[object, str]-) -> list[str]:+def _writers(monkeypatch: pytest.MonkeyPatch, first: str, rescue: tuple[object, str]) -> list[str]:"""Wire a first writer and what the rescue offers. Returns the calls made."""used: list[str] = []monkeypatch.setattr(@@ -147,9 +154,7 @@ async def test_the_dead_rung_is_named_so_it_is_not_retried(async def _boom(**_kwargs: object) -> str:raise RuntimeError("429 RESOURCE_EXHAUSTED")- monkeypatch.setattr(- prompt_composer, "_resolve_writer", lambda: (_Writer("depleted"), "api")- )+ monkeypatch.setattr(prompt_composer, "_resolve_writer", lambda: (_Writer("depleted"), "api"))monkeypatch.setattr(prompt_composer,"_rescue_writer",diff --git a/tests/unit/agentic_ide/test_prompt_composer.py b/tests/unit/agentic_ide/test_prompt_composer.pyindex 60b8ce0f07..81ba7a70dc 100644--- a/tests/unit/agentic_ide/test_prompt_composer.py+++ b/tests/unit/agentic_ide/test_prompt_composer.py@@ -6,6 +6,7 @@ words reach the terminal — just phrased less well. So the tests here are mostlabout the unhappy paths: they are the ones that decide whether the feature worksfor an arbitrary downloader (§3) or only on a machine like the maintainer's."""+from __future__ import annotationsfrom dataclasses import dataclass, field@@ -257,13 +258,16 @@ async def test_the_writer_gets_the_rules_for_the_detected_kind(assert "IMPLEMENTATION task" not in seen["system"]-async def test_the_writer_is_shown_an_outline_of_the_candidate_files(+async def test_the_writer_gets_candidate_paths_not_file_bodies(workspace: _Session, monkeypatch: pytest.MonkeyPatch) -> None:- """Without the outline the prompt can only describe code, not name it."""- provider = (- Path(workspace.folder) / "jarvis" / "plugins" / "wake" / "vosk_kws_provider.py"- )+ """The tree index names the files; the agent opens them.++ Sending AST outlines made the writer prompt thousands of characters and+ looked like reading the repo. The wait was the model, not the disk, but+ the bodies still have no place on a 1 s path.+ """+ provider = Path(workspace.folder) / "jarvis" / "plugins" / "wake" / "vosk_kws_provider.py"provider.write_text('"""Vosk keyword spotting."""\n\n\n'"def candidate_shape_ok(span: float) -> bool:\n return True\n",@@ -282,17 +286,69 @@ async def test_the_writer_is_shown_an_outline_of_the_candidate_files("review the vosk wake provider", session=workspace, terminal_name="Kai")- assert "candidate_shape_ok" in seen["user"]- assert "Vosk keyword spotting." in seen["user"]- # House rules stay out: the receiving agent already has them. Re-loading- # the 1200-char dump would go green without this pin.+ assert "jarvis/plugins/wake/vosk_kws_provider.py" in seen["user"]+ assert "FILE OUTLINES" not in seen["user"]+ assert "candidate_shape_ok" not in seen["user"]+ # House rules stay out: the receiving agent already has them.assert "HOUSE RULES" not in seen["user"]-def test_the_outline_budget_stays_slim() -> None:- """Five files at 34 k was most of the input tokens on every call."""- assert prompt_composer._OUTLINE_FILES == 3 # noqa: SLF001- assert prompt_composer._OUTLINE_CHARS == 1800 # noqa: SLF001+def test_the_writer_does_not_read_file_bodies() -> None:+ """Bodies were the over-sync. Paths come from the in-memory tree."""+ assert prompt_composer._OUTLINE_FILES == 0 # noqa: SLF001+ assert prompt_composer._OUTLINE_CHARS == 0 # noqa: SLF001+++async def test_a_slow_writer_ships_the_plain_brief_inside_the_fast_budget(+ workspace: _Session, monkeypatch: pytest.MonkeyPatch+) -> None:+ """Spoken delivery must not wait out a coding CLI. Live 2026-08-19 18:10+ Flash sat 8 s, then Claude CLI wrote 376 chars in 9.9 s — 22 s total."""+ _prime(workspace)++ async def _hang(**_kwargs: object) -> str:+ import asyncio++ await asyncio.sleep(60)+ return "## Task\nNever."++ monkeypatch.setattr(prompt_composer, "FAST_BUDGET_S", 0.05)+ monkeypatch.setattr(prompt_composer, "COMPOSE_TIMEOUT_S", 90.0)+ monkeypatch.setattr(prompt_composer, "_llm_compose", _hang)++ result = await prompt_composer.compose(+ "review the vosk wake provider", session=workspace, terminal_name="Kai"+ )+ assert result.composed_by == "fallback"+ assert "timed out" in result.note+ assert "vosk" in result.text.lower()+++def test_the_spoken_budget_is_about_a_second() -> None:+ """BridgeVoice lands a transcript in ~1 s. That is the cap, not a goal+ the CLI rescue is allowed to overshoot."""+ assert prompt_composer.FAST_BUDGET_S <= 1.5+ assert prompt_composer.HEDGE_AFTER_API_S <= prompt_composer.FAST_BUDGET_S+++async def test_compose_busy_is_true_while_a_writer_runs(+ workspace: _Session, monkeypatch: pytest.MonkeyPatch+) -> None:+ """Recaps read this flag so they do not spawn a CLI mid-brief."""+ _prime(workspace)+ seen: list[bool] = []++ async def _capture(**_kwargs: object) -> str:+ seen.append(prompt_composer.compose_busy())+ return "## Task\nDo it."++ monkeypatch.setattr(prompt_composer, "_llm_compose", _capture)+ assert prompt_composer.compose_busy() is False+ await prompt_composer.compose(+ "review the vosk wake provider", session=workspace, terminal_name="Kai"+ )+ assert seen == [True]+ assert prompt_composer.compose_busy() is Falseasync def test_no_quality_writer_degrades_openly(@@ -318,10 +374,7 @@ async def test_a_prompt_ending_on_a_reference_is_repaired(_prime(workspace)async def _trailing(**_kwargs: object) -> str:- return (- "## Task\nReview it.\n\n"- "## Key files\n- `@jarvis/plugins/wake/vosk_kws_provider.py`"- )+ return "## Task\nReview it.\n\n## Key files\n- `@jarvis/plugins/wake/vosk_kws_provider.py`"monkeypatch.setattr(prompt_composer, "_llm_compose", _trailing)@@ -351,9 +404,7 @@ async def test_an_explicitly_pinned_brain_is_used(prompt_composer, "_resolve_writer", lambda: pytest.fail("should not resolve"))- await prompt_composer.compose(- "review it", session=workspace, terminal_name="Kai", brain=pinned- )+ await prompt_composer.compose("review it", session=workspace, terminal_name="Kai", brain=pinned)assert seen["brain"] is pinneddiff --git a/tests/unit/agentic_ide/test_writer_rescue.py b/tests/unit/agentic_ide/test_writer_rescue.pyindex 5e6bca852d..6a7ceb1c9e 100644--- a/tests/unit/agentic_ide/test_writer_rescue.py+++ b/tests/unit/agentic_ide/test_writer_rescue.py@@ -8,6 +8,7 @@ was a key whose prepayment credits were gone, so every composition for daysended on the raw spoken sentence while a signed-in subscription sat unused.That is the single-provider brick AP-22 forbids."""+from __future__ import annotationsfrom types import SimpleNamespace@@ -49,6 +50,21 @@ def test_the_rung_that_died_is_never_retried(monkeypatch: pytest.MonkeyPatch) ->assert source == "api"+def test_rescue_can_skip_the_subscription(monkeypatch: pytest.MonkeyPatch) -> None:+ """Spoken compose never pays a CLI cold start as insurance."""+ monkeypatch.setattr(writer, "_load_config", lambda: _cfg())+ monkeypatch.setattr(writer, "_tool_model", lambda cfg: "tool-brain")+ monkeypatch.setattr(writer, "_subscription", lambda cfg, timeout: SimpleNamespace(name="codex"))+ monkeypatch.setattr(writer, "_quality", lambda cfg: "api-brain")++ brain, source = writer.resolve_rescue_writer(+ exclude=("tool_model:grok", "api"), allow_subscription=False+ )++ assert brain is None+ assert source == ""++def test_the_subscription_is_the_last_rescue(monkeypatch: pytest.MonkeyPatch) -> None:"""Both API-side rungs dead: only now is a coding CLI's cold start worthpaying — the user is still waiting, and a rescue that starts on the slowest