Skip to content

fix(cron): add seconds support to parse_duration - #44871

Open
Code-suphub wants to merge 2 commits into
NousResearch:mainfrom
Code-suphub:fix/44749-cron-seconds-support
Open

fix(cron): add seconds support to parse_duration#44871
Code-suphub wants to merge 2 commits into
NousResearch:mainfrom
Code-suphub:fix/44749-cron-seconds-support

Conversation

@Code-suphub

@Code-suphub Code-suphub commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

parse_duration only accepts m/h/d units. When the LLM constructs a sub-minute schedule like "10s" or "30s", it raises ValueError, causing the cron job creation to fail silently or produce an incorrect timestamp.

Fixes #44749

Changes

cron/jobs.py:

  1. parse_duration — Add s/sec/secs/second/seconds to the regex and multiplier map ('s': 1/60). Return value remains in minutes (fractional for sub-minute) to preserve backward compatibility.

  2. parse_schedule — Use timedelta(seconds=total_seconds) instead of timedelta(minutes=minutes) for sub-minute precision. Update display text and error message to include seconds examples.

  3. Interval display — Show "every 30s" instead of "every 0.5m" for sub-minute recurring schedules.

Examples

"10s"       → once in 10 seconds
"30s"       → once in 30 seconds
"every 30s" → recurring every 30 seconds
"30m"       → once in 30 minutes (unchanged)
"2h"        → once in 2 hours (unchanged)

Testing

cd hermes-agent && python -m pytest tests/cron/test_jobs.py -v -k "parse"

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Checklist

Code

Documentation

  • I have updated relevant documentation or marked as N/A
  • I have updated cli-config.yaml.example if I added/changed config keys or marked as N/A

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
Code-suphub force-pushed the fix/44749-cron-seconds-support branch from 82db152 to a252fe2 Compare June 12, 2026 11:42
- 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 tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management duplicate This issue or pull request already exists labels Jun 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #44751 (earlier open, same author) — same fix for #44749: add seconds units to parse_duration. #44751 also adds LLM guidance away from absolute timestamps.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for addressing the relative-duration parser gap.

Problems

  • This does not yet provide sub-minute execution: the built-in ticker is explicitly 60 seconds in cron/jobs.py:85, and cron/scheduler_provider.py:176-194 runs one tick then waits that interval. A parsed 10s job can therefore be discovered up to roughly a minute later.
  • The proposed fractional minutes representation also reaches blueprint export. tools/blueprints.py:261 calls _schedule_to_string, where int(schedule["minutes"]) at line 314 turns a 30-second interval (0.5) into 0 and renders every 0h at lines 315-317.
  • The diff changes no tests; current parser coverage in tests/cron/test_jobs.py:33-113 has no seconds cases.

Suggested changes

  • Establish a scheduler-level sub-minute dispatch contract before accepting seconds syntax, then preserve that representation through serialization and add deterministic parser, scheduling, and export regression tests.

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
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 duplicate This issue or pull request already exists 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/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: cron relative timestamps fail for sub-minute schedules (e.g. 'in 10 seconds')

4 participants