fix(cron): add seconds support to parse_duration - #44871
Open
Code-suphub wants to merge 2 commits into
Open
Conversation
parse_duration only accepted m/h/d units. When the LLM constructs a sub-minute schedule like '10s' or '30s', it raised ValueError. - Add s/sec/secs/second/seconds to the regex and multiplier map - Use timedelta(seconds=) in parse_schedule for sub-minute precision - Update display and error messages to include seconds examples Fixes NousResearch#44749
Code-suphub
force-pushed
the
fix/44749-cron-seconds-support
branch
from
June 12, 2026 11:42
82db152 to
a252fe2
Compare
- Fix type annotation from -> int to -> float (seconds produce fractional minutes) - Use timedelta(seconds=) in compute_next_run for interval schedules so sub-minute recurring jobs (e.g. 'every 30s') compute correctly
tonydwb
approved these changes
Jun 12, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Good feature addition. Adds seconds support to parse_duration for sub-minute cron intervals. Return type changed from int to float. All usages updated to handle fractional minutes (max(1, round(minutes * 60)) ensures sub-minute intervals work correctly). No issues found.
Collaborator
Contributor
|
Thanks for addressing the relative-duration parser gap. Problems
Suggested changes
Automated hermes-sweeper review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parse_durationonly acceptsm/h/dunits. When the LLM constructs a sub-minute schedule like"10s"or"30s", it raisesValueError, causing the cron job creation to fail silently or produce an incorrect timestamp.Fixes #44749
Changes
cron/jobs.py:parse_duration— Adds/sec/secs/second/secondsto the regex and multiplier map ('s': 1/60). Return value remains in minutes (fractional for sub-minute) to preserve backward compatibility.parse_schedule— Usetimedelta(seconds=total_seconds)instead oftimedelta(minutes=minutes)for sub-minute precision. Update display text and error message to include seconds examples.Interval display — Show
"every 30s"instead of"every 0.5m"for sub-minute recurring schedules.Examples
Testing
Type of Change
Checklist
Code
fix(scope): description)Documentation
cli-config.yaml.exampleif I added/changed config keys or marked as N/A