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(runs): DecisionStep rationale + ToolCall command/output DTO fields
Ruben Lütke5bbb6404e2f0
diff --git a/jarvis/runs/constants.py b/jarvis/runs/constants.pyindex 8f452b1b46..8a3efce037 100644--- a/jarvis/runs/constants.py+++ b/jarvis/runs/constants.py@@ -30,6 +30,20 @@ RUN_DECISION_KINDS: Final[tuple[str, ...]] = (DECISION_BRAIN, DECISION_MISSION, DECISION_FALLBACK,)+# --- Rationale provenance (the honest "why") --------------------------+# Where a DecisionStep's rationale came from. NEVER fabricated:+# "model" — the brain's own natural-language text emitted next to a tool_use+# block (ActionProposed.rationale), captured for free.+# "rule" — a deterministic, honest explanation the analyzer builds from a+# CAPTURED fact (approval source, denial reason, provider fallback).+# An empty source means no rationale was available; the UI says so plainly+# rather than guessing. This crosses Python -> Pydantic -> TS -> UI, so it is+# parity-guarded like the other run enums.+RATIONALE_MODEL: Final[str] = "model"+RATIONALE_RULE: Final[str] = "rule"++RATIONALE_SOURCES: Final[tuple[str, ...]] = (RATIONALE_MODEL, RATIONALE_RULE)+# --- Run outcome (distinct from SLO latency) --------------------------# The functional result of a run, NOT its speed. A slow-but-answered run is a# success; only a genuine failure (unrecovered error, no answer, denied action)@@ -60,6 +74,7 @@ __all__ = ["DECISION_TIER", "DECISION_ROUTE", "DECISION_RISK","DECISION_BRAIN", "DECISION_MISSION", "DECISION_FALLBACK","RUN_DECISION_KINDS",+ "RATIONALE_MODEL", "RATIONALE_RULE", "RATIONALE_SOURCES","OUTCOME_SUCCESS", "OUTCOME_PARTIAL", "OUTCOME_FAILED", "RUN_OUTCOMES","ROLE_USER", "ROLE_JARVIS", "ROLE_SYSTEM", "ROLE_TOOL", "ROLE_ERROR","TRANSCRIPT_ROLES",diff --git a/jarvis/runs/model.py b/jarvis/runs/model.pyindex 176b4238bd..c12395c5b6 100644--- a/jarvis/runs/model.py+++ b/jarvis/runs/model.py@@ -40,6 +40,11 @@ class ToolCall(BaseModel):exit_code: int | None = Nonesuccess: bool = Trueerror_line: str | None = None # scrubbed stderr ERROR line+ # The actual command + result — already captured (CLI full_command,+ # ToolCallStarted.args_preview / ToolCallCompleted.output_preview) but never+ # surfaced until now. Both are redacted/length-capped upstream.+ command: str = "" # what was run (args_preview / full_command)+ output: str = "" # what came back (output_preview, truncated)class LatencyEntry(BaseModel):@@ -54,6 +59,13 @@ class DecisionStep(BaseModel):kind: str # see RUN_DECISION_KINDSlabel: strdetail: str | None = None+ # Session-Decision-Log: the honest "why" for this step. ``rationale`` is the+ # plain-language reason; ``rationale_source`` tags its provenance — see+ # RATIONALE_SOURCES ("model" = the brain's own words, "rule" = a+ # deterministic explanation from a captured fact, "" = none available).+ # Never fabricated; an empty source surfaces as "no rationale recorded".+ rationale: str = ""+ rationale_source: str = ""class ErrorEntry(BaseModel):diff --git a/tests/unit/runs/test_constants_parity.py b/tests/unit/runs/test_constants_parity.pyindex 25c056086c..5c7ffe572d 100644--- a/tests/unit/runs/test_constants_parity.py+++ b/tests/unit/runs/test_constants_parity.py@@ -2,6 +2,7 @@ from jarvis.runs.constants import (SLO_STATUSES, SLO_OK, SLO_WARN, SLO_BREACH,RUN_DECISION_KINDS, DECISION_TIER, DECISION_ROUTE, DECISION_RISK,DECISION_BRAIN, DECISION_MISSION, DECISION_FALLBACK,+ RATIONALE_SOURCES, RATIONALE_MODEL, RATIONALE_RULE,)@@ -18,3 +19,10 @@ def test_decision_kinds_complete_and_stable():assert set(RUN_DECISION_KINDS) == {"tier", "route", "risk", "brain", "mission", "fallback",}+++def test_rationale_sources_complete_and_stable():+ # The honest-"why" provenance tag. "model" = the brain's own words;+ # "rule" = a deterministic explanation built from a captured fact.+ assert RATIONALE_SOURCES == (RATIONALE_MODEL, RATIONALE_RULE)+ assert set(RATIONALE_SOURCES) == {"model", "rule"}diff --git a/tests/unit/runs/test_model.py b/tests/unit/runs/test_model.pyindex 1dc39e6dc9..5d87b8a7bb 100644--- a/tests/unit/runs/test_model.py+++ b/tests/unit/runs/test_model.py@@ -19,6 +19,28 @@ def test_enum_fields_are_plain_strings():assert ds.kind == "future_kind"+def test_decision_step_rationale_defaults_and_set():+ # The honest "why" rides on DecisionStep. Default = none captured.+ ds = DecisionStep(kind="risk", label="approved: cli_gcloud")+ assert ds.rationale == "" and ds.rationale_source == ""+ ds2 = DecisionStep(+ kind="route", label="proposed: open_calendar",+ rationale="I open the calendar to check your schedule.",+ rationale_source="model",+ )+ assert ds2.rationale.startswith("I open the calendar")+ assert ds2.rationale_source == "model"+++def test_tool_call_command_and_output_defaults_and_set():+ # The already-captured command + result, surfaced (was hidden before).+ tc = ToolCall(name="cli_gcloud")+ assert tc.command == "" and tc.output == ""+ tc2 = ToolCall(name="cli_gcloud", command="gcloud projects list",+ output="3 projects")+ assert tc2.command == "gcloud projects list" and tc2.output == "3 projects"++def test_run_list_item_shape():item = RunListItem(session_id="s1", started_ms=1, ended_ms=2, duration_s=0.001,