The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cron): every last_status consumer renders delivery_failed explicitly (dashboard badge, Desktop inspector, /cron list, docs)
Tekniumdf4b3733baa5
diff --git a/apps/desktop/src/plugins/hermes-bots/cron-detail.test.tsx b/apps/desktop/src/plugins/hermes-bots/cron-detail.test.tsxindex f42b9808d1c..57ebdf91a5f 100644--- a/apps/desktop/src/plugins/hermes-bots/cron-detail.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/cron-detail.test.tsx@@ -28,7 +28,8 @@ vi.mock('@hermes/plugin-sdk', async importOriginal => {return { ...sdk, host: { ...sdk.host, request } }})-const { RoutineDetailDialog, RoutineRow, routineDetailIssue, routineDetailRows } = await import('./cron')+const { RoutineDetailDialog, RoutineRow, routineDetailIssue, routineDetailRows, routineLastResult } =+ await import('./cron')const activeJob: RoutineJob = {deliver: 'bot-chat',@@ -88,6 +89,22 @@ describe('the facts the row never showed', () => {expect(valueOf(passthrough, 'Schedule')).toBe('0 9 * * 1-5')})+ it('spells out every last_status the scheduler writes', () => {+ // The gateway's literal set is closed; each one gets a human reading, and+ // delivery_failed in particular must not read as a success.+ expect(routineLastResult('ok')).toBe('Succeeded')+ expect(routineLastResult('error')).toBe('Failed')+ expect(routineLastResult('delivery_failed')).toBe('Ran, but delivery failed')+ expect(routineLastResult('blocked_config')).toBe('Blocked by configuration (not run)')+ // Unknown literals pass through rather than vanish.+ expect(routineLastResult('something_new')).toBe('something_new')+ expect(routineLastResult(undefined)).toBeNull()++ expect(valueOf(routineDetailRows({ ...activeJob, last_status: 'delivery_failed' }), 'Last result')).toBe(+ 'Ran, but delivery failed'+ )+ })+it('explains a failing or scheduler-paused job in failure order', () => {expect(routineDetailIssue(activeJob)).toBeNull()expect(routineDetailIssue({ ...activeJob, paused_reason: 'too many failures' })).toBe('too many failures')diff --git a/apps/desktop/src/plugins/hermes-bots/cron.tsx b/apps/desktop/src/plugins/hermes-bots/cron.tsxindex 4e25a957aae..931bd069ac6 100644--- a/apps/desktop/src/plugins/hermes-bots/cron.tsx+++ b/apps/desktop/src/plugins/hermes-bots/cron.tsx@@ -331,6 +331,36 @@ function routineTimestamp(value: string | undefined): null | string {return Number.isFinite(ms) ? `${relativeTime(ms)} · ${new Date(ms).toLocaleString()}` : null}+/** The scheduler's `last_status` literals, spelled out for the inspector. The+ * set is closed on the gateway side, so every literal is named here — an+ * unknown one is passed through verbatim rather than hidden. `delivery_failed`+ * means the agent run succeeded but the brief never reached its target; it+ * must read as a failure, not as a run result the user can trust. */+export function routineLastResult(status: string | null | undefined): null | string {+ const raw = String(status || '').trim()++ if (!raw) {+ return null+ }++ switch (raw) {+ case 'ok':+ return 'Succeeded'++ case 'error':+ return 'Failed'++ case 'delivery_failed':+ return 'Ran, but delivery failed'++ case 'blocked_config':+ return 'Blocked by configuration (not run)'++ default:+ return raw+ }+}+/** The facts `cron.manage list` already sends with every job, as label/value* rows. Pure so the detail contract is testable without a renderer, and so* the dialog cannot invent a field the gateway never sent: an absent value@@ -353,7 +383,7 @@ export function routineDetailRows(job: RoutineJob | null | undefined): Array<{ l['Repeat', job?.repeat],['Next run', paused ? null : routineTimestamp(job?.next_run_at)],['Last run', routineTimestamp(job?.last_run_at)],- ['Last result', job?.last_status],+ ['Last result', routineLastResult(job?.last_status)],['Delivers to', job?.deliver],['Model', job?.model],['Working directory', job?.workdir]diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.pyindex e03376475cf..7fe57373193 100644--- a/hermes_cli/cli_commands_mixin.py+++ b/hermes_cli/cli_commands_mixin.py@@ -1986,7 +1986,13 @@ class CLICommandsMixin:print(f" Skills: {', '.join(job['skills'])}")print(f" Prompt: {job.get('prompt_preview', '')}")if job.get("last_run_at"):- print(f" Last run: {job['last_run_at']} ({job.get('last_status', '?')})")+ status = job.get("last_status") or "?"+ # delivery_failed: the agent ran fine but the output never+ # reached the target — name the delivery reason, which+ # lives in last_delivery_error (last_error is None).+ if status == "delivery_failed" and job.get("last_delivery_error"):+ status = f"delivery_failed: {job['last_delivery_error']}"+ print(f" Last run: {job['last_run_at']} ({status})")print()returndiff --git a/tests/hermes_cli/test_cron.py b/tests/hermes_cli/test_cron.pyindex dbe0b1fecb2..b4882a4849e 100644--- a/tests/hermes_cli/test_cron.py+++ b/tests/hermes_cli/test_cron.py@@ -510,3 +510,41 @@ class TestCronRunBackgroundDispatch:assert rc == 0assert "Running in background (delegation del-xyz)." in outassert "failed" not in out.lower()+++class TestSlashCronListLastStatus:+ """The in-chat ``/cron list`` (cli_commands_mixin) renders every+ ``last_status`` literal explicitly — ``delivery_failed`` names the delivery+ reason (last_error is None for those runs) instead of printing the bare+ literal next to a run that looks otherwise fine."""++ def _run_list(self, tmp_cron_dir, capsys):+ from hermes_cli.cli_commands_mixin import CLICommandsMixin++ class _Host(CLICommandsMixin):+ pass++ _Host()._handle_cron_command("/cron list --all")+ return capsys.readouterr().out++ def test_delivery_failed_names_the_delivery_error(self, tmp_cron_dir, capsys):+ create_job(prompt="Nightly brief", schedule="every 1h", deliver="telegram:1")+ jobs = load_jobs()+ jobs[0]["last_run_at"] = "2026-09-01T07:00:00+00:00"+ jobs[0]["last_status"] = "delivery_failed"+ jobs[0]["last_error"] = None+ jobs[0]["last_delivery_error"] = "telegram: 502 Bad Gateway"+ save_jobs(jobs)++ out = self._run_list(tmp_cron_dir, capsys)+ assert "Last run: 2026-09-01T07:00:00+00:00 (delivery_failed: telegram: 502 Bad Gateway)" in out++ def test_ok_stays_plain(self, tmp_cron_dir, capsys):+ create_job(prompt="Nightly brief", schedule="every 1h")+ jobs = load_jobs()+ jobs[0]["last_run_at"] = "2026-09-01T07:00:00+00:00"+ jobs[0]["last_status"] = "ok"+ save_jobs(jobs)++ out = self._run_list(tmp_cron_dir, capsys)+ assert "(ok)" in outdiff --git a/web/src/lib/cron-job.test.ts b/web/src/lib/cron-job.test.tsindex 172f7f939ed..25420d0a3a7 100644--- a/web/src/lib/cron-job.test.ts+++ b/web/src/lib/cron-job.test.ts@@ -4,6 +4,7 @@ import {buildCronJobPayload,cronJobHasExecutionContent,cronJobFormFromJob,+ cronLastResult,splitCronList,type CronJobFormState,} from "./cron-job";@@ -153,3 +154,49 @@ describe("cronJobFormFromJob", () => {});});});++describe("cronLastResult", () => {+ it("renders nothing for a job that never ran", () => {+ expect(cronLastResult({ last_status: null })).toBeNull();+ expect(cronLastResult({ last_status: "" })).toBeNull();+ });++ it("is green for ok with no detail", () => {+ expect(cronLastResult({ last_status: "ok", last_error: null })).toEqual({+ status: "ok",+ tone: "success",+ detail: null,+ });+ });++ it("is amber for delivery_failed and explains it from last_delivery_error", () => {+ // The agent run succeeded (last_error is null for these runs); the reason+ // lives in last_delivery_error. Must never render as green or as "unknown".+ expect(+ cronLastResult({+ last_status: "delivery_failed",+ last_error: null,+ last_delivery_error: "telegram: 502 Bad Gateway",+ }),+ ).toEqual({+ status: "delivery_failed",+ tone: "warning",+ detail: "telegram: 502 Bad Gateway",+ });+ });++ it("is red for error and any unrecognised literal", () => {+ expect(cronLastResult({ last_status: "error", last_error: "boom" })).toEqual({+ status: "error",+ tone: "destructive",+ detail: "boom",+ });+ expect(cronLastResult({ last_status: "something_new" })?.tone).toBe("destructive");+ });++ it("is amber for blocked_config (preflight refused to burn a run)", () => {+ expect(+ cronLastResult({ last_status: "blocked_config", last_error: "missing API key" }),+ ).toEqual({ status: "blocked_config", tone: "warning", detail: "missing API key" });+ });+});diff --git a/web/src/lib/cron-job.ts b/web/src/lib/cron-job.tsindex ab8e8345825..de4fa9fc47f 100644--- a/web/src/lib/cron-job.ts+++ b/web/src/lib/cron-job.ts@@ -102,3 +102,39 @@ export function cronJobFormFromJob(job: CronJob): CronJobFormState {workdir: asString(job.workdir),};}++/** How a job's `last_status` should render. The scheduler writes a small,+ * closed set of literals; every literal maps to an explicit tone here so a+ * new status can never fall through to a neutral "unknown"-looking badge.+ * In particular `delivery_failed` (agent run succeeded, output never reached+ * the target) is amber, not green and not the same red as a run error, and+ * its detail lives in `last_delivery_error` (last_error is null for it). */+export type CronLastResultTone = "success" | "warning" | "destructive";++export interface CronLastResult {+ status: string;+ tone: CronLastResultTone;+ /** Human detail to show next to the badge; null when nothing to add. */+ detail: string | null;+}++const CRON_LAST_RESULT_TONE: Record<string, CronLastResultTone> = {+ ok: "success",+ delivery_failed: "warning",+ blocked_config: "warning",+ error: "destructive",+};++export function cronLastResult(+ job: Pick<CronJob, "last_status" | "last_error" | "last_delivery_error">,+): CronLastResult | null {+ const status = asString(job.last_status).trim();+ if (!status) return null;+ const tone = CRON_LAST_RESULT_TONE[status] ?? "destructive";+ if (status === "ok") return { status, tone, detail: null };+ const detail =+ status === "delivery_failed"+ ? asString(job.last_delivery_error).trim() || asString(job.last_error).trim()+ : asString(job.last_error).trim() || asString(job.last_delivery_error).trim();+ return { status, tone, detail: detail || null };+}diff --git a/web/src/pages/CronPage.tsx b/web/src/pages/CronPage.tsxindex b501d5675f2..a29a192dc28 100644--- a/web/src/pages/CronPage.tsx+++ b/web/src/pages/CronPage.tsx@@ -22,6 +22,7 @@ import {buildCronJobPayload,cronJobHasExecutionContent,cronJobFormFromJob,+ cronLastResult,type CronJobFormState,} from "@/lib/cron-job";import { DeleteConfirmDialog } from "@/components/DeleteConfirmDialog";@@ -1100,6 +1101,7 @@ export default function CronPage() {const toolsets = Array.isArray(job.enabled_toolsets)? job.enabled_toolsets.filter(Boolean): [];+ const lastResult = cronLastResult(job);return (<Card key={jobKey}>@@ -1112,6 +1114,15 @@ export default function CronPage() {<Badge tone={STATUS_TONE[state] ?? "secondary"}>{state}</Badge>+ {lastResult && lastResult.status !== "ok" && (+ <Badge+ tone={lastResult.tone}+ title={lastResult.detail ?? undefined}+ data-testid="cron-last-result"+ >+ {lastResult.status}+ </Badge>+ )}<Badge tone="outline">{profileLabel(profile)}</Badge>{deliver && deliver !== "local" && (<Badge tone="outline">{deliver}</Badge>diff --git a/website/docs/developer-guide/cron-internals.md b/website/docs/developer-guide/cron-internals.mdindex 427692eb92a..968af066cdf 100644--- a/website/docs/developer-guide/cron-internals.md+++ b/website/docs/developer-guide/cron-internals.md@@ -63,6 +63,20 @@ Jobs are stored in `~/.hermes/cron/jobs.json` with atomic write semantics (write}```+### `last_status` literals++`last_status` is a closed set written only by `cron.jobs.mark_job_run`. Every+renderer (`hermes cron list`/`doctor`, the `cronjob` tool, the web dashboard+badge, the Desktop routine inspector) maps each literal explicitly — a consumer+must never test `== "ok"` for "the user got their result":++| Literal | Meaning | Detail field |+|---------|---------|--------------|+| `ok` | Agent run succeeded and (if targeted) delivery was confirmed | — |+| `error` | Agent run failed | `last_error` |+| `delivery_failed` | Agent run succeeded, but the output never reached its target | `last_delivery_error` (`last_error` is `null`) |+| `blocked_config` | Pre-dispatch validation refused to burn a run | `last_error` |+### Job Lifecycle States| State | Meaning |