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
feat(agentic-ide): compose briefed markdown prompts from real code context
Ruben Lütkebe111f432581
diff --git a/jarvis/agentic_ide/prompt_composer.py b/jarvis/agentic_ide/prompt_composer.pyindex 87de5562f5..1607900cbe 100644--- a/jarvis/agentic_ide/prompt_composer.py+++ b/jarvis/agentic_ide/prompt_composer.py@@ -9,31 +9,53 @@ by asking what you meant. What the user asked for is that *Jarvis* does theprompt engineering: it knows the repo, so it turns that sentence into a briefedtask with the relevant files already attached.+The prompt's SHAPE lives in ``prompt_blueprint`` and the guardrails it carries+are chosen by ``task_kind``; this module is the orchestration around them:+which files to offer, what to read of them, which model writes it, and what+happens when any of that is unavailable.+What the composed prompt contains, and why each part earns its place:-* **The task, as an imperative.** Fillers, the addressing clause ("tell Kai- to …") and speech artefacts are gone; what remains is what to do.-* **File references in the agent's own syntax** (``@path``). Both supported- CLIs read ``@`` as "pull this file into context", which removes the agent's- entire opening round of blind searching. Paths come from the workspace file- index — never invented, and every one is verified to exist before it ships.-* **A short workspace line** (stack, branch) when it is not obvious, so the- agent does not re-derive it.+* **A briefed task in markdown**, not a rephrased sentence. Opus 5 and Fable 5+ both work best from a complete specification given up front, so the prompt+ states the task, why it matters, the files, the scope bound, and what done+ looks like — dropping any section it cannot ground rather than padding it.+* **File references in the agent's own syntax** (``@path``), inside the Key+ files list with a reason each. Both supported CLIs read ``@`` as "pull this+ file into context", which removes the agent's entire opening round of blind+ searching. Paths come from the workspace file index — never invented, and+ every one is verified to exist before it ships.+* **Real symbol names**, because the writer reads a bounded outline of those+ files first (``code_skeleton``). Without it the prompt can only say "the+ ranking logic" where it could say ``_fuse_ranked()``.+* **The repository's own house rules**, so ``## Done when`` cites the project's+ actual test command instead of inventing a plausible one.Two-layer construction, because the product must work for a downloader with noAPI key at all (§3):-1. **Composed** — one bounded call to the frontier chain- (``resolve_frontier_brain``: key-aware, crosses provider families, AP-22).- It gets the utterance, the project profile and the candidate files, and- returns the prompt.-2. **Deterministic fallback** — regex cleanup plus the same file references,- used when no provider is reachable, the call fails, times out, or comes back+1. **Composed** — one bounded call to ``resolve_quality_brain``. Deliberately+ NOT the full frontier chain: that chain ends in small, fast models so a core+ path never dies, and a prompt written by one of those looks fine while being+ materially worse. Here the output IS the product, so a chain that cannot+ reach a capable model returns nothing and we fall to layer 2 openly.+2. **Deterministic fallback** — the same markdown skeleton filled by regex,+ used when no provider qualifies, the call fails, times out, or comes backempty. It is *always* better than the raw transcript, so the feature neverdepends on a model being available.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 (deliberate trade, maintainer decision 2026-07-25).** An earlier+change routed this through the router-tier model the voice turn already held,+because a rewrite took 1-3 s there against 7-8 s on the deep tier. That+optimised the wrong axis: the maintainer's instruction was that these prompts+must be accurate about the codebase and "must not be dumb", and chose the+slower, better prompt explicitly. Reading file outlines costs more still. So+the composer takes its time and the bound below is generous — what must never+happen is a silent demotion to a weaker model, because nobody inspects a prompt+that looks fine."""from __future__ import annotations@@ -48,41 +70,20 @@ from .file_index import cached_indexfrom .session import MAX_PROMPT_CHARS, sanitize_prompt# The composer is not on the voice hot path the way an ack is, but the user is-# waiting to hear "sent to Kai" — past a few seconds it feels broken. On timeout-# the deterministic prompt ships, so this bound costs quality, never delivery.+# waiting to hear "sent to Kai". On timeout the deterministic prompt ships, so+# this bound costs quality, never delivery.## Measured 2026-07-25 on the live chain: a fast router-tier model answers in-# 1-3 s, while the deep frontier tier (a thinking model) took 7-8 s for the same-# rewrite. Callers that hold a fast brain pass it in; 12 s leaves room for the-# slow path to still succeed rather than silently demoting every composition to-# the regex fallback, which an 8 s bound did.-COMPOSE_TIMEOUT_S = 12.0+# 1-3 s and the deep tier took 7-8 s for the same rewrite. Reading file outlines+# adds to that. The bound is therefore generous rather than tight: a bound that+# expires mid-composition does not produce a faster good prompt, it produces the+# regex one — which an earlier 8 s bound did routinely.+COMPOSE_TIMEOUT_S = 20.0# 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-_SYSTEM_PROMPT = """\-You turn a spoken instruction into a precise prompt for a coding agent (Claude \-Code / Codex) that is already running inside the user's repository.--Rules:-- Output ONLY the prompt text. No preamble, no explanation, no quotes, no \-markdown fences.-- Write it as a direct instruction to the coding agent, in the imperative.-- Preserve every constraint, file, symbol and intent the user expressed. Do not \-invent requirements, scope, or acceptance criteria they did not state.-- Remove speech artefacts: filler words, false starts, self-corrections, and \-the clause that addressed the agent by name ("tell Kai to ...").-- If the user was vague, keep it vague — state the goal and let the agent \-investigate. Never fabricate specifics to make the prompt look complete.-- Reference relevant files with @path syntax on their own line at the end, \-using ONLY paths from the candidate list you are given. Omit the line entirely \-if no candidate is clearly relevant.-- Write the prompt in the same language the user spoke.-- Keep it under 1200 characters.-"""-# Speech artefacts the deterministic layer removes. Matching *input vocabulary*# in the supported locales — these are the words people actually say while# thinking, not prose.@@ -173,15 +174,6 @@ def _file_candidates(session, instruction: str, limit: int) -> list[str]: # noqreturn _existing(session.folder, index.suggest(instruction, limit=limit))-def _render_fallback(instruction: str, files: list[str]) -> str:- body = _clean_speech(instruction)- if not body:- body = " ".join((instruction or "").split())- if files:- body = f"{body}\n\n{' '.join('@' + f for f in files)}"- return body--def _extract_referenced(text: str) -> list[str]:"""``@path`` tokens in a composed prompt, in order of appearance."""seen: list[str] = []@@ -192,66 +184,69 @@ def _extract_referenced(text: str) -> list[str]:return seen-async def _llm_compose(- *,- utterance: str,- instruction: str,- session, # noqa: ANN001 - Session, avoid an import cycle- terminal_name: str,- agent_display: str,- candidates: list[str],- brain=None, # noqa: ANN001 - Brain, avoid an import cycle-) -> str:- """One bounded call that writes the prompt.-- ``brain`` lets a caller that already holds a warm, FAST model pass it in —- the router-tier brain the voice turn is using anyway. That matters: measured- on the live chain, a rewrite took 1-3 s there against 7-8 s on the deep- frontier tier, which is a thinking model doing far more work than rephrasing- one sentence needs.-- Without one (the REST/CLI path, which holds no brain), it falls back to- ``resolve_frontier_brain`` — the shared key-aware chain that follows the- user's own configuration and crosses provider families when the primary is- dead (AP-21 / AP-22), rather than a pinned provider that would brick this- for every downloader with a different key.+def _resolve_writer(): # noqa: ANN202 - Brain | None, avoid an import cycle+ """The model that writes prompts, or None when only fast tiers are up.++ Uses ``resolve_quality_brain`` rather than the full frontier chain: the+ latter is built so a core path never dies and therefore ends in small, fast+ models. Here the OUTPUT is the product, and a brief written by a mini model+ is worse in a way nobody notices — it reads perfectly well. Returning None+ lets the caller degrade to the deterministic prompt and say so."""- from jarvis.core.protocols import BrainMessage, BrainRequest+ from jarvis.brain.resolver import resolve_quality_brain+ from jarvis.core.config import load_config- if brain is None:- from jarvis.brain.resolver import resolve_frontier_brain- from jarvis.core.config import load_config+ try:+ return resolve_quality_brain(load_config())+ except Exception: # noqa: BLE001 - resolution must never break a turn+ logger.info("Agentic IDE prompt writer could not be resolved", exc_info=True)+ return None- brain = resolve_frontier_brain(load_config())- profile_lines = "\n".join(session.profile.summary_lines())- candidate_block = (- "\n".join(f"- {c}" for c in candidates)- if candidates- else "(no candidate files matched — omit the @ line)"- )- user_block = (- f"The user is talking to the coding agent {agent_display} running in a "- f"terminal they call {terminal_name}.\n\n"- f"WORKSPACE\n{profile_lines}\n\n"- f"CANDIDATE FILES (repo-relative; use only these in @ references)\n"- f"{candidate_block}\n\n"- f"WHAT THE USER SAID (verbatim speech transcript)\n{utterance}\n\n"- f"THE INSTRUCTION PART, WITH THE ADDRESSING REMOVED\n{instruction}\n\n"- f"Write the prompt now."- )+# How much of the repository's agent instructions to carry. Enough for the+# headline conventions; far short of pasting a whole CLAUDE.md into every call.+_HOUSE_RULES_CHARS = 1200+++def _house_rules(session) -> str: # noqa: ANN001 - Session, avoid an import cycle+ """The repository's own conventions, so ``## Done when`` stays grounded.++ Without this the writer has to guess a test command, and a guessed one is+ exactly the kind of invented acceptance criterion the blueprint forbids.+ """+ from .code_skeleton import skeleton_for++ names = list(getattr(session.profile, "instruction_files", None) or [])+ for name in names:+ text = skeleton_for(session.folder, name, max_chars=_HOUSE_RULES_CHARS)+ if text:+ return f"From {name}:\n{text}"+ return ""+++async def _llm_compose(+ *,+ brain, # noqa: ANN001 - Brain, avoid an import cycle+ system_prompt: str,+ user_block: str,+) -> str:+ """One bounded call that writes the prompt."""+ from jarvis.core.protocols import BrainMessage, BrainRequestrequest = BrainRequest(messages=(BrainMessage(role="user", content=user_block),),- system=_SYSTEM_PROMPT,+ system=system_prompt,# Deterministic rewriting, not creative writing: the prompt must carry# the user's intent, so temperature stays low.temperature=0.2,- max_tokens=800,+ # A structured brief with five sections needs room; 800 truncated it.+ max_tokens=2000,stream=True,- # A prompt rewrite needs no internal reasoning budget, and on- # thinking-heavy models it would eat max_tokens and truncate the answer.- reasoning_effort="none",+ # Turning a spoken sentence plus a set of file outlines into a briefed+ # task is judgement work, not transcription. The documentation is+ # explicit that thinking disabled performs worse than a modest effort at+ # comparable cost, and "none" is what made this a rephraser.+ reasoning_effort="medium",)chunks: list[str] = []async for delta in brain.complete(request):@@ -260,6 +255,44 @@ async def _llm_compose(return "".join(chunks).strip()+async def _compose_once(+ *,+ brain, # noqa: ANN001 - Brain, avoid an import cycle+ session, # noqa: ANN001 - Session, avoid an import cycle+ said: str,+ base_instruction: str,+ terminal_name: str,+ agent_display: str,+ candidates: list[str],+ kind: str,+) -> str:+ """Read the candidate files, then make the one writing call.++ File reading runs in a worker thread: it is disk IO on a path a voice turn+ is waiting on, and the whole call already sits under ``COMPOSE_TIMEOUT_S``.+ """+ from . import prompt_blueprint as blueprint+ from .code_skeleton import skeletons as read_skeletons++ outlines = await asyncio.to_thread(read_skeletons, session.folder, candidates)+ house_rules = await asyncio.to_thread(_house_rules, session)++ return await _llm_compose(+ brain=brain,+ system_prompt=blueprint.system_prompt(kind),+ user_block=blueprint.user_block(+ utterance=said,+ instruction=base_instruction,+ terminal_name=terminal_name,+ agent_display=agent_display,+ profile_lines=session.profile.summary_lines(),+ candidates=candidates,+ skeletons=outlines,+ house_rules=house_rules,+ ),+ )++def _strip_wrapper(text: str) -> str:"""Remove a fenced block or surrounding quotes a model may have added."""stripped = text.strip()@@ -284,70 +317,87 @@ async def compose() -> ComposedPrompt:"""Build the prompt for ``terminal_name`` out of what the user said.- Pass ``brain`` when you already hold a fast one (see ``_llm_compose``);- omitting it resolves the shared key-aware chain.+ ``brain`` pins the writing model explicitly. Leave it None — the default+ resolves a quality-tier model and degrades openly when none is reachable.+ Passing a fast model here trades prompt accuracy for a few seconds, which+ is the trade the maintainer decided against on 2026-07-25.Never raises: every failure path lands on the deterministic prompt, because- "the agent got a slightly rougher prompt" is a far better outcome than "your+ "the agent got a rougher prompt" is a far better outcome than "yourinstruction vanished"."""+ from . import prompt_blueprint as blueprint+ from .task_kind import classify+said = (utterance or "").strip()- base_instruction = (instruction or said).strip()+ base_instruction = _clean_speech(instruction or said) or (instruction or said).strip()if not said:return ComposedPrompt(text="", composed_by="raw", note="empty instruction")candidates = _file_candidates(session, base_instruction or said, max_files * 2)- if not use_llm:- text = _render_fallback(base_instruction, candidates[:max_files])+ def _deterministic(composed_by: str, note: str = "") -> ComposedPrompt:+ chosen = candidates[:max_files]return ComposedPrompt(- text=sanitize_prompt(text)[:MAX_PROMPT_CHARS],- files=candidates[:max_files],- composed_by="raw",+ text=sanitize_prompt(+ blueprint.render_fallback(base_instruction, chosen), keep_newlines=True+ )[:MAX_PROMPT_CHARS],+ files=chosen,+ composed_by=composed_by,+ note=note,)- note = ""+ if not use_llm:+ return _deterministic("raw")++ writer = brain if brain is not None else _resolve_writer()+ if writer is None:+ # Deliberately NOT falling through to whatever model is left: see the+ # module docstring. Plain and honest beats polished and quietly worse.+ return _deterministic("fallback", "no quality-tier provider reachable")+try:composed = await asyncio.wait_for(- _llm_compose(- utterance=said,- instruction=base_instruction,+ _compose_once(+ brain=writer,session=session,+ said=said,+ base_instruction=base_instruction,terminal_name=terminal_name,agent_display=agent_display,candidates=candidates,- brain=brain,+ kind=classify(base_instruction),),timeout=COMPOSE_TIMEOUT_S,)composed = _strip_wrapper(composed)except TimeoutError:- composed, note = "", f"composer timed out after {COMPOSE_TIMEOUT_S:g}s"+ return _deterministic(+ "fallback", f"composer timed out after {COMPOSE_TIMEOUT_S:g}s"+ )except Exception as exc: # noqa: BLE001 - any provider failure degrades- composed, note = "", f"composer unavailable ({type(exc).__name__})"logger.info("Agentic IDE prompt composer fell back: {}", exc)-- if composed:- # Keep only the references that survive an existence check — the model- # may echo a candidate that was renamed, or invent one outright.- referenced = _existing(session.folder, _extract_referenced(composed))- dropped = [r for r in _extract_referenced(composed) if r not in referenced]- for bad in dropped:- composed = composed.replace(f"@{bad}", bad)- final = sanitize_prompt(composed)[:MAX_PROMPT_CHARS]- if final:- return ComposedPrompt(- text=final, files=referenced, composed_by="llm", note=note- )- note = note or "composer returned nothing usable"-- chosen = candidates[:max_files]- return ComposedPrompt(- text=sanitize_prompt(_render_fallback(base_instruction, chosen))[:MAX_PROMPT_CHARS],- files=chosen,- composed_by="fallback",- note=note or "no provider reachable",- )+ return _deterministic("fallback", f"composer unavailable ({type(exc).__name__})")++ if not composed:+ return _deterministic("fallback", "composer returned nothing usable")++ # 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+ # costs the agent a turn; the bare path costs it nothing.+ referenced = _existing(session.folder, _extract_referenced(composed))+ for bad in (r for r in _extract_referenced(composed) if r not in referenced):+ composed = composed.replace(f"@{bad}", bad)++ if blueprint.ends_on_reference(composed):+ # A trailing @path or /command holds the completion popup open, and the+ # Enter that follows picks a suggestion instead of submitting.+ composed = f"{composed}\n\nStart there; search further if needed."++ final = sanitize_prompt(composed, keep_newlines=True)[:MAX_PROMPT_CHARS]+ if not final:+ return _deterministic("fallback", "composer returned nothing usable")+ return ComposedPrompt(text=final, files=referenced, composed_by="llm")__all__ = [diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex b864058829..8a1a1c00b1 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -5599,26 +5599,6 @@ class BrainManager:)return f"Öffne {label}." if is_de else f"Opening {label}." # i18n-allow- def _composer_brain(self) -> Brain | None:- """The warm, fast brain the Agentic-IDE prompt composer should use.-- Rewriting one spoken sentence into a prompt is a small job, and the user- is waiting to hear it landed. This hands the composer the same fast-tier- model the router turn already resolved (cached in ``_brain_cache``, so- no construction cost) instead of letting it fall back to the deep chain,- which on the live measurement took 7-8 s for the identical rewrite.-- Returns ``None`` when no fast brain can be resolved — the composer then- falls back to the shared key-aware chain, and past that to its regex- layer, so the instruction is delivered either way.- """- try:- primary = self._config.brain.primary- return self._get_brain(primary, self._fast_model(primary))- except Exception: # noqa: BLE001 - the composer has its own fallbacks- log.debug("Agentic IDE composer brain unavailable", exc_info=True)- return None-async def _run_agentic_ide_fast_path(self,user_text: str,@@ -5707,10 +5687,13 @@ class BrainManager:terminal_name=term.name,agent_display=AGENT_DISPLAY.get(term.agent, term.agent),instruction=found.instruction,- # The user is waiting to hear "sent to Kai", so the rewrite runs on- # the FAST tier this turn is already using — measured 1-3 s against- # 7-8 s on the deep chain the composer would otherwise resolve.- brain=self._composer_brain(),+ # No brain is pinned here on purpose. An earlier version handed the+ # composer this turn's FAST router model to save 4-5 s, but that+ # optimised the wrong axis: the prompt is what the coding agent then+ # works from for minutes, and the maintainer's decision on+ # 2026-07-25 was explicitly for the better prompt over the quicker+ # handoff. The composer resolves a quality-tier model itself and+ # degrades to its deterministic prompt when none is reachable.)if not composed.text:return Nonediff --git a/tests/unit/agentic_ide/test_prompt_composer.py b/tests/unit/agentic_ide/test_prompt_composer.pyindex dbe6cb5d78..3648ffe264 100644--- a/tests/unit/agentic_ide/test_prompt_composer.py+++ b/tests/unit/agentic_ide/test_prompt_composer.py@@ -191,7 +191,9 @@ async def test_an_index_that_is_not_ready_yet_does_not_block(file_index.reset_cache()async def _echo(**kwargs: object) -> str:- assert kwargs["candidates"] == []+ # With no index there are no candidates, and the writer is told so+ # rather than left to guess a path.+ assert "no candidate files matched" in str(kwargs["user_block"])return "Review the wake word detection."monkeypatch.setattr(prompt_composer, "_llm_compose", _echo)@@ -201,3 +203,138 @@ async def test_an_index_that_is_not_ready_yet_does_not_block(# The instruction goes out; with no index there is nothing to attach.assert "wake" in result.text.lower()assert result.files == []+++# ------------------------------------------------------- structured output+async def test_the_composed_prompt_is_markdown(+ workspace: _Session, monkeypatch: pytest.MonkeyPatch+) -> None:+ _prime(workspace)++ async def _brief(**_kwargs: object) -> str:+ return (+ "## Task\nReview the wake provider.\n\n"+ "## Key files\n- `@jarvis/plugins/wake/vosk_kws_provider.py` - the provider"+ )++ monkeypatch.setattr(prompt_composer, "_llm_compose", _brief)++ result = await prompt_composer.compose(+ "review the vosk wake provider", session=workspace, terminal_name="Kai"+ )++ assert result.composed_by == "llm"+ assert result.text.startswith("## Task")+ assert "\n" in result.text, "the line structure must survive sanitisation"+++async def test_the_writer_gets_the_rules_for_the_detected_kind(+ workspace: _Session, monkeypatch: pytest.MonkeyPatch+) -> None:+ _prime(workspace)+ seen: dict[str, str] = {}++ async def _capture(**kwargs: object) -> str:+ seen["system"] = str(kwargs["system_prompt"])+ return "## Task\nDo it."++ monkeypatch.setattr(prompt_composer, "_llm_compose", _capture)++ await prompt_composer.compose(+ "review the wake provider", session=workspace, terminal_name="Kai"+ )++ assert "REVIEW task" in seen["system"]+ assert "IMPLEMENTATION task" not in seen["system"]+++async def test_the_writer_is_shown_an_outline_of_the_candidate_files(+ 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"+ )+ provider.write_text(+ '"""Vosk keyword spotting."""\n\n\n'+ "def candidate_shape_ok(span: float) -> bool:\n return True\n",+ encoding="utf-8",+ )+ _prime(workspace)+ seen: dict[str, str] = {}++ async def _capture(**kwargs: object) -> str:+ seen["user"] = str(kwargs["user_block"])+ return "## Task\nDo it."++ monkeypatch.setattr(prompt_composer, "_llm_compose", _capture)++ await prompt_composer.compose(+ "review the vosk wake provider", session=workspace, terminal_name="Kai"+ )++ assert "candidate_shape_ok" in seen["user"]+ assert "Vosk keyword spotting." in seen["user"]+++async def test_no_quality_writer_degrades_openly(+ workspace: _Session, monkeypatch: pytest.MonkeyPatch+) -> None:+ """Rather than silently demoting to whatever small model is left."""+ _prime(workspace)+ monkeypatch.setattr(prompt_composer, "_resolve_writer", lambda: None)++ result = await prompt_composer.compose(+ "review the vosk wake provider", session=workspace, terminal_name="Kai"+ )++ assert result.composed_by == "fallback"+ assert "quality-tier" in result.note+ assert result.text.startswith("## Task")+++async def test_a_prompt_ending_on_a_reference_is_repaired(+ workspace: _Session, monkeypatch: pytest.MonkeyPatch+) -> None:+ """A trailing @path holds the completion popup open and never submits."""+ _prime(workspace)++ async def _trailing(**_kwargs: object) -> str:+ return (+ "## Task\nReview it.\n\n"+ "## Key files\n- `@jarvis/plugins/wake/vosk_kws_provider.py`"+ )++ monkeypatch.setattr(prompt_composer, "_llm_compose", _trailing)++ result = await prompt_composer.compose(+ "review the vosk wake provider", session=workspace, terminal_name="Kai"+ )++ from jarvis.agentic_ide.prompt_blueprint import ends_on_reference++ assert not ends_on_reference(result.text)+++async def test_an_explicitly_pinned_brain_is_used(+ workspace: _Session, monkeypatch: pytest.MonkeyPatch+) -> None:+ """The parameter still works for a caller that means it."""+ _prime(workspace)+ pinned = object()+ seen: dict[str, object] = {}++ async def _capture(**kwargs: object) -> str:+ seen["brain"] = kwargs["brain"]+ return "## Task\nDo it."++ monkeypatch.setattr(prompt_composer, "_llm_compose", _capture)+ monkeypatch.setattr(+ prompt_composer, "_resolve_writer", lambda: pytest.fail("should not resolve")+ )++ await prompt_composer.compose(+ "review it", session=workspace, terminal_name="Kai", brain=pinned+ )++ assert seen["brain"] is pinned