A cron job rewrote its own delivery target, and the reports stopped arriving

Your cron table has 19 jobs. One is called upkeep and runs “tidy up” at 4am every Saturday. It does something plain: list every job, refresh a few siblings’ prompts and delivery settings from a template — including the line
hermes cron edit <upkeep-id> --deliver origin
which reads as “send the results back to the chat I was created in”. Week one was fine. In week two the Saturday report did not arrive. Neither did it in week three. hermes cron list shows that job’s deliver field as local — no error, no warning, it simply went from “deliver to me” to “deliver nowhere”.
What origin actually means
The semantics matter, because the bug lives inside them. A cron job’s deliver can name a concrete target (telegram:<chat_id>, slack, local, all), or it can be origin — the chat the job was created in.
origin is an expression relative to creation time. When the job is created, Hermes records the conversation address at that moment; every later run delivers back there. If there was no usable source at creation time (a job created by a script, or on the request/response api_server platform which cannot receive deliveries), a home-channel fallback stands in.
The official docs state the design plainly, in the section about managing cron from inside a cron run:
No dangling delivery. A cron run is ephemeral, so
deliver: originfrom inside one is resolved at create time to the creating job’s own concrete target (platform:chat_id[:thread_id], orlocalif the creating job delivers nowhere).
Note those three words: at create time. The documented scenario is creating a new job from inside a cron run — a brand-new job must not point at an ephemeral session that disappears, so origin is resolved the instant it is created.
Updating an existing job is a different situation entirely. The job already exists, its origin was recorded long ago, and origin is meaningful and stable for it. Resolving it again at that point does not fix anything — it corrupts a value that was already correct.
What the code does
_update_core_fields in tools/cronjob_tools.py sends both deliver and failure_deliver through the same resolver on the update path:
if deliver is not None:
...
updates["deliver"] = _resolve_cron_context_deliver(_normalize_deliver_param(deliver))
if a["failure_deliver"] is not None:
...
_norm_fd = _resolve_cron_context_deliver(_norm_fd)
updates["failure_deliver"] = _norm_fd
And that resolver’s own docstring states its scope (tools/cronjob_job_args.py):
def _resolve_cron_context_deliver(deliver: Optional[str]) -> Optional[str]:
"""Resolve ``origin`` to a concrete target for creates made FROM a cron run (the creating
session is ephemeral, so by fire time there is no origin). Non-cron sessions: unchanged.
Cron sessions: ``origin`` (or omitted) becomes the creating run's ``platform:chat_id[:thread]``
from HERMES_CRON_AUTO_DELIVER_*, or ``local`` when it has no concrete target; other
elements pass through. Otherwise the scheduler would guess a home channel."""
“For creates made FROM a cron run.” The first line of the body says the same thing:
if not is_truthy_value(get_session_env("HERMES_CRON_SESSION", "")):
return deliver
Outside a cron run it returns the value untouched. Inside one, origin (and None) become the creator’s concrete address, assembled from HERMES_CRON_AUTO_DELIVER_PLATFORM / _CHAT_ID / _THREAD_ID; with no concrete target it degrades to local.
The problem is that the scheduler sets those three variables for the job that is currently running (cron/scheduler.py assigns HERMES_CRON_AUTO_DELIVER_* and marks them inheritable by subprocesses). So when you call hermes cron edit from inside a cron run, the child process carries the running job’s delivery target. A command meant to be “keep your own origin” becomes “become my chat instead” — and if the upkeep job itself delivers to local, the result is local.
You will not see it happen. updates["deliver"] is simply overwritten, the command exits 0, and one column in hermes cron list has quietly changed.
Three checks to run
One: list the origin jobs and confirm they still say origin.
hermes cron list
If you find local among jobs you never changed, this is what happened.
Two: run the delivery health check.
hermes cron doctor
This is a read-only fleet check: failed runs, failed deliveries, overdue or missing next_run_at, missing scripts or workdirs, exiting non-zero when it finds problems. It will not tell you “origin was rewritten to local”, but “this job is configured to deliver and keeps failing” usually surfaces here.
Three: do not edit delivery from inside a cron run.
This is the direct workaround. An upkeep job can safely change prompts, schedules and names through the cronjob tool; the delivery field should be changed by a human, or written as an explicit target instead of origin.
If you genuinely must run that edit from inside a cron run, strip the variables around the CLI call:
env -u HERMES_CRON_SESSION \
-u HERMES_CRON_AUTO_DELIVER_PLATFORM \
-u HERMES_CRON_AUTO_DELIVER_CHAT_ID \
-u HERMES_CRON_AUTO_DELIVER_THREAD_ID \
hermes cron edit <id> --deliver origin
The mechanism is easy to follow: outside a “cron session” the resolver returns its input on the first line, origin stays literal, and a literal origin is valid for an existing job — it has a recorded origin, plus a home-channel fallback when it does not.
Why this bug is unusually hard to spot
Three silent traits stack up:
- No error. The success path is a field overwrite and exit code 0.
- Delayed exposure. The upkeep run itself looks fine; the damage only shows when a sibling job next fires and no output appears, usually days later.
- Misleading symptoms. Your first instinct is “the delivery platform broke” or “the bot token expired”, so you go read Telegram and gateway logs while the actual change sits in
jobs.json.
The fix is narrow: apply the cron-context resolution on create only, and keep the literal origin on update. A community patch and regression test exist (the new test fails on main and passes with the patch) but it is not merged yet. Until it is, the three checks above are the best you can do.
One more thing about cron delivery
deliver and failure_deliver are two separate fields — the second says where failures go, and it shares the first one’s resolution path. So this bug rewrites both. If you had configured “success to the group, failures to me privately”, check both columns.
Cron has more knobs than most people assume: a job can deliver through its own bot (see giving a cron job its own bot), carry memory across runs (see cron memory continuity), and be checked with cron doctor (see the cron doctor guide). The full subcommand list lives in the cron command reference.
If you remember one line: origin is relative to creation time, and anything that “re-resolves” it later can break an address that was already right.