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(tools): stop a command readback burying its own result in app state

Ruben Lütke2ad39e86b493
diff --git a/jarvis/plugins/tool/app_command.py b/jarvis/plugins/tool/app_command.py
index a8cb8acbd0..a5c3f72937 100644
--- a/jarvis/plugins/tool/app_command.py
+++ b/jarvis/plugins/tool/app_command.py
@@ -81,6 +81,29 @@ def _validate_args(schema: dict[str, Any], args: dict[str, Any]) -> list[str]:
return errors
+#: Response keys carrying a FULL app-state snapshot. Mutating routes return one
+#: so an open UI can re-render without a second fetch — but a language model
+#: needs what CHANGED, not the snapshot. Measured: one Agentic-IDE spawn answers
+#: with ~25 000 characters of workspace state (every pane, its transcript, the
+#: project's skills and subagents), so three calls in a turn bury the actual
+#: result and the reply the model has to act on. A live session on 2026-07-27
+#: spent 58 000 input tokens on one turn that way and lost track of the pane it
+#: had just opened. Callers that genuinely want the snapshot have a dedicated
+#: status command.
+_SNAPSHOT_KEYS = frozenset({"state"})
+
+
+def _without_snapshots(data: Any) -> Any:
+ """The server's response minus any full-state snapshot it echoed back."""
+ if not isinstance(data, dict):
+ return data
+ trimmed = {key: value for key, value in data.items() if key not in _SNAPSHOT_KEYS}
+ if trimmed.keys() <= {"ok"}:
+ # The snapshot WAS the answer; trimming it would return nothing at all.
+ return data
+ return trimmed
+
+
def _summarize(title: str, data: Any) -> str:
"""One honest sentence from the server's actual response payload."""
if isinstance(data, dict):
@@ -239,7 +262,7 @@ class RegistryCommandTool:
output={
"command_id": cmd.id,
"summary": _summarize(cmd.title, data),
- "response": data,
+ "response": _without_snapshots(data),
},
)
diff --git a/tests/unit/plugins/tool/test_app_command.py b/tests/unit/plugins/tool/test_app_command.py
index 84b9bdfee2..da84d279e6 100644
--- a/tests/unit/plugins/tool/test_app_command.py
+++ b/tests/unit/plugins/tool/test_app_command.py
@@ -209,3 +209,37 @@ async def test_end_to_end_against_real_webserver_app(monkeypatch) -> None:
# old_provider comes from cfg.brain.primary (shared app_control logic),
# so only pin the destination side of the transition here.
assert "-> openrouter" in result.output["summary"]
+
+
+# --------------------------------------------------------------------------- #
+# Response trimming: what CHANGED, not a snapshot of everything #
+# --------------------------------------------------------------------------- #
+
+
+def test_a_full_state_snapshot_is_kept_out_of_the_readback() -> None:
+ """Mutating routes echo the whole app state back; the model must not read it.
+
+ One Agentic-IDE spawn answers with roughly 25 000 characters of workspace
+ state — every pane, its transcript, the project's skills and subagents —
+ purely so an open UI can re-render without a second fetch. Three such calls
+ in one turn buried the result the model then had to act on: a live session
+ on 2026-07-27 spent 58 000 input tokens on a single turn and lost track of
+ the pane it had just opened, spawning three more.
+ """
+ from jarvis.plugins.tool.app_command import _without_snapshots
+
+ trimmed = _without_snapshots(
+ {"ok": True, "terminals": [{"name": "Kate"}], "state": {"huge": "x" * 5000}}
+ )
+
+ assert trimmed == {"ok": True, "terminals": [{"name": "Kate"}]}
+
+
+def test_a_response_that_is_only_a_snapshot_is_still_returned() -> None:
+ """Trimming must never answer with nothing at all."""
+ from jarvis.plugins.tool.app_command import _without_snapshots
+
+ payload = {"ok": True, "state": {"active": True}}
+
+ assert _without_snapshots(payload) == payload
+ assert _without_snapshots("plain text") == "plain text"