fix(cron): show delivery failure inline with last-run status

When a cron job's agent run succeeds but delivery to a channel
(Discord, Telegram, etc.) fails, `last_status` is "ok" while
`last_delivery_error` holds the failure reason.  The previous display
printed a separate yellow warning line that was easy to miss — the
status cell still showed a plain green "ok", making the job look
healthy at a glance.

This commit surfaces the failure directly in the status cell:

  hermes_cli/cron.py (`hermes cron list`)
    "ok" → "ok  ⚠ delivery failed" (green + yellow) when
    `last_delivery_error` is set; the detail line below is kept.

  cli.py (in-chat /cron list)
    Status string becomes "ok ⚠ delivery failed" and a
    "Delivery error: …" line is printed below it.

No changes to cron/jobs.py or the data model — `last_status` still
reflects agent execution only, per the maintainer design decision.

Fixes #5861
This commit is contained in:
UGBOMEH OGOCHUKWU WILLIAMS 2026-04-19 15:42:40 +01:00
parent a521005fe5
commit c08accb2f1
2 changed files with 11 additions and 4 deletions

7
cli.py
View file

@ -5339,7 +5339,12 @@ class HermesCLI:
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', '?')})")
delivery_err = job.get("last_delivery_error")
last_status = job.get("last_status", "?")
status_str = f"{last_status} ⚠ delivery failed" if (last_status == "ok" and delivery_err) else last_status
print(f" Last run: {job['last_run_at']} ({status_str})")
if delivery_err:
print(f" Delivery error: {delivery_err}")
print()
return

View file

@ -96,15 +96,17 @@ def cron_list(show_all: bool = False):
# Execution history
last_status = job.get("last_status")
delivery_err = job.get("last_delivery_error")
if last_status:
last_run = job.get("last_run_at", "?")
if last_status == "ok":
status_display = color("ok", Colors.GREEN)
if delivery_err:
status_display = color("ok", Colors.GREEN) + " " + color("⚠ delivery failed", Colors.YELLOW)
else:
status_display = color("ok", Colors.GREEN)
else:
status_display = color(f"{last_status}: {job.get('last_error', '?')}", Colors.RED)
print(f" Last run: {last_run} {status_display}")
delivery_err = job.get("last_delivery_error")
if delivery_err:
print(f" {color('⚠ Delivery failed:', Colors.YELLOW)} {delivery_err}")