Skip to content

The agent that grows with you

fix(cron): refuse a shell command line as `script` at job creation

Teknium42054a7f8d58
diff --git a/cron/AGENTS.md b/cron/AGENTS.md
index 78a13580bf2..9126d561b77 100644
--- a/cron/AGENTS.md
+++ b/cron/AGENTS.md
@@ -10,7 +10,8 @@ schedule via the `cronjob` tool; users via `hermes cron list|add|edit|pause|resu
`/cron`. Schedules: duration (`"30m"`, `"2h"`, `"1d"`), "every" phrase (`"every 2h"`, `"every monday
9am"`), 5-field cron (`"0 9 * * *"`), ISO one-shot (`"2026-06-01T09:00:00Z"`). Per-job fields:
`skills`, `model`/`provider` overrides, `script` (pre-run data-collection script whose stdout is
-injected into the prompt; `no_agent=True` makes the script the whole job), `context_from` (chain job
+injected into the prompt; `no_agent=True` makes the script the whole job; always a FILE under
+`HERMES_HOME/scripts/`, never a command line — `script='echo hi'` is refused at creation), `context_from` (chain job
A's last output into job B's prompt), `workdir` (run with that directory's `AGENTS.md`/`CLAUDE.md`
loaded), multi-platform delivery.
diff --git a/cron/jobs.py b/cron/jobs.py
index 160bd6e481a..254aaeedb6b 100644
--- a/cron/jobs.py
+++ b/cron/jobs.py
@@ -27,7 +27,7 @@ except ImportError: # pragma: no cover - non-Windows
msvcrt = None
from datetime import datetime, timedelta
from pathlib import Path
-from hermes_constants import get_hermes_home
+from hermes_constants import display_hermes_home, get_hermes_home
from typing import Optional, Dict, List, Any, Callable, Set, Tuple, Union, Collection
logger = logging.getLogger(__name__)
@@ -424,6 +424,11 @@ NO_AGENT_WITHOUT_SCRIPT_ERROR = (
"there is nothing for the job to run."
)
+SCRIPT_IS_COMMAND_LINE_ERROR = (
+ "script must name a file under {scripts_dir} (e.g. 'watchdog.sh'), not a shell command line: "
+ "{script!r} has no such file. Write the command into a script there and pass its filename."
+)
+
def job_payload_is_empty(job: Dict[str, Any]) -> bool:
"""True when a job record has nothing runnable (blank prompt, no script, no skills) AND at
@@ -1658,6 +1663,20 @@ def _validate_job_mode_invariants(
"based on source changes. Use a plain no_agent script job instead.")
if no_agent and not script:
raise ValueError(NO_AGENT_WITHOUT_SCRIPT_ERROR)
+ if script and _script_is_command_line(script):
+ raise ValueError(SCRIPT_IS_COMMAND_LINE_ERROR.format(
+ scripts_dir=display_hermes_home() + "/scripts/", script=script))
+
+
+def _script_is_command_line(script: str) -> bool:
+ """A ``script`` with whitespace that resolves to no file is a command line (``echo hi``),
+ not a path; run every tick it would deliver "Script not found" as the payload. A plain
+ missing filename stays creatable (``hermes cron doctor`` reports it)."""
+ if not any(ch.isspace() for ch in script.strip()):
+ return False
+ from cron.lifecycle_guard import _resolve_script_path
+ path = _resolve_script_path(script)
+ return path is None or not path.is_file()
def _oneshot_past_grace_error(run_at: Any) -> ValueError:
diff --git a/tests/cron/test_cron_no_agent.py b/tests/cron/test_cron_no_agent.py
index 669f97f1d1e..743ef3ca2b5 100644
--- a/tests/cron/test_cron_no_agent.py
+++ b/tests/cron/test_cron_no_agent.py
@@ -53,6 +53,21 @@ def test_create_job_no_agent_requires_script(hermes_env):
create_job(prompt=None, schedule="every 5m", no_agent=True)
+def test_script_must_be_a_file_under_scripts_dir_not_a_shell_command(hermes_env):
+ """``script`` names a file under HERMES_HOME/scripts/. A command line (``echo hi``) is
+ refused at creation instead of firing every tick as "Script not found" delivered as the
+ payload; a real file whose name contains a space is still a path."""
+ from cron.jobs import create_job, update_job
+
+ with pytest.raises(ValueError, match="scripts"):
+ create_job(prompt=None, schedule="every 5m", script="echo CRON_PAYLOAD", no_agent=True, deliver="local")
+
+ (hermes_env / "scripts" / "my watchdog.sh").write_text("echo hi\n", encoding="utf-8")
+ job = create_job(prompt=None, schedule="every 5m", script="my watchdog.sh", no_agent=True, deliver="local")
+ with pytest.raises(ValueError, match="scripts"):
+ update_job(job["id"], {"script": "echo CRON_PAYLOAD"})
+
+
def test_update_job_roundtrips_no_agent_flag(hermes_env):
from cron.jobs import create_job, update_job, get_job
diff --git a/website/docs/user-guide/features/cron.md b/website/docs/user-guide/features/cron.md
index 2ccc687f2f6..dfcfc5c31ed 100644
--- a/website/docs/user-guide/features/cron.md
+++ b/website/docs/user-guide/features/cron.md
@@ -749,7 +749,7 @@ Semantics:
- `{"wakeAgent": false}` on the last line → silent tick (same gate LLM jobs use).
- No tokens, no model, no provider fallback — the job never touches the inference layer.
-`.sh` / `.bash` files run under `bash` from `PATH` when available, otherwise `/bin/bash` (important on Windows Git Bash). Anything else runs under the current Python interpreter (`sys.executable`). Scripts must resolve inside `$HERMES_HOME/scripts/` — relative names, absolute paths, and `~`-prefixed paths are accepted when the resolved target stays in that directory; paths that escape it are rejected. Subprocess env is sanitized (`_sanitize_subprocess_env`): provider API credentials and other Hermes-managed secrets are **not** inherited by cron scripts.
+`.sh` / `.bash` files run under `bash` from `PATH` when available, otherwise `/bin/bash` (important on Windows Git Bash). Anything else runs under the current Python interpreter (`sys.executable`). `script` is always a **file**, never a command line: `--script "echo hi"` is refused at creation (write the command into `~/.hermes/scripts/hi.sh` and pass `hi.sh`). Scripts must resolve inside `$HERMES_HOME/scripts/` — relative names, absolute paths, and `~`-prefixed paths are accepted when the resolved target stays in that directory; paths that escape it are rejected. Subprocess env is sanitized (`_sanitize_subprocess_env`): provider API credentials and other Hermes-managed secrets are **not** inherited by cron scripts.
### The agent sets these up for you