Skip to content

The agent that grows with you

fix(cron): a Run-now stopped by cancel reports "cancelled", not "failed"

Teknium3f435147912f
diff --git a/hermes_cli/cron.py b/hermes_cli/cron.py
index 4efcd4f2baf..df4678041fa 100644
--- a/hermes_cli/cron.py
+++ b/hermes_cli/cron.py
@@ -902,6 +902,7 @@ def _job_action(action: str, job_id: str, success_verb: str) -> int:
if action == "run":
print(f" {_run_outcome(result.get('job', {}))}")
if (job.get('executed') and job.get('execution_success') is False
+ and job.get('last_status') != 'cancelled'
and not job.get('delegation_id') and job.get('execution_mode') != 'background'):
return 1
return 0
@@ -918,6 +919,8 @@ def _run_outcome(job: dict[str, Any]) -> str:
if job.get("execution_mode") == "background":
return "Running in background."
if job.get("executed"):
+ if not job.get("execution_success") and job.get("last_status") == "cancelled":
+ return "Ran now: cancelled."
return f"Ran now: {'succeeded' if job.get('execution_success') else 'failed'}."
return job.get("execution_skipped") or "It will run on the next scheduler tick."
diff --git a/tests/hermes_cli/test_cron.py b/tests/hermes_cli/test_cron.py
index efe415162d7..2e92f6185cc 100644
--- a/tests/hermes_cli/test_cron.py
+++ b/tests/hermes_cli/test_cron.py
@@ -527,6 +527,22 @@ class TestCronRunBackgroundDispatch:
assert rc == 1
assert "Ran now: failed." in out
+ def test_run_stopped_by_a_cancel_reports_cancelled_not_failed(self, monkeypatch, capsys):
+ monkeypatch.setattr(
+ cron_cli,
+ "_cron_api",
+ lambda **kwargs: {
+ "success": True,
+ "job": {"id": "job-1", "name": "Watchdog", "executed": True,
+ "execution_success": False, "last_status": "cancelled"},
+ },
+ )
+
+ rc, out = self._run_cmd(capsys)
+
+ assert rc == 0
+ assert "Ran now: cancelled." in out
+
def test_delegation_id_alone_counts_as_background(self, monkeypatch, capsys):
# Some dispatchers may not set execution_mode but always return the
# delegation_id — either marker alone must suppress the verdict.