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(voice): capture fresh appshots instead of reusing old images
rubenluetke10-beep9463a7c1f9bf
diff --git a/jarvis/appshot/service.py b/jarvis/appshot/service.pyindex 968ac44f51..f800654c80 100644--- a/jarvis/appshot/service.py+++ b/jarvis/appshot/service.py@@ -27,9 +27,10 @@ Scope = Literal["window", "region"]#: Trusted framing in front of the untrusted screen evidence block.APPSHOT_PREAMBLE = (- "APPSHOT: the user deliberately captured their front window to give you "- "context. Use it for their request. If they only asked you to take an "- "appshot, confirm it in one short sentence and ask what they want to know."+ "APPSHOT: a captured snapshot of the user's front window, supplied as context. "+ "It shows the window at capture time, not a live view. Use it when asked about "+ "this image. A request to take another appshot requires a fresh successful "+ "take_appshot call; this earlier image is not evidence of a new capture.")diff --git a/jarvis/live/config.py b/jarvis/live/config.pyindex 82bddc820c..83fb5ff31c 100644--- a/jarvis/live/config.py+++ b/jarvis/live/config.py@@ -112,6 +112,16 @@ class LiveConfig(BaseModel):+ AGENT_BRIEF_RULE+ " "+ COMPUTER_CONTROL_RULES+ + " Appshots: when asked to take an appshot, screenshot, or look at the "+ "current screen, call take_appshot for a fresh capture, even if an earlier "+ "image is already in context. This tool owns the capture animation and "+ "privacy filtering. Use scope window by default; scope screen only for "+ "an explicit whole-screen request. Use computer for operating the desktop. "+ "An attached image is a static snapshot, never proof that you performed a "+ "new capture. Describe an existing supplied image when asked about that "+ "image. Confirm a requested new capture only after take_appshot succeeds "+ "in this request; if it fails, explain the failure without describing the "+ "old image as current. "+ " "+ self.backend_instructions),diff --git a/jarvis/live/native.py b/jarvis/live/native.pyindex 4edd4227ff..20c7277b53 100644--- a/jarvis/live/native.py+++ b/jarvis/live/native.py@@ -40,7 +40,7 @@ _DUPLEX_REFUSAL_FALLBACK = "The selected voice engine cannot take a call right n_TOOL_DEADLINE_S = VOICE_TOOL_BUDGET_S# Session built-ins of ``LiveTools``: always declared, whatever the budget._SESSION_TOOLS = frozenset(- {"end_call", "discover_tools", "call_tool", "confirm_action", "computer"}+ {"end_call", "discover_tools", "call_tool", "confirm_action", "computer", "take_appshot"})# Under a declaration budget (a provider's ``tool_declaration_budget_tokens``# or ``[voice].realtime_tool_declaration_budget_tokens``, the smaller wins), atdiff --git a/jarvis/live/subscription.py b/jarvis/live/subscription.pyindex 2ccafcfa54..28b50e604d 100644--- a/jarvis/live/subscription.py+++ b/jarvis/live/subscription.py@@ -376,14 +376,23 @@ class SubscriptionLiveVoiceSession(LiveVoiceSession):if not latest:returnrequest_item = {"role": "user", "content": [{"type": "input_text", "text": latest}]}- items.append(request_item)history_prefix = [request_item]if not application_event:if self._pending_images:self._image_context = self._pending_imagesself._pending_images = []if self._image_context:- items.append({"role": "user", "content": self._image_context})+ items.append({"role": "user", "content": [+ {+ "type": "input_text",+ "text": "[Earlier screen snapshot, not a new capture for the "+ "request below. A new appshot request requires take_appshot.]",+ },+ *self._image_context,+ ]})+ # Put the actual request after retained image context. A previous+ # appshot's framing must not override a request for a fresh capture.+ items.append(request_item)backend = self._config.live.backend_config(language=self._language,tools=self._tools.declarations(defer_catalog=True),diff --git a/jarvis/live/tools.py b/jarvis/live/tools.pyindex 9ade3c5d25..1683cb62a6 100644--- a/jarvis/live/tools.py+++ b/jarvis/live/tools.py@@ -51,7 +51,7 @@ _REQUEST_TEXT_CHARS = 1200# Declared before every other tool so the size budget never drops them._PRIORITY_TOOLS = frozenset({"workspace-orchestrate", "find-app-action", "run-app-action"})# Declared under its canonical name in every mode (see ``declarations``).-_DIRECT_TOOL = "computer"+_DIRECT_TOOLS = frozenset({"computer", "take_appshot"})_APPROVAL_NEXT_STEP = ("Ask the user to approve this action. After an explicit yes, call confirm_action ""directly (not through call_tool) with this approval_id. A yes is never a hang-up."@@ -172,16 +172,18 @@ class LiveTools:["approval_id"],),]- # The screen is operated in many short rounds (ADR-0038): declare the- # computer tool under its own name instead of behind discover/call_tool.- computer = next((d for d in self.catalog() if d.name == _DIRECT_TOOL), None)- if computer is not None:+ # Keep capture available even with a deferred catalog. Otherwise a live+ # model may reuse an old image or choose computer instead of the appshot+ # path that owns privacy filtering, the shutter effect and the receipt.+ for descriptor in self.catalog():+ if descriptor.name not in _DIRECT_TOOLS:+ continuedefinitions.append({"type": "function",- "name": computer.name,- "description": computer.description,- "parameters": computer.input_schema,+ "name": descriptor.name,+ "description": descriptor.description,+ "parameters": descriptor.input_schema,})if defer_catalog:@@ -205,7 +207,7 @@ class LiveTools:# or brief a coding agent (live 2026-10-01).ordered = sorted(self.catalog(), key=lambda d: (d.name not in _PRIORITY_TOOLS, d.name))for descriptor in ordered:- if descriptor.name == _DIRECT_TOOL:+ if descriptor.name in _DIRECT_TOOLS:continuealias = "jarvis_" + hashlib.sha256(descriptor.name.encode()).hexdigest()[:20]definition = {diff --git a/jarvis/plugins/tool/appshot.py b/jarvis/plugins/tool/appshot.pyindex 0d38ebdd34..ec5dca0f57 100644--- a/jarvis/plugins/tool/appshot.py+++ b/jarvis/plugins/tool/appshot.py@@ -23,9 +23,10 @@ SCOPES = ("window", "screen")#: Trusted framing in front of the untrusted screen evidence of a full-screen#: appshot (the window appshot carries the service's own preamble)._SCREEN_PREAMBLE = (- "APPSHOT: the user deliberately asked for their whole screen to give you "- "context. Use it for their request. If they only asked you to take an "- "appshot, confirm it in one short sentence and ask what they want to know."+ "APPSHOT: a captured snapshot of the user's whole screen, supplied as context. "+ "It shows the screen at capture time, not a live view. Use it when asked about "+ "this image. A request to take another appshot requires a fresh successful "+ "take_appshot call; this earlier image is not evidence of a new capture.")diff --git a/tests/contract/test_live_computer.py b/tests/contract/test_live_computer.pyindex c05c5fad9d..8867c2e9eb 100644--- a/tests/contract/test_live_computer.py+++ b/tests/contract/test_live_computer.py@@ -10,6 +10,7 @@ from jarvis.core.protocols import SupervisorToolDescriptor, ToolResultfrom jarvis.cu.direct import TOOL_DESCRIPTION, tool_schemafrom jarvis.live.state import LiveLedgerfrom jarvis.live.tools import LiveTools+from tests.fakes.fake_subscription_session import AppshotSubscriptionGatewayclass ComputerGateway:@@ -50,6 +51,23 @@ def test_computer_is_declared_under_its_own_name(ledger, defer):assert aliases == [][email protected]("defer", [True, False])+def test_appshot_is_declared_once_even_when_other_tools_are_deferred(ledger, defer):+ gateway = AppshotSubscriptionGateway()+ runtime = LiveTools(gateway, ledger, "s", language="en", backend_model="m")+ declared = runtime.declarations(defer_catalog=defer)+ appshot = next(d for d in gateway.catalog() if d.name == "take_appshot")+ assert [d["parameters"] for d in declared if d["name"] == "take_appshot"] == [+ appshot.input_schema,+ ]+ assert "take_appshot" not in runtime._names.values()++ from jarvis.live.native import _fit_declarations++ # Native providers with a small declaration budget retain the same capture path.+ assert "take_appshot" in {d["name"] for d in _fit_declarations(declared, 1)}++@pytest.mark.asyncioasync def test_a_direct_computer_call_runs_and_returns_its_screenshot(ledger):gateway = ComputerGateway()@@ -101,3 +119,17 @@ def test_backend_instructions_hand_the_screen_to_the_thinking_model():]assert "computer tool" in instructionsassert "no separate computer-use agent" in instructions++[email protected]("auth_mode", ["api_key", "chatgpt_subscription"])+def test_new_capture_requires_fresh_appshot_evidence_in_both_live_modes(auth_mode):+ from jarvis.live.config import LiveConfig++ config = LiveConfig(+ configured=True, auth_mode=auth_mode, backend_model="api-model",+ subscription_backend_model="subscription-model",+ )+ instructions = config.backend_config(language="en", tools=[])["instructions"]+ assert "call take_appshot for a fresh capture" in instructions+ assert "only after take_appshot succeeds" in instructions+ assert "old image as current" in instructionsdiff --git a/tests/fakes/fake_subscription_session.py b/tests/fakes/fake_subscription_session.pyindex ccbd72bdea..1b5c5979bd 100644--- a/tests/fakes/fake_subscription_session.py+++ b/tests/fakes/fake_subscription_session.py@@ -34,6 +34,30 @@ class SubscriptionGateway:return True+class AppshotSubscriptionGateway(SubscriptionGateway):+ """A newly requested capture returns a different image, or an explicit refusal."""++ def __init__(self, *, refused=False):+ super().__init__()+ self.refused = refused++ def catalog(self):+ from jarvis.plugins.tool.appshot import AppshotTool++ return (*super().catalog(), SupervisorToolDescriptor(+ AppshotTool.name, AppshotTool.description, AppshotTool.schema, "monitor",+ ))++ async def execute(self, name, args, request):+ self.calls.append((name, args, operation_model.get()))+ if self.refused:+ return ToolResult(False, None, "Blocked by the privacy filter.")+ return ToolResult(True, {+ "description": "A newly captured window",+ "_image": {"mime": "image/png", "data": "TkVX"},+ })++class SubscriptionConnection:session_id = "rtc_fake"answer_sdp = "answer"diff --git a/tests/unit/live/test_subscription_session.py b/tests/unit/live/test_subscription_session.pyindex 3e40c63b71..876a0654a8 100644--- a/tests/unit/live/test_subscription_session.py+++ b/tests/unit/live/test_subscription_session.py@@ -11,6 +11,7 @@ from jarvis.live.config import LiveConfigfrom jarvis.live.state import LiveLedgerfrom jarvis.live.tools import LiveToolsfrom tests.fakes.fake_subscription_session import (+ AppshotSubscriptionGateway,ScriptedSubscriptionReasoning,SubscriptionConnection,SubscriptionEvents,@@ -27,7 +28,7 @@ def make_session(monkeypatch, tmp_path):sessions = []- def make(rounds):+ def make(rounds, gateway=None):reasoning = ScriptedSubscriptionReasoning(rounds)monkeypatch.setattr(module, "SubscriptionReasoning", lambda **kwargs: reasoning)config = SimpleNamespace(@@ -56,7 +57,7 @@ def make_session(monkeypatch, tmp_path):bus=bus,)ledger = LiveLedger(tmp_path / f"{session.session_id}.sqlite3")- gateway = SubscriptionGateway()+ gateway = gateway or SubscriptionGateway()session._ledger = ledgersession._connection = SubscriptionConnection()session._tools = LiveTools(@@ -356,6 +357,61 @@ async def test_screenshot_tool_result_becomes_a_supported_image_input(make_sessi)[email protected]("refused", [False, True])+async def test_new_appshot_request_keeps_old_image_as_context_and_uses_new_tool_result(+ make_session, refused,+):+ gateway = AppshotSubscriptionGateway(refused=refused)+ capture = {+ "id": "fresh-shot", "type": "function_call", "call_id": "capture-1",+ "name": "take_appshot", "arguments": '{"scope":"window"}',+ }+ session, reasoning, _, _, _, _ = make_session([+ completed_response("r1", [capture]),+ completed_response("r2", [spoken_result("Capture refused." if refused else "Captured.")]),+ ], gateway=gateway)+ await session.attach_appshot(b"OLD", "image/png", "An earlier skill editor screenshot")+ request = "Take a new appshot and look at my current screen."+ await session._delegate("fresh-request", request)++ first = reasoning.requests[0]+ assert "take_appshot" in {tool["name"] for tool in first["tools"]}+ assert first["input"][-1]["content"][0]["text"] == request+ previous = first["input"][-2]["content"]+ assert "Earlier screen snapshot" in previous[0]["text"]+ assert previous[-1]["image_url"] == "data:image/png;base64,T0xE"+ assert [(name, args) for name, args, _ in gateway.calls] == [+ ("take_appshot", {"scope": "window"}),+ ]+ followup = reasoning.requests[1]["input"]+ result = next(item for item in followup if item.get("type") == "function_call_output")+ assert json.loads(result["output"])["success"] is not refused+ assert ("data:image/png;base64,TkVX" in json.dumps(followup)) is not refused+ if refused:+ assert "Blocked by the privacy filter" in result["output"]+ else:+ assert session._image_context == [+ {"type": "input_image", "image_url": "data:image/png;base64,TkVX"},+ ]+++async def test_existing_appshot_stays_available_for_a_followup_without_recapture(make_session):+ session, reasoning, gateway, _, _, _ = make_session([+ completed_response("r1", [spoken_result("This image shows a skill editor.")]),+ completed_response("r2", [spoken_result("The button in that image says Save.")]),+ ])+ await session.attach_appshot(b"OLD", "image/png", "A supplied screenshot")+ for index, request in enumerate(("Describe this image.", "What does its button say?")):+ await session._delegate(f"image-{index}", request)+ items = reasoning.requests[index]["input"]+ assert items[-1]["content"][0]["text"] == request+ assert "data:image/png;base64,T0xE" in json.dumps(items)+ assert "Earlier screen snapshot" in json.dumps(items)+ assert gateway.calls == []++@pytest.mark.asyncioasync def test_completion_report_uses_subscription_reasoning_without_new_tool_authority(make_session,