Skip to content

fix(cron): add standalone cron daemon mode - #43864

Closed
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/cron-daemon-standalone-clean
Closed

fix(cron): add standalone cron daemon mode#43864
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/cron-daemon-standalone-clean

Conversation

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds hermes cron daemon command to run the cron scheduler as a standalone process, independent of the gateway.

Problem: Cron jobs don't execute on systems where the gateway isn't running (Windows without service installation, headless servers, etc.). The cron scheduler only runs inside the gateway process, so if the gateway isn't started, cron jobs never fire.

Solution: New hermes cron daemon command that runs the same tick loop as the gateway's internal cron ticker, but as a standalone process.

Changes Made

  • hermes_cli/cron.py: Added cron_daemon() function that runs the cron tick loop with signal handling
  • hermes_cli/main.py: Added daemon subcommand parser with --interval option (default 60s)

How to Test

  1. Create a cron job:

    hermes cron create "* * * * *" "Test job - just print hello" --name test-daemon
    
  2. Start the cron daemon:

    hermes cron daemon --interval 60
    
  3. Verify the job executes (check hermes cron list for last_run_at)

  4. Stop with Ctrl+C

Related Issue

Fixes #41037 (Cron jobs never execute: last_run_at always null after manual trigger)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (standalone cron daemon mode)

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

Context for maintainers: This is a re-creation of original PR #41363 (previously #41167 after splitting the provider-config changes). That was caught in a circular close: the original was closed by the author to split into focused PRs, and the focused version was then flagged as a duplicate of the already-closed original. The fix landed in neither.

The underlying issue (#41037 — cron jobs never execute when gateway isn't running) is still open. This PR has been rebased on latest main (d1383a6).

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management labels Jun 11, 2026
@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

👋 @NousResearch/maintainers this PR has been rebased on latest main with 100% green CI across all checks (no failures).

This implements a standalone cron daemon mode so cron jobs execute without the gateway running (issue #41037). When the gateway isn't available, starts a lightweight scheduler that runs jobs independently.

Could a maintainer take a look?

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

@OutThisLife @austinpickett — this PR has been fully green and ready for review. Fixes #41037 (cron jobs don't execute without gateway). Could either of you take a look when you get a chance?

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for preserving the focused standalone-daemon idea. The feature is still absent on current main, but this version needs rework for the scheduler architecture that landed after its base.

Problems

  • cron_daemon() in this diff calls cron.scheduler.tick() directly. Current ticker entry points resolve and start the configured provider instead (cron/scheduler_provider.py:114-151, hermes_cli/web_server.py:150-154), so the proposed path would ignore an external cron.provider.
  • The parser adds --accept-hooks, but daemon is absent from hermes_cli/main.py:12408-12454; therefore agent startup skips plugin discovery and shell-hook registration.
  • The two-file diff has no tests or docs. Existing command coverage is in tests/hermes_cli/test_cron_parser_builder.py:26-34, and the public command list is website/docs/reference/cli-commands.md:527-543.

Suggested changes

  • Rebase the implementation concept on resolve_cron_scheduler().start(stop_event, interval=...), add daemon to the cron startup set, and add bounded lifecycle/provider tests plus documentation.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
- Add hermes cron daemon subcommand for headless/standalone operation
- Add gateway lifecycle command defense (#30719) in cron_create()
- Fix null-repeat bug in cron_list (job.get('repeat') or {})
- _GATEWAY_LIFECYCLE_PATTERNS to block gateway restart/stop/kill in cron jobs

Co-authored-by: Ash <alaamohanad169-ship-it@users.noreply.github.com>
@alaamohanad169-ship-it
alaamohanad169-ship-it force-pushed the fix/cron-daemon-standalone-clean branch from 0242f02 to 303fb57 Compare July 25, 2026 22:47
@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

👋 CI passing. Ready for review/merge when convenient. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron jobs never execute: last_run_at always null after manual trigger

3 participants