hermes - ✅(Solved) Fix cron: pre-run script failures silently greenwashed as success (status=ok) [2 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#20301Fetched 2026-05-06 06:37:31
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×2

Error Message

When a cron job's pre-run script fails (non-zero exit code), the error output is injected into the agent prompt — but the job itself is still marked as ok. The agent may respond to the error in its prompt, but the cron status does not reflect that the pre-run script failed. run_job() should detect when the pre-run script returns a non-zero exit code and mark the job as failed, with the error message in the job output. The script failure is captured and injected into the agent prompt, which may cause the agent to produce a response about the error — but the job status remains ok. This is a "green-light pollution" pattern.

Fix Action

Fixed

PR fix notes

PR #20323: fix(cron): propagate pre-run script failure to job status

Description (problem / solution / changelog)

Summary

When a cron job's pre-run script exits non-zero, the error is injected into the agent prompt — but run_job() still reports success (status=ok). Operators see ok and assume the job ran correctly, when the data-collection step actually failed.

Root Cause

In run_job(), the pre-run script result (_ran_ok) is only used to build the prompt content. The function always returns True at the end, regardless of whether the script succeeded or failed.

Fix

Track script failure via a _script_failed flag set when _run_job_script() returns False. Return not _script_failed instead of hardcoded True at the success path, so failed scripts propagate to job status.

Files changed:

  • cron/scheduler.py — +11/-1 lines (add _script_failed flag, conditional return)
  • tests/cron/test_cron_script.py — +132 lines (3 regression tests)

Regression Coverage

TestScenarioExpected
test_script_failure_marks_job_as_failedScript exits 1success=False
test_script_success_marks_job_as_okScript exits 0success=True
test_no_script_marks_job_as_okNo script configuredsuccess=True

Testing

$ python -m pytest tests/cron/test_cron_script.py::TestRunJobScriptFailureStatus -v
3 passed

5 pre-existing failures in tests/cron/ are unrelated (confirmed by running on upstream origin/main).

Fixes cron: pre-run script failures silently greenwashed as success (status=ok) #20301

Changed files

  • cron/scheduler.py (modified, +11/-1)
  • gateway/platforms/whatsapp.py (modified, +4/-1)
  • tests/cron/test_cron_script.py (modified, +132/-0)
  • tests/tools/test_file_tools.py (modified, +37/-0)
  • tools/file_tools.py (modified, +6/-6)

PR #20326: fix(cron): fail jobs when pre-run script fails instead of greenwashing as ok

Description (problem / solution / changelog)

Stop marking cron jobs as last_status=ok when their pre-run script failed.

What changed and why

  • cron/scheduler.py::run_job now short-circuits on pre-run script failure — when _run_job_script returns success=False, the job exits with success=False, the script output as the error, and a "pre-run script failed" status doc, instead of injecting the error into an agent prompt and burning an LLM call. mark_job_run already records last_status=error for success=False, and _process_job already delivers the failure message to the configured target.
  • This mirrors the existing no_agent path's failed-script handling (cron/scheduler.py:912-929), so both paths now behave consistently: a broken pre-run script always surfaces as error, never as ok.
  • Updated TestRunJobWakeGate.test_script_failure_does_not_trigger_gate (which previously asserted the old greenwashing behavior — "agent DID wake despite the gate-like text") to assert the new contract: agent is not invoked, success is False, and the script error is captured. The gate-bypass safety property the original test cared about (don't honor wakeAgent: false from a failed script's stderr) is still upheld — we just fail-fast instead of waking the agent.

How to test

  • pytest tests/cron/ -q — all 318 cron tests pass (one pre-existing failure on test_script_empty_output_noted reproduces on main, unrelated to this fix).
  • pytest tests/run_agent/test_exit_cleanup_interrupt.py -q — passes (these tests patch _build_job_prompt and exercise run_job cleanup paths).
  • Manual repro: create a cron job with script pointing to a script that exit 1s, run a tick, and check cron listlast_status is now error with the script's stderr in last_error.

What platforms tested on

  • macOS on darwin-arm64 (local)

Fixes #20301

<!-- autocontrib:worker-id=issue-new-4cc4be9c kind=pr-open -->

Changed files

  • cron/scheduler.py (modified, +24/-1)
  • tests/cron/test_scheduler.py (modified, +14/-6)
RAW_BUFFERClick to expand / collapse

Bug Description

When a cron job's pre-run script fails (non-zero exit code), the error output is injected into the agent prompt — but the job itself is still marked as ok. The agent may respond to the error in its prompt, but the cron status does not reflect that the pre-run script failed.

Steps to Reproduce

  1. Create a cron job with a script field pointing to a script that will intentionally fail (exit code 1)
  2. Run the cron job
  3. Observe that run_job() reports success even though the pre-run script failed

Expected Behavior

run_job() should detect when the pre-run script returns a non-zero exit code and mark the job as failed, with the error message in the job output.

Actual Behavior

The script failure is captured and injected into the agent prompt, which may cause the agent to produce a response about the error — but the job status remains ok. This is a "green-light pollution" pattern.

Impact

Silent failures in cron data collection. Operators see ok status and assume the job ran correctly, when in fact the pre-run step crashed. The downstream agent may produce plausible-looking output based on stale or missing data, making the failure harder to detect.

extent analysis

TL;DR

The cron job's run_job() function should be modified to check the exit code of the pre-run script and mark the job as failed if it's non-zero.

Guidance

  • Review the run_job() function to ensure it properly handles the exit code of the pre-run script and updates the job status accordingly.
  • Verify that the script field in the cron job configuration is correctly pointing to the intended script and that the script is executable.
  • Check the agent prompt handling to prevent "green-light pollution" and ensure that the error message is properly propagated to the job output.
  • Consider adding logging or monitoring to detect and alert on silent failures in cron data collection.

Example

def run_job(job):
    # ...
    script_exit_code = subprocess.call(job['script'])
    if script_exit_code != 0:
        job['status'] = 'failed'
        job['output'] = f"Pre-run script failed with exit code {script_exit_code}"
    # ...

Notes

The exact implementation details may vary depending on the programming language and framework used. This example assumes a Python-based implementation.

Recommendation

Apply workaround: Modify the run_job() function to properly handle the exit code of the pre-run script and update the job status accordingly, as this will directly address the issue of silent failures in cron data collection.

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

hermes - ✅(Solved) Fix cron: pre-run script failures silently greenwashed as success (status=ok) [2 pull requests, 1 participants]