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(tasks): a failed run no longer ends a recurring automation
rubenluetke10-beepd4bb8da42bc4
diff --git a/jarvis/tasks/runner.py b/jarvis/tasks/runner.pyindex 6f5b2bbad0..3f0d0cbc1d 100644--- a/jarvis/tasks/runner.py+++ b/jarvis/tasks/runner.py@@ -174,14 +174,22 @@ class TaskRunner:except Exception as exc: # noqa: BLE001duration_ms = int((time.perf_counter() - start) * 1000)error_msg = readable_error(exc)- await self._store.update_state(task_id, "failed", error=error_msg)+ # A recurring automation survives a failed run: it goes back to+ # `scheduled` with the reason in `last_error`, and fires again at+ # its next occurrence. Only one-shot tasks end in `failed`+ # (live 2026-08-24: the first automation ever added died for+ # good on one provider error and "Run now" refused it as final).+ is_recurring = getattr(spec.trigger, "type", None) == "every"+ await self._store.update_state(+ task_id, "scheduled" if is_recurring else "failed", error=error_msg,+ )await self._store.append_step(task_id, "log",{"event": "error", "message": error_msg})await self._bus.publish(TaskFailed(task_id=task_id,error=error_msg,- will_retry=False,+ will_retry=is_recurring,source_layer="tasks.runner",))diff --git a/jarvis/tasks/store.py b/jarvis/tasks/store.pyindex 8be7ed0772..84cb8a9906 100644--- a/jarvis/tasks/store.py+++ b/jarvis/tasks/store.py@@ -291,11 +291,14 @@ class TaskStore:sets.append("started_at_ns = ?")params.append(now_ns)# A run has finished when the state is terminal — or when a recurring- # task hands back a ``result`` on its way to ``scheduled``. Either way+ # task hands back a ``result`` (or a failure ``error``) on its way to+ # ``scheduled``. Either way# ``finished_at_ns`` marks the end of the LAST run, and a successful# result clears the error of a previous failed run so the list view's# ``last_run_state`` reflects the latest run only.- finished = state in TERMINAL_STATES or result is not None+ finished = (+ state in TERMINAL_STATES or result is not None or error is not None+ )if finished:sets.append("finished_at_ns = ?")params.append(now_ns)diff --git a/tests/unit/tasks/test_runner.py b/tests/unit/tasks/test_runner.pyindex 382f073e97..c7c6e8b889 100644--- a/tests/unit/tasks/test_runner.py+++ b/tests/unit/tasks/test_runner.py@@ -418,3 +418,26 @@ async def test_cancel_mid_stream_stops_the_harness(assert task is not Noneassert task["state"] == "cancelled"assert hm.harness.cancelled # the stop reached the harness itself+++async def test_recurring_task_survives_a_failed_run(store: TaskStore, bus: EventBus) -> None:+ """A failed run must not end a recurring automation: the task returns to+ ``scheduled`` with the reason in ``last_error`` (live 2026-08-24 — the+ first automation ever added died for good on one provider error)."""+ from jarvis.tasks.schema import TriggerEvery++ runner = TaskRunner(store=store, bus=bus)+ spec = TaskSpec(+ title="recurring-tool-missing",+ trigger=TriggerEvery(interval_seconds=3600.0),+ action=ToolCallAction(tool_name="whoami", args={}),+ )+ tid = await store.insert(spec)++ await runner.run(tid)++ task = await store.get(tid)+ assert task is not None+ assert task["state"] == "scheduled"+ assert task["last_error"]+ assert task["finished_at_ns"] is not None