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): composed prompts describe the code instead of summarising it
Ruben Lütked2d3681fe1a4
diff --git a/jarvis/agentic_ide/code_skeleton.py b/jarvis/agentic_ide/code_skeleton.pyindex 8154b1bfa9..3faa4b7e9b 100644--- a/jarvis/agentic_ide/code_skeleton.py+++ b/jarvis/agentic_ide/code_skeleton.py@@ -29,12 +29,15 @@ import refrom collections.abc import Sequencefrom pathlib import Path-# Bounds. Three files is what a spoken instruction realistically points at,-# and the character budgets keep the composer's own context well clear of the-# point where a provider would start truncating.-MAX_SKELETON_FILES = 3-MAX_CHARS_PER_FILE = 6_000-MAX_CHARS_TOTAL = 20_000+# Bounds. Raised from 3/6k/20k after the first live compositions came back at+# a third of the allowed prompt length: the writer can only describe what it+# was shown, so a thin outline budget caps prompt depth no matter how the+# instructions are worded. Five files covers a feature's surface rather than+# just its entry point, and the budgets still leave a frontier model's context+# far from the point where a provider would truncate.+MAX_SKELETON_FILES = 5+MAX_CHARS_PER_FILE = 9_000+MAX_CHARS_TOTAL = 34_000# Never read more than this off disk before outlining — a "source file" in an# arbitrary folder can be a 200 MB generated blob.diff --git a/jarvis/agentic_ide/prompt_blueprint.py b/jarvis/agentic_ide/prompt_blueprint.pyindex bcd30853f8..9ae9ae4427 100644--- a/jarvis/agentic_ide/prompt_blueprint.py+++ b/jarvis/agentic_ide/prompt_blueprint.py@@ -43,24 +43,42 @@ from .task_kind import (KIND_REVIEW,)-# Long enough for a real brief with five sections; short enough that the pane's-# input box does not become the whole screen. MAX_PROMPT_CHARS (4000) remains-# the hard transport cap above this.-MAX_BODY_CHARS = 3000+# The hard ceiling. MAX_PROMPT_CHARS is the transport cap above this.+# Set above what real briefs measure (2865-3713 across three live runs) rather+# than at it: a limit the writer breaches on every ordinary composition teaches+# it that the limits in this prompt are approximate, and the ones that matter —+# invent nothing, never end on a reference — are not.+MAX_BODY_CHARS = 4500++# What a GOOD prompt weighs, which is a different question from what is allowed.+# The first version stated only the ceiling, and three live compositions came+# back at 549 / 865 / 904 characters — under a third of the budget. A model+# reads "keep it under N" as "be brief", so the target has to be said out loud.+# The floor is the load-bearing half: below it, context the agent will have to+# rediscover for itself has almost certainly been left out.+TARGET_MIN_CHARS = 1800+TARGET_MAX_CHARS = 3200_SKELETON = """\## Task-<one to three imperative sentences: what to do>+<what to do, in the imperative - two to five sentences. Name the concrete+symbols, files and behaviours involved; do not compress it to a headline>## Why this matters-<the intent behind the request - ONLY when it is known or clearly derivable>+<the intent behind the request, and what breaks or improves for the user -+ONLY when it is known or clearly derivable>++## How it works today+<the current behaviour of the code being changed, in real symbol names: which+function does what, who calls it, which state it keeps. This is the part that+saves the agent an entire round of rediscovery>## Key files-- `@path/to/file` - what it contributes to this task-- `@path/to/other` - what it contributes+- `@path/to/file` - what lives here and which part of it matters, named+- `@path/to/other` - same, specifically## Scope-<what is in, and what is explicitly out>+<what is in, what is explicitly out, and the constraints that apply>## Done when- <an observable outcome>@@ -82,13 +100,32 @@ fence, no quotes.- `## Task` is mandatory. Every other section is OPTIONAL: omit a section \entirely when you have nothing grounded to put in it. Never pad a section to \fill the shape.-- Invent nothing. No requirement, constraint, scope or success criterion the \-user did not state and the workspace does not establish. `## Done when` may \-only contain what the user asked for or what the repository itself determines \-(its test command, its lint gate). If neither gives you anything, omit it.++DESCRIBING is not INVENTING, and the difference decides how good this prompt \+is. Keep these apart:+- INVENTING is forbidden: a requirement, a constraint, a scope boundary or a \+success criterion the user did not state and the workspace does not establish. \+`## Done when` may only contain what the user asked for or what the repository \+itself determines (its test command, its lint gate). If neither gives you \+anything, omit the section.+- DESCRIBING is wanted, in detail: what the code in the file outlines actually \+does, which function is called from where, what the workspace profile says \+about the stack and conventions, which constraint the repository's own house \+rules impose. None of that is invention - it is context you were given and the \+agent would otherwise spend its first minutes rediscovering. Spend words here.++Be thorough. Aim for {TARGET_MIN_CHARS}-{TARGET_MAX_CHARS} characters. A prompt \+under 800 characters has almost certainly dropped context you were handed: go \+back and say what the relevant code does today, name the symbols involved, and \+state the constraints that apply. Length must come from substance - concrete \+file, symbol and behaviour detail - never from filler, restating the task in \+other words, or hedging.- Reference files with `@path` inside a `## Key files` list item, using ONLY \-paths from the candidate list you are given, each with a short reason. Omit \-the section when no candidate is clearly relevant.+paths from the candidate list you are given. Say what each file holds and \+which function or class in it is the relevant one - "the ranking pipeline" is \+worth far less to the agent than "`_fuse_ranked()`, which merges the ranked \+lists before the relevance gate". Omit the section when no candidate is \+clearly relevant.- Never end the prompt on an `@path` or a `/command`: a trailing reference \leaves the agent's completion popup open and the prompt is never submitted.- Write in ENGLISH, whatever language the user spoke. The agent works in a \@@ -96,11 +133,17 @@ repository whose code, comments and commits are English.- Preserve every constraint, file, symbol and intent the user expressed. \Remove speech artefacts: filler words, false starts, self-corrections, and the \clause addressing the agent by name.-- Keep the whole prompt under {MAX_BODY_CHARS} characters.-- Do not ask the agent to narrate, echo or explain its internal reasoning.-- Do not ask the agent to verify, re-check or double-check its own work \-afterwards. It already does that unprompted, and asking for it makes the \-result worse, not better.\+- Never exceed {MAX_BODY_CHARS} characters.++Two subjects must not appear in the prompt AT ALL - not as a requirement and \+not as a prohibition. Say nothing about either; the agent handles both \+correctly on its own, and raising them measurably degrades its work:+- Verification. No "verify your work", no "double-check", and equally no "do \+not double-check". Write neither.+- Its own reasoning. No "explain your reasoning", "show your thinking" or \+"narrate your steps", and equally no instruction forbidding those. Write \+neither. (A line like "Do not narrate your internal reasoning" in the finished \+prompt is this rule being LEAKED instead of followed - it is a defect.)\"""# Per-kind guardrails. Short on purpose: a short coherent set is followed, a@@ -108,8 +151,14 @@ result worse, not better.\_KIND_RULES: dict[str, str] = {KIND_IMPLEMENT: """\This is an IMPLEMENTATION task. Specific to it:-- Give the complete specification up front, so the agent can work start to \-finish without coming back with questions.+- Give the COMPLETE specification up front, so the agent can work start to \+finish without coming back with questions. This is the kind that most deserves \+length: describe the behaviour that must exist afterwards, the shape it should \+take, where it belongs in the existing code, and how it should behave when \+things go wrong.+- `## How it works today` is close to mandatory here. Name the function the \+change lands in, what it currently does, and who calls it - the agent cannot \+fit a change into code it has to find first.- `## Scope` matters here. Bound the work: name what is out of scope, and say \that surrounding cleanup, unrequested refactors, speculative abstractions and \defensive handling for impossible cases are not wanted.@@ -121,8 +170,13 @@ This is a REVIEW task. Specific to it:on. Filtering happens afterwards, in a separate pass. Never instruct the agent \to report only serious issues, or to apply a high bar, or to err on the side \of silence - it will follow that literally and stay quiet about real defects.+- Say what the code is FOR and what would count as a defect in it. A reviewer \+who knows that the ranking decides which results reach a spoken answer reviews \+differently from one who sees a sorting function.- Name what to weigh the code against when the workspace establishes it: the \-repository's own conventions, its anti-pattern register, its tests.+repository's own conventions, its anti-pattern register, its tests. List the \+specific dimensions worth a pass - correctness, edge cases, error handling, \+test coverage, and whatever the code's own purpose makes risky.- The deliverable is the findings. Do not ask for fixes in the same prompt.\""",KIND_INVESTIGATE: """\@@ -132,20 +186,27 @@ would confirm it. Say so explicitly.- Say that the agent should report the finding and stop, and should not apply \a fix before the user has seen it.- Carry across every symptom, error message, timing and reproduction detail \-the user gave. Those are the evidence; do not summarise them away.\+the user gave, VERBATIM. Those are the evidence; do not summarise them away.+- Describe the path the code takes through the area under suspicion, in real \+symbol names, and name the places where it could plausibly go wrong. Giving \+the agent the map is not the same as giving it the answer.\""",KIND_QUESTION: """\This is a QUESTION. Specific to it:- The deliverable is an answer grounded in the code, not a change. Say that \the agent should read the relevant files before answering and should not \change anything.-- Keep it short. A question rarely needs `## Scope` or `## Done when`; omit \-them unless the user set a real boundary.\+- Be specific about what is actually being asked and what a useful answer \+would cover, so the agent does not return either a one-liner or an essay.+- A question rarely needs `## Scope` or `## Done when`; omit them unless the \+user set a real boundary.\""",KIND_NEUTRAL: """\The kind of work is not clearly determined. Stay with what the user said:- State the task as they framed it, and bound the scope to it - no \surrounding cleanup, no unrequested refactors.+- Still describe the relevant code as it stands today. Being unsure which KIND \+of work this is is no reason to hand over less context.- If they described a problem rather than asking for a change, say that the \deliverable is the assessment.\""",@@ -240,9 +301,44 @@ def ends_on_reference(text: str) -> bool:return bool(_TRAILING_TOKEN_RE.search((text or "").rstrip()))+# Punctuation a finished sentence ends on.+_SENTENCE_ENDINGS = (".", "!", "?", ":", ";", "`", ")", "]", '"', "'", "…")+# Line shapes that legitimately end without punctuation: list items, headings,+# table rows, fenced-block delimiters.+_STRUCTURAL_PREFIXES = ("-", "*", "+", "#", ">", "|", "```")+++def looks_truncated(text: str) -> bool:+ """True when a composed prompt stopped mid-sentence.++ On a thinking model the token budget covers the reasoning as well as the+ answer, so an under-provisioned budget produces a brief that simply stops —+ measured live, one ended on "...to find" and was still handed over as a+ finished prompt. That is worse than the plain deterministic prompt, because+ it READS as complete: the agent starts work on an instruction whose second+ half was never written.++ Deliberately narrow. It only fires when the last line is running prose that+ ends without punctuation. A list item ("- `@a.py` - the ranking pipeline")+ and a heading are complete lines that happen to carry no full stop, and+ treating them as damage would degrade good briefs. A false positive costs+ one rougher prompt; a missed truncation sends an agent off with half a task.+ """+ body = (text or "").strip()+ if not body:+ return True+ last = body.splitlines()[-1].strip()+ if not last or last.startswith(_STRUCTURAL_PREFIXES):+ return False+ return not last.endswith(_SENTENCE_ENDINGS)++__all__ = ["MAX_BODY_CHARS",+ "TARGET_MAX_CHARS",+ "TARGET_MIN_CHARS","ends_on_reference",+ "looks_truncated","render_fallback","system_prompt","user_block",diff --git a/tests/unit/agentic_ide/test_prompt_blueprint.py b/tests/unit/agentic_ide/test_prompt_blueprint.pyindex 93e2991155..95f1aaed40 100644--- a/tests/unit/agentic_ide/test_prompt_blueprint.py+++ b/tests/unit/agentic_ide/test_prompt_blueprint.py@@ -14,7 +14,10 @@ import pytestfrom jarvis.agentic_ide.prompt_blueprint import (MAX_BODY_CHARS,+ TARGET_MAX_CHARS,+ TARGET_MIN_CHARS,ends_on_reference,+ looks_truncated,render_fallback,system_prompt,user_block,@@ -51,23 +54,33 @@ def test_every_kind_demands_the_markdown_skeleton(kind):@pytest.mark.parametrize("kind", _ALL_KINDS)-def test_every_kind_forbids_a_verification_ritual(kind):- """Opus 5 and Fable 5 both over-verify when a prompt tells them to verify."""- lowered = system_prompt(kind).lower()- assert "do not ask the agent to verify" in lowered+def test_every_kind_bans_the_two_leak_prone_subjects_outright(kind):+ """Verification and reasoning must not appear at all — in EITHER direction.++ The first version said "do not ask the agent to verify", and a live+ composition dutifully wrote "Do not narrate your internal reasoning or+ double-check your own work" INTO the finished prompt: the rule leaked+ instead of being followed. Banning the subject rather than one direction of+ it is what closes that.+ """+ text = system_prompt(kind)+ assert "must not appear in the prompt AT ALL" in text+ assert "not as a requirement and not as a prohibition" in text.replace("\n", " ")+ assert "Write neither." in text@pytest.mark.parametrize("kind", _ALL_KINDS)-def test_every_kind_forbids_asking_the_agent_to_narrate_its_reasoning(kind):- """A reasoning-echo instruction can trigger a refusal on Fable 5."""- lowered = system_prompt(kind).lower()- assert "internal reasoning" in lowered- assert "do not ask the agent to narrate" in lowered+def test_every_kind_names_the_leak_as_a_defect(kind):+ """Showing the exact leaked line is what makes the rule recognisable."""+ assert "being LEAKED instead of followed" in system_prompt(kind)@pytest.mark.parametrize("kind", _ALL_KINDS)def test_every_kind_forbids_inventing_requirements(kind):- assert "invent nothing" in system_prompt(kind).lower()+ """Still the hard rule — it just no longer suppresses description with it."""+ text = system_prompt(kind)+ assert "INVENTING is forbidden" in text+ assert "the user did not state and the workspace does not establish" in text@pytest.mark.parametrize("kind", _ALL_KINDS)@@ -209,5 +222,73 @@ def test_ends_on_reference_detects_the_failure_shape():assert not ends_on_reference("")-def test_body_bound_is_three_thousand():- assert MAX_BODY_CHARS == 3000+def test_the_target_length_sits_inside_the_hard_ceiling():+ """The ceiling says what is allowed; the target says what is good.++ Stating only the ceiling produced 549/865/904-character prompts against a+ 3000 budget — a model reads "under N" as "be brief".+ """+ assert TARGET_MIN_CHARS < TARGET_MAX_CHARS < MAX_BODY_CHARS++[email protected]("kind", _ALL_KINDS)+def test_every_kind_states_the_target_length_not_only_the_ceiling(kind):+ text = system_prompt(kind)+ assert str(TARGET_MIN_CHARS) in text+ assert str(TARGET_MAX_CHARS) in text+ assert "Be thorough" in text++[email protected]("kind", _ALL_KINDS)+def test_every_kind_separates_describing_from_inventing(kind):+ """The anti-invention rule was suppressing legitimate description too."""+ text = system_prompt(kind)+ assert "DESCRIBING is not INVENTING" in text+ assert "INVENTING is forbidden" in text+ assert "DESCRIBING is wanted" in text++[email protected]("kind", _ALL_KINDS)+def test_every_kind_offers_the_current_behaviour_section(kind):+ """Describing today's code is what saves the agent a discovery round."""+ assert "## How it works today" in system_prompt(kind)+++def test_no_kind_tells_the_writer_to_keep_it_short():+ """Brevity instructions are what produced the thin prompts."""+ for kind in _ALL_KINDS:+ assert "Keep it short" not in system_prompt(kind)+++# ------------------------------------------------------ truncation guard+def test_a_brief_that_stops_mid_sentence_is_recognised():+ """Measured live: an investigation brief ended on "...to find" and was+ handed over as finished. Half a brief reads as a whole one."""+ assert looks_truncated("## Task\nTrace the path through the pipeline to find")+++def test_a_finished_brief_is_not_flagged():+ assert not looks_truncated("## Task\nReview the ranking pipeline.")+ assert not looks_truncated("## Task\nDo it.\n\n## Key files\n- `@a.py` - here")+ assert not looks_truncated("## Task\nCheck this:")+++def test_a_list_item_without_a_full_stop_is_not_truncation():+ """The common shape of a finished Key files section — must not fire."""+ assert not looks_truncated("## Task\nDo it.\n\n## Key files\n- `@a.py` - ranking")+ assert not looks_truncated("## Task\nDo it.\n\n## Done when\n- The tests pass")+++def test_a_heading_left_dangling_is_not_treated_as_damage():+ """Structural lines carry no punctuation by nature; only prose is judged."""+ assert not looks_truncated("## Task\nDo it.\n\n## Scope")+++def test_unformatted_prose_that_finishes_properly_is_accepted():+ """Formatting is the blueprint's job to demand, not this guard's to police."""+ assert not looks_truncated("Review the ranking pipeline and report back.")+++def test_empty_output_counts_as_truncated():+ assert looks_truncated("")+ assert looks_truncated(" ")diff --git a/tests/unit/agentic_ide/test_prompt_composer.py b/tests/unit/agentic_ide/test_prompt_composer.pyindex 3648ffe264..9ebba79815 100644--- a/tests/unit/agentic_ide/test_prompt_composer.py+++ b/tests/unit/agentic_ide/test_prompt_composer.py@@ -121,8 +121,10 @@ async def test_invented_file_references_are_stripped(async def _hallucinate(**_kwargs: object) -> str:return (- "Review the wake word detection. "- "@jarvis/plugins/wake/vosk_kws_provider.py @jarvis/does/not/exist.py"+ "## Task\nReview the wake word detection.\n\n"+ "## Key files\n"+ "- `@jarvis/plugins/wake/vosk_kws_provider.py` - the provider\n"+ "- `@jarvis/does/not/exist.py` - invented by the model")monkeypatch.setattr(prompt_composer, "_llm_compose", _hallucinate)