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(persona): label the assistant's lines by the name the user gave it (#577)

Ruben Lütkef7d7c31e1de7
diff --git a/jarvis/agent_chat/jarvis_harness.py b/jarvis/agent_chat/jarvis_harness.py
index 1c8fac9bca..7304beb509 100644
--- a/jarvis/agent_chat/jarvis_harness.py
+++ b/jarvis/agent_chat/jarvis_harness.py
@@ -464,7 +464,12 @@ async def identity_prompt(
def render_transcript(
history: list[dict[str, Any]], *, max_chars: int = TRANSCRIPT_MAX_CHARS
) -> str:
- """The chat's log as plain prose, newest last, cut to ``max_chars`` from the front."""
+ """The chat's log as plain prose, newest last, cut to ``max_chars`` from the front.
+
+ The model reading this IS the second speaker, whatever it is called (the
+ assistant on the app's own chat, a named agent on its seat), so its own
+ lines are labelled ``You``. Nothing parses these labels.
+ """
from jarvis.agent_chat.runner_api import messages_from_events
lines: list[str] = []
@@ -476,7 +481,7 @@ def render_transcript(
elif message.role == "assistant":
text = _prose(message.content)
if text.strip():
- lines.append(f"Jarvis: {text.strip()}")
+ lines.append(f"You: {text.strip()}")
out = "\n\n".join(lines)
if len(out) > max_chars:
out = "…" + out[-max_chars:]
diff --git a/jarvis/agentic_ide/conversation.py b/jarvis/agentic_ide/conversation.py
index 523ddf35e3..8f8b2e2d37 100644
--- a/jarvis/agentic_ide/conversation.py
+++ b/jarvis/agentic_ide/conversation.py
@@ -41,7 +41,9 @@ MAX_MESSAGES = 4
#: so the bound has to clear it rather than cut it in half.
MAX_MESSAGE_CHARS = 1000
-_ROLE_LABELS = {"user": "The user", "assistant": "Jarvis"}
+#: How the two speakers are named to the writer. Read by a model only; the
+#: assistant's own name is the user's choice and plays no part in a brief.
+_ROLE_LABELS = {"user": "The user", "assistant": "The assistant"}
def _bounded(text: str) -> str:
diff --git a/jarvis/agentic_ide/prompt_composer.py b/jarvis/agentic_ide/prompt_composer.py
index b2197a7ff3..7b7f4af4b3 100644
--- a/jarvis/agentic_ide/prompt_composer.py
+++ b/jarvis/agentic_ide/prompt_composer.py
@@ -96,6 +96,8 @@ from pathlib import Path
from loguru import logger
+from jarvis.brain.assistant_name import DEFAULT_ASSISTANT_NAME
+
from .file_index import cached_index
from .session import MAX_PROMPT_CHARS, sanitize_prompt
from .task_kind import (
@@ -344,9 +346,14 @@ ProgressSink = Callable[[ComposeNotice], None]
and must not be able to await anything, let alone the pane it describes."""
-def print_notice(notice: ComposeNotice) -> None:
+def print_notice(notice: ComposeNotice, *, speaker: str = "") -> None:
"""Put one notice where the user is actually looking. Never raises.
+ ``speaker`` is the name the user gave the assistant; it leads the printed
+ line. A caller without a config leaves it empty and the neutral name is
+ used. The line is read by a person watching a terminal and parsed by
+ nothing.
+
Standard output when there is one — that is the terminal a headless install
and a ``--dev`` run are both watched from. Under the tray build there is no
console at all (``pythonw.exe`` gives the process no stdout), so the line
@@ -359,7 +366,7 @@ def print_notice(notice: ComposeNotice) -> None:
logger.info("Agentic IDE composer: {}", notice.message)
return
try:
- stream.write(f"Jarvis: {notice.message}\n")
+ stream.write(f"{speaker.strip() or DEFAULT_ASSISTANT_NAME}: {notice.message}\n")
stream.flush()
except (OSError, ValueError, AttributeError, UnicodeError):
# A closed, detached or non-decodable stream is not a failure of the
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.py
index 74f65464ef..74640ce786 100644
--- a/jarvis/brain/manager.py
+++ b/jarvis/brain/manager.py
@@ -7752,7 +7752,9 @@ class BrainManager:
# Keep the stdout/log line a headless install watches, exactly as
# the REST route does — the socket beat is an addition to it.
- print_notice(notice)
+ print_notice(
+ notice, speaker=resolve_assistant_name(getattr(self, "_config", None))
+ )
try:
loop = asyncio.get_running_loop()
except RuntimeError: # pragma: no cover - no loop, no clients
@@ -9114,7 +9116,7 @@ class BrainManager:
history = tuple(getattr(self, "_history", None) or ())
lines: list[str] = []
for message in history[-_CU_CONTEXT_MAX_MESSAGES:]:
- role = "User" if getattr(message, "role", "") == "user" else "Jarvis"
+ role = "User" if getattr(message, "role", "") == "user" else "Assistant"
content = " ".join(str(getattr(message, "content", "") or "").split())
if not content:
continue
diff --git a/jarvis/sessions/formatter.py b/jarvis/sessions/formatter.py
index 7e950fff9e..ec5ef3fd6f 100644
--- a/jarvis/sessions/formatter.py
+++ b/jarvis/sessions/formatter.py
@@ -11,6 +11,8 @@ from collections.abc import Iterable
from dataclasses import dataclass, replace
from datetime import UTC, datetime
+from jarvis.brain.assistant_name import DEFAULT_ASSISTANT_NAME
+
from .constants import SPOKEN_KIND_WITHHELD
from .diagnostics import diagnostic_value, session_termination_diagnostics
from .models import VoiceEventRow, VoiceSessionRow, VoiceTurnRow
@@ -129,12 +131,24 @@ def _fold_withheld_twins(items: list[_JarvisOutput]) -> list[_JarvisOutput]:
return result
+def _speaker(assistant_name: str | None) -> str:
+ """The label of the assistant's lines: the caller's name for it, else the neutral one."""
+ return " ".join((assistant_name or "").split()) or DEFAULT_ASSISTANT_NAME
+
+
def format_session_markdown(
session: VoiceSessionRow,
turns: Iterable[VoiceTurnRow],
events: Iterable[VoiceEventRow] | None = None,
+ *,
+ assistant_name: str | None = None,
) -> str:
- """Render a structured transcript for rich copy-and-paste targets."""
+ """Render a structured transcript for rich copy-and-paste targets.
+
+ ``assistant_name`` labels the assistant's lines. The export is read by a
+ person and parsed by nothing, so it carries the name the user chose.
+ """
+ speaker = _speaker(assistant_name)
turns_list = list(turns)
events_list = list(events or [])
events_map = _events_by_turn(events_list)
@@ -198,7 +212,7 @@ def format_session_markdown(
if t.cost_usd > 0:
meta_parts.append(f"${t.cost_usd:.4f}")
if meta_parts:
- lines.append(f"**🧠 Jarvis dachte:** {' · '.join(meta_parts)}")
+ lines.append(f"**🧠 {speaker} dachte:** {' · '.join(meta_parts)}")
lines.append("")
if t.tool_calls:
@@ -222,7 +236,7 @@ def format_session_markdown(
voice_note = (
f" · _Voice (requested, not verified): `{spoken_by}`_"
)
- lines.append(f"**🔊 Jarvis sagte** _(de={t.jarvis_lang})_{voice_note}")
+ lines.append(f"**🔊 {speaker} sagte** _(de={t.jarvis_lang})_{voice_note}")
lines.append("")
for output in outputs:
if output.is_reply and t.awaiting_confirmation:
@@ -263,13 +277,17 @@ def format_session_plain(
session: VoiceSessionRow,
turns: Iterable[VoiceTurnRow],
events: Iterable[VoiceEventRow] | None = None,
+ *,
+ assistant_name: str | None = None,
) -> str:
"""Render dialogue plus the session's final termination evidence.
The body uses speaker labels, without Markdown, emojis, or per-turn
cost/model telemetry. Supplemental audible phrases remain dialogue;
termination diagnostics are labelled as not spoken after the dialogue.
+ ``assistant_name`` labels the assistant's lines (see the markdown form).
"""
+ speaker = _speaker(assistant_name)
turns_list = list(turns)
events_list = list(events or [])
events_map = _events_by_turn(events_list)
@@ -305,7 +323,7 @@ def format_session_plain(
for output in _jarvis_outputs_for_turn(t, events_map.get(t.id, [])):
# The clean transcript reads as dialogue — the technical ``detail``
# (exit codes, harness reasons) stays out to avoid AI-slop.
- blocks.append(f"Jarvis: {output.text}")
+ blocks.append(f"{speaker}: {output.text}")
if blocks:
lines.append("\n\n".join(blocks))
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index ed6ebc1ca4..faef981951 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -5105,11 +5105,17 @@ async def terminal_prompt(
# nobody asked to send are noise.
beat_bus = getattr(request.app.state, "bus", None)
on_progress = None
+ from jarvis.brain.assistant_name import resolve_assistant_name
+
+ # The stdout line leads with the name the user gave the assistant.
+ _speaker_name = resolve_assistant_name(
+ getattr(request.app.state, "config", None)
+ )
if beat_bus is not None and not req.dry_run:
from jarvis.core.events import AgenticIdeComposeProgress
def _publish_beat(notice: ComposeNotice) -> None:
- print_notice(notice)
+ print_notice(notice, speaker=_speaker_name)
task = asyncio.get_running_loop().create_task(
beat_bus.publish(
AgenticIdeComposeProgress(
diff --git a/jarvis/ui/web/sessions_routes.py b/jarvis/ui/web/sessions_routes.py
index 6e5c5e9a8f..d77399bea2 100644
--- a/jarvis/ui/web/sessions_routes.py
+++ b/jarvis/ui/web/sessions_routes.py
@@ -52,6 +52,18 @@ router = APIRouter(prefix="/api/sessions", tags=["sessions"])
# ----------------------------------------------------------------------
+def _assistant_name(request: Request) -> str:
+ """What the user calls the assistant: the speaker label of an export.
+
+ Resolved per request from the wake word, so a renamed assistant shows up
+ in the next export without a restart.
+ """
+ from jarvis.brain.assistant_name import DEFAULT_ASSISTANT_NAME, resolve_assistant_name
+
+ config = getattr(request.app.state, "config", None)
+ return resolve_assistant_name(config) if config is not None else DEFAULT_ASSISTANT_NAME
+
+
def _require_store(request: Request) -> SessionStore:
store: SessionStore | None = getattr(request.app.state, "session_store", None)
if store is None:
@@ -143,10 +155,14 @@ def export_session(
events = store.get_events(session_id)
if export_format == "markdown":
- body = format_session_markdown(session, turns, events)
+ body = format_session_markdown(
+ session, turns, events, assistant_name=_assistant_name(request)
+ )
return PlainTextResponse(content=body, media_type="text/markdown; charset=utf-8")
if export_format == "plain":
- body = format_session_plain(session, turns, events)
+ body = format_session_plain(
+ session, turns, events, assistant_name=_assistant_name(request)
+ )
return PlainTextResponse(content=body, media_type="text/plain; charset=utf-8")
# JSON variant — we return the full detail payload.
detail = SessionDetail(session=session, turns=turns, events=events)
@@ -200,9 +216,13 @@ async def save_session_to_downloads(
# Render the format body.
if export_format == "markdown":
- body = format_session_markdown(session, turns, events)
+ body = format_session_markdown(
+ session, turns, events, assistant_name=_assistant_name(request)
+ )
elif export_format == "plain":
- body = format_session_plain(session, turns, events)
+ body = format_session_plain(
+ session, turns, events, assistant_name=_assistant_name(request)
+ )
else:
detail = SessionDetail(session=session, turns=turns, events=events)
body = detail.model_dump_json(indent=2)
@@ -286,9 +306,13 @@ async def open_session_with(
events = store.get_events(session_id)
if export_format == "markdown":
- rendered = format_session_markdown(session, turns, events)
+ rendered = format_session_markdown(
+ session, turns, events, assistant_name=_assistant_name(request)
+ )
elif export_format == "plain":
- rendered = format_session_plain(session, turns, events)
+ rendered = format_session_plain(
+ session, turns, events, assistant_name=_assistant_name(request)
+ )
else:
detail = SessionDetail(session=session, turns=turns, events=events)
rendered = detail.model_dump_json(indent=2)
diff --git a/tests/unit/agent_chat/test_jarvis_identity.py b/tests/unit/agent_chat/test_jarvis_identity.py
index c4681f8367..7a2860485d 100644
--- a/tests/unit/agent_chat/test_jarvis_identity.py
+++ b/tests/unit/agent_chat/test_jarvis_identity.py
@@ -58,7 +58,7 @@ async def test_identity_has_the_jarvis_layers_the_transcript_and_the_addendum(mo
user_text="and now?", history=_history(), resume=None
)
assert text.index("YOU ARE GEORGE") < text.index("Date: today")
- assert "Person: what did we decide?" in text and "Jarvis: To ship on Friday." in text
+ assert "Person: what did we decide?" in text and "You: To ship on Friday." in text
assert text.endswith(jarvis_harness.SYSTEM_PREAMBLE)
assert brain.asked_with == ["and now?"], "the wiki context is pulled for THIS turn's text"
diff --git a/tests/unit/agentic_ide/test_compose_notice_speaker.py b/tests/unit/agentic_ide/test_compose_notice_speaker.py
new file mode 100644
index 0000000000..48ae1b31e3
--- /dev/null
+++ b/tests/unit/agentic_ide/test_compose_notice_speaker.py
@@ -0,0 +1,20 @@
+"""The composer's progress line on stdout names the assistant the user's way."""
+
+from __future__ import annotations
+
+from jarvis.agentic_ide.prompt_composer import STAGE_START, ComposeNotice, print_notice
+from jarvis.brain.assistant_name import DEFAULT_ASSISTANT_NAME
+
+_NOTICE = ComposeNotice(stage=STAGE_START, message="Writing the brief for T1.", terminal="T1")
+
+
+def test_the_line_leads_with_the_name_the_user_gave_the_assistant(capsys) -> None:
+ print_notice(_NOTICE, speaker="George")
+ assert capsys.readouterr().out == "George: Writing the brief for T1.\n"
+
+
+def test_without_a_name_the_line_uses_the_neutral_one(capsys) -> None:
+ print_notice(_NOTICE)
+ print_notice(_NOTICE, speaker=" ")
+ line = f"{DEFAULT_ASSISTANT_NAME}: Writing the brief for T1.\n"
+ assert capsys.readouterr().out == line * 2
diff --git a/tests/unit/agentic_ide/test_prompt_handover_and_backreference.py b/tests/unit/agentic_ide/test_prompt_handover_and_backreference.py
index cad83fc372..78f50b8013 100644
--- a/tests/unit/agentic_ide/test_prompt_handover_and_backreference.py
+++ b/tests/unit/agentic_ide/test_prompt_handover_and_backreference.py
@@ -193,7 +193,7 @@ def test_render_labels_who_said_what():
assert out.splitlines() == [
"The user: how do we sharpen it?",
- "Jarvis: Four levers.",
+ "The assistant: Four levers.",
]
diff --git a/tests/unit/sessions/test_formatter.py b/tests/unit/sessions/test_formatter.py
index 315069110e..2204ea0684 100644
--- a/tests/unit/sessions/test_formatter.py
+++ b/tests/unit/sessions/test_formatter.py
@@ -205,7 +205,7 @@ def test_plain_has_no_telemetry() -> None:
def test_plain_uses_speaker_labels() -> None:
out = format_session_plain(_session(), _example_turns())
assert "Du: Kannst du für mich bitte einmal meine Gmails durchsuchen?" in out
- assert "Jarvis: Einen Augenblick." in out
+ assert "Assistant: Einen Augenblick." in out
def test_plain_header_is_a_single_slim_line() -> None:
@@ -228,9 +228,9 @@ def test_plain_preserves_umlauts() -> None:
def test_plain_turn_without_reply_renders_cleanly() -> None:
out = format_session_plain(_session(), _example_turns())
assert "Du: auflegen" in out
- # The reply-less turn must not emit a dangling empty "Jarvis:" line.
- assert "Jarvis: \n" not in out
- assert not out.rstrip().endswith("Jarvis:")
+ # The reply-less turn must not emit a dangling empty "Assistant:" line.
+ assert "Assistant: \n" not in out
+ assert not out.rstrip().endswith("Assistant:")
def test_plain_empty_session_is_graceful() -> None:
@@ -306,7 +306,7 @@ def test_plain_includes_spoken_phrases_as_clean_dialogue() -> None:
spoken = [_spoken("turn-0", "Das hat zu lange gedauert.", "timeout")]
out = format_session_plain(_session(), turns, spoken)
# The voiced phrase reads as part of the dialogue — no kind tag, no slop.
- assert "Jarvis: Das hat zu lange gedauert." in out
+ assert "Assistant: Das hat zu lange gedauert." in out
assert "timeout" not in out # plain export stays clean of meta-tags
@@ -326,8 +326,8 @@ def test_plain_orders_preamble_before_final_response_by_timestamp() -> None:
),
]
out = format_session_plain(_session(), turns, events)
- preamble_pos = out.index("Jarvis: Ich rufe deine heutigen Termine")
- final_pos = out.index("Jarvis: Ich konnte das gerade nicht abrufen.")
+ preamble_pos = out.index("Assistant: Ich rufe deine heutigen Termine")
+ final_pos = out.index("Assistant: Ich konnte das gerade nicht abrufen.")
assert preamble_pos < final_pos
@@ -340,7 +340,7 @@ def test_plain_prefers_confirmed_reply_over_generated_model_text() -> None:
out = format_session_plain(_session(), turns, events)
- assert "Jarvis: This sentence reached playback." in out
+ assert "Assistant: This sentence reached playback." in out
assert "Generated text that was not played." not in out
@@ -356,8 +356,8 @@ def test_plain_orders_late_readback_after_final_response() -> None:
),
]
out = format_session_plain(_session(), turns, events)
- final_pos = out.index("Jarvis: Ich kuemmere mich darum.")
- readback_pos = out.index("Jarvis: Die Recherche ist fertig.")
+ final_pos = out.index("Assistant: Ich kuemmere mich darum.")
+ readback_pos = out.index("Assistant: Die Recherche ist fertig.")
assert final_pos < readback_pos
@@ -406,7 +406,7 @@ def test_plain_folds_withheld_twin_into_the_spoken_reply() -> None:
out = format_session_plain(_session(), turns, events)
- assert out.count(f"Jarvis: {answer}") == 1
+ assert out.count(f"Assistant: {answer}") == 1
def test_markdown_keeps_the_abort_detail_when_folding_the_withheld_twin() -> None:
@@ -445,7 +445,7 @@ def test_withheld_event_without_a_spoken_twin_still_renders() -> None:
out = format_session_plain(_session(), turns, events)
- assert "Jarvis: Der Anfang der Antwort, der abgebrochen wurde." in out
+ assert "Assistant: Der Anfang der Antwort, der abgebrochen wurde." in out
# --- direct tests for the small pure helpers ---------------------------------
@@ -523,3 +523,20 @@ def test_pretty_voice_mode(mode: str, expected: str) -> None:
def test_pretty_voice_mode_empty() -> None:
assert _pretty_voice_mode("") == "Unknown"
+
+
+def test_the_assistants_lines_carry_the_name_the_user_gave_it() -> None:
+ plain = format_session_plain(_session(), _example_turns(), assistant_name="George")
+ assert "George: Einen Augenblick." in plain
+ assert "Assistant:" not in plain and "Jarvis" not in plain
+
+ markdown = format_session_markdown(_session(), _example_turns(), assistant_name="George")
+ assert "George sagte" in markdown # i18n-allow: the export's own German label
+ assert "Jarvis" not in markdown
+
+
+def test_a_blank_name_falls_back_to_the_neutral_label() -> None:
+ from jarvis.brain.assistant_name import DEFAULT_ASSISTANT_NAME
+
+ out = format_session_plain(_session(), _example_turns(), assistant_name=" ")
+ assert f"{DEFAULT_ASSISTANT_NAME}: Einen Augenblick." in out
diff --git a/tests/unit/sessions/test_recorder_realtime.py b/tests/unit/sessions/test_recorder_realtime.py
index 22928f276b..e5bfd8d306 100644
--- a/tests/unit/sessions/test_recorder_realtime.py
+++ b/tests/unit/sessions/test_recorder_realtime.py
@@ -605,8 +605,8 @@ async def test_realtime_progress_bridge_survives_into_plain_export(tmp_path) ->
store.get_turns("audible-bridge"),
events,
)
- progress_at = exported.index("Jarvis: I'm still working on it.")
- reply_at = exported.index("Jarvis: The current figure is 42.")
+ progress_at = exported.index("Assistant: I'm still working on it.")
+ reply_at = exported.index("Assistant: The current figure is 42.")
assert progress_at < reply_at
finally:
store.close()
diff --git a/tests/unit/ui/web/test_sessions_routes.py b/tests/unit/ui/web/test_sessions_routes.py
index d6a18ca2a6..d52f19bc0f 100644
--- a/tests/unit/ui/web/test_sessions_routes.py
+++ b/tests/unit/ui/web/test_sessions_routes.py
@@ -136,9 +136,9 @@ def test_save_session_to_downloads_uses_events_for_plain_export(tmp_path, monkey
content = saved.read_text(encoding="utf-8")
assert "Modus: Pipeline" in content.splitlines()[0]
assert "Ended by: hotkey" in content
- assert "Jarvis: Preamble first." in content
- assert content.index("Jarvis: Preamble first.") < content.index(
- "Jarvis: Final answer."
+ assert "Assistant: Preamble first." in content
+ assert content.index("Assistant: Preamble first.") < content.index(
+ "Assistant: Final answer."
)
finally:
store.close()
@@ -230,3 +230,28 @@ def test_latest_turn_returns_404_when_no_user_transcript_exists(tmp_path) -> Non
assert response.json()["detail"] == "user-turn-not-found"
finally:
store.close()
+
+
+def test_an_export_labels_the_assistant_by_its_wake_word_name(tmp_path) -> None:
+ from types import SimpleNamespace
+
+ store = SessionStore(tmp_path / "sessions.db")
+ store.open()
+ try:
+ _seed_session(store)
+ app = FastAPI()
+ app.include_router(sessions_routes.router)
+ app.state.session_store = store
+ app.state.config = SimpleNamespace(
+ trigger=SimpleNamespace(wake_word=SimpleNamespace(phrase="Hey George"))
+ )
+
+ with TestClient(app) as client:
+ plain = client.get("/api/sessions/s1/export?format=plain").text
+ markdown = client.get("/api/sessions/s1/export?format=markdown").text
+
+ assert "George: Final answer." in plain
+ assert "George sagte" in markdown # i18n-allow: the export's own German label
+ assert "Jarvis" not in plain and "Jarvis" not in markdown
+ finally:
+ store.close()