fix(cron): warn user when creating cron job if gateway is not running#2793
fix(cron): warn user when creating cron job if gateway is not running#2793ygd58 wants to merge 4 commits into
Conversation
|
The test failure is a dependency resolution error in the CI environment (hermes-agent[all]==0.4.0 cannot be used), not caused by this PR's changes to cronjob_tools.py. This appears to be a pre-existing CI infrastructure issue. |
| "next_run_at": job["next_run_at"], | ||
| "job": _format_job(job), | ||
| "message": f"Cron job '{job['name']}' created.", | ||
| "warning": _check_cron_ticker_warning(), |
There was a problem hiding this comment.
I'm not able to find the function _check_cron_ticker_warning in the code base. Is this func defined?
There was a problem hiding this comment.
Thanks for catching that! The function definition was missing from the commit. Fixed in the latest push — _check_cron_ticker_warning() is now defined at line 141 in cronjob_tools.py.
| ) | ||
| except Exception: | ||
| pass | ||
| return None |
There was a problem hiding this comment.
The return type is not included None
not sure if the type requirement in this repo. If it is strict, then we need to change the return type to str | None
There was a problem hiding this comment.
Good catch! Fixed changed return type to Optional[str] which correctly reflects that the function can return either a warning string or None.
Fixes #2788
Root Cause
Cron jobs only fire automatically when the gateway is running. In CLI-only mode, the cron ticker is never started, so jobs never execute. Users creating cron jobs via CLI had no indication of this.
Fix
Added
_check_cron_ticker_warning()that checks if the gateway is running viaget_running_pid(). When a cron job is created and the gateway is NOT running, the response includes awarningfield:The LLM sees this warning and can relay it to the user.