hermes - ✅(Solved) Fix cron: scheduler does not parse script arguments (e.g. memory-ttl.py expire) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#20300Fetched 2026-05-06 06:37:32
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #20354: fix(cron): pass arguments to job scripts

Description (problem / solution / changelog)

Summary

  • Parse cron job script entries with shlex.split() so a script path can be followed by CLI arguments.
  • Pass parsed arguments through to both Python and bash cron scripts.
  • Keep the existing scripts-directory containment check on the parsed script path before execution.
  • Add regression coverage for a relative script invoked with arguments.
  • Add the missing AUTHOR_MAP entry for this commit email so attribution checks can resolve the contributor.

Why this shape

Cron scripts are already configured as a single string, and users can reasonably write values such as memory-ttl.py expire or monitor.py --check-only. Previously _run_job_script() treated the entire string as the filename, so the script either failed lookup or ran without the intended mode depending on how it was configured downstream.

Using shlex.split() keeps quoted arguments predictable while preserving the existing explicit interpreter selection and path containment model.

Testing

  • Verified the new regression test fails before the fix.
  • /opt/venv/bin/python -m py_compile cron/scheduler.py tests/cron/test_cron_script.py scripts/release.py
  • /opt/venv/bin/python -m pytest tests/cron/test_cron_script.py::TestRunJobScript tests/cron/test_cron_script.py::TestScriptPathContainment tests/cron/test_cron_no_agent.py -q -o addopts=''

Result: 35 passed, 1 warning.

Notes for maintainers

This is intentionally limited to script argument parsing and does not change the trust boundary: the executable script itself still has to resolve inside HERMES_HOME/scripts/ before it runs.

Closes #20300.

This work was done with Hermes Agent.

Changed files

  • cron/scheduler.py (modified, +16/-6)
  • scripts/release.py (modified, +1/-0)
  • tests/cron/test_cron_script.py (modified, +14/-0)
RAW_BUFFERClick to expand / collapse

Bug Description

The cron script field supports a path that includes arguments (e.g. memory-ttl.py expire), but _run_job_script() in cron/scheduler.py treats the entire string as a filename rather than parsing it into "script path + arguments".

Steps to Reproduce

  1. Create a cron job with script: "memory-ttl.py expire" (or any script that accepts CLI arguments)
  2. Run the cron job
  3. Observe that subprocess.run([sys.executable, str(path)]) receives the full string as the path argument — the script runs but without expire as an argument, so it executes in its default mode instead

Expected Behavior

Use shlex.split() to separate the script filename from its arguments, then append the arguments to the subprocess call: subprocess.run([sys.executable, str(path)] + script_args).

Actual Behavior

The entire string including whitespace-separated arguments is treated as a single filename. Scripts that rely on CLI arguments silently run in the wrong mode.

Impact

Any cron job using a script that requires arguments (like --report-only, expire, --check-only) silently runs with the wrong behavior. The job still returns ok status, masking the incorrect execution.

extent analysis

TL;DR

Modify the _run_job_script() function in cron/scheduler.py to parse the script field into a path and arguments using shlex.split() before executing the subprocess.

Guidance

  • Identify the line in cron/scheduler.py where subprocess.run() is called and modify it to split the script field into a path and arguments.
  • Use shlex.split() to safely split the script field into a list of arguments, handling any whitespace or quotes correctly.
  • Update the subprocess.run() call to include the script arguments, such as subprocess.run([sys.executable, str(path)] + script_args).
  • Verify the fix by creating a test cron job with a script that requires arguments and checking its execution behavior.

Example

import shlex
# ...
script_path_with_args = "memory-ttl.py expire"
script_args = shlex.split(script_path_with_args)
path = script_args[0]
args = script_args[1:]
subprocess.run([sys.executable, str(path)] + args)

Notes

This fix assumes that the script field only contains the script path and arguments, without any other syntax or formatting. If the script field can contain other characters or formatting, additional parsing may be necessary.

Recommendation

Apply the workaround by modifying the _run_job_script() function to correctly parse and execute the script field with arguments, as this will fix the issue without requiring any version upgrades or external changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING