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(realtime): delegate directive names on-screen control; history window 8 -> 20

Ruben Lütke393464c01330
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index 5a9fc03b0b..f3f70d994d 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -77,17 +77,24 @@ _DELEGATE_NATIVE_BOUNDARY_WAIT_S = 1.0
# end. Keep the classic speech-pipeline acknowledgement timing unchanged; this
# longer threshold belongs only to the realtime provider bridge.
_DELEGATE_BRIDGE_DELAY_S = 6.0
-_DELEGATE_HISTORY_MAX_MESSAGES = 8
+# 20 messages, not 8: a failed screen action typically costs the user several
+# correction turns, and each background completion adds a context note. With 8,
+# the original task was trimmed out exactly when the recovery turn needed it
+# (live forensic 2026-07-15 08:00: the final mission posted a placeholder
+# announcement because the announce request had just left the window).
+_DELEGATE_HISTORY_MAX_MESSAGES = 20
_DELEGATE_HISTORY_MAX_CHARS = 1_200
_DELEGATE_DECLARATION: dict[str, Any] = {
"name": "jarvis_action",
"description": (
"Execute an action for the user through the Jarvis action system: "
- "open apps or views, change settings, control the computer, manage "
- "files, start background research or coding missions, read or write "
- "the user's private Wiki memory, and inspect the current MCP, CLI, "
- "tool, integration, configuration, or system state. Also call this "
- "to relay the user's answer to a pending confirmation question."
+ "open apps or views, change settings, control the computer on screen "
+ "(click, type, and navigate inside any application window until the "
+ "task is finished), manage files, start background research or coding "
+ "missions, read or write the user's private Wiki memory, and inspect "
+ "the current MCP, CLI, tool, integration, configuration, or system "
+ "state. Also call this to relay the user's answer to a pending "
+ "confirmation question."
),
"parameters": {
"type": "object",
@@ -115,6 +122,13 @@ _DELEGATE_ROLE_DIRECTIVE = (
"cannot see any of it yourself, so guessing is always wrong. Answer from "
"your own knowledge only for general world knowledge and ordinary social "
"chat. "
+ "The action system physically operates the user's computer on screen: it "
+ "opens apps and clicks, types, and navigates inside any application "
+ "window until a multi-step task is finished end to end. Never tell the "
+ "user that you lack a tool, an API, access, or permission for something "
+ "in their world, and never propose manual workarounds, scripts, or "
+ "keyboard tricks instead of acting — call jarvis_action (again, with the "
+ "user's correction folded in) and let the action system do it. "
"Never announce that you are going to look something up, check, read, "
"fetch, open, save, enter, or do anything: either call jarvis_action in the "
"same response, or do not say it at all. An announcement without a function "
diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.py
index 1557e4d4bc..94d5d86a1d 100644
--- a/tests/unit/realtime/test_session.py
+++ b/tests/unit/realtime/test_session.py
@@ -1775,6 +1775,58 @@ async def test_delegate_mode_declares_single_action_function():
assert "MCPs" in provider.opened_with.instructions
+async def test_delegate_directive_names_screen_control_and_forbids_capability_denial():
+ """The live model must know its on-screen reach and never deny it.
+
+ Live forensic 2026-07-15 07:59: asked why a screen action failed, the
+ model claimed it had no API access and offered to type via 'a script or
+ the keyboard' — inventing capability gaps instead of calling
+ jarvis_action. The directive must name Computer-Use-style screen control
+ explicitly and forbid claiming a missing tool/API/access for anything in
+ the user's world.
+ """
+ provider = FakeProvider([RealtimeEvent(type="turn_complete")])
+ sess = _session(provider, brain=FakeBrain())
+
+ await sess.handle_control({"type": "audio_start", "sample_rate": 16_000})
+ await sess.wait_finished()
+ await sess.end(reason="test")
+
+ instructions = provider.opened_with.instructions
+ assert "clicks, types, and navigates" in instructions
+ assert "Never tell the user that you lack" in instructions
+ declaration = next(
+ d for d in provider.opened_with.tools if d["name"] == "jarvis_action"
+ )
+ assert "click, type, and navigate" in declaration["description"]
+
+
+def test_delegate_history_keeps_a_task_five_exchanges_back():
+ """The window must survive a correction sequence plus announcements.
+
+ Live forensic 2026-07-15 08:00: after four correction turns and two
+ background-completion notes, the original announce request had just been
+ trimmed out of the 8-message window — the final mission posted a
+ placeholder announcement instead of the requested content.
+ """
+ sess = _session(FakeProvider([]), brain=FakeBrain())
+ sess._remember_delegate_turn(
+ "Announce the live event on my Personal Jarvis server.", "On it."
+ )
+ # One failure completion + four correction exchanges follow, mirroring
+ # the live session's shape.
+ sess._remember_delegate_turn("", "[Trusted background completion]\nIt failed.")
+ for index in range(4):
+ sess._remember_delegate_turn(f"correction {index}", f"reply {index}")
+ sess._remember_delegate_turn("", "[Trusted background completion]\nDone-ish.")
+
+ contents = [str(m.content) for m in sess._delegate_history]
+ assert any("Personal Jarvis" in c for c in contents), (
+ f"the original task must survive the correction sequence: {contents}"
+ )
+
+
@pytest.mark.asyncio
@pytest.mark.parametrize(
"utterance",