NousResearch/hermes-agent · warning · ValueError
Invalid duration: '{s}'. Use format like '30m', '2h', or '1d
Error message
Invalid duration: '{s}'. Use format like '30m', '2h', or '1d' What it means
ValueError from parse_duration in cron/jobs.py: the string must fully match ^(\d+)\s*(m|min|...|h|hr|...|d|day|days)$ after lowercasing/stripping. Anything else — combined units ('1h30m'), '45', '0.5h', 'w' (weeks), or embedded text — fails. Returns minutes via multipliers m=1, h=60, d=1440.
Source
Thrown at cron/jobs.py:603
# =============================================================================
# Schedule Parsing
# =============================================================================
def parse_duration(s: str) -> int:
"""
Parse duration string into minutes.
Examples:
"30m" → 30
"2h" → 120
"1d" → 1440
"""
s = s.strip().lower()
match = re.match(r'^(\d+)\s*(m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days)$', s)
if not match:
raise ValueError(f"Invalid duration: '{s}'. Use format like '30m', '2h', or '1d'")
value = int(match.group(1))
unit = match.group(2)[0] # First char: m, h, or d
multipliers = {'m': 1, 'h': 60, 'd': 1440}
return value * multipliers[unit]
def parse_schedule(schedule: str) -> Dict[str, Any]:
"""
Parse schedule string into structured format.
Returns dict with:
- kind: "once" | "interval" | "cron"
- For "once": "run_at" (ISO timestamp)
- For "interval": "minutes" (int)
- For "cron": "expr" (cron expression)
View on GitHub (pinned to c896c09c42)
Solutions
- Use one integer + one unit: '30m', '2h', '1d' (long forms 'mins'/'hours'/'days' also accepted)
- Convert weeks to days (7d) and compound durations to the smallest unit ('1h30m' -> '90m')
- If a cron-style or timestamp schedule is wanted, pass a 5-field cron expression or ISO timestamp instead of a duration
Example fix
# before create_job(schedule="1h30m", ...) # ValueError: Invalid duration: '1h30m'. Use format like '30m', '2h', or '1d' # after create_job(schedule="90m", ...)
Defensive patterns
Strategy: validation
Validate before calling
import re
_DURATION_RE = re.compile(r"^(\d+)\s*(m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days)$")
def is_valid_duration(s: str) -> bool:
return bool(_DURATION_RE.match(s.strip().lower())) Try / catch
from cron.jobs import parse_duration
try:
minutes = parse_duration(raw)
except ValueError:
minutes = humanize_to_minutes(raw) # '1h30m' -> 90, then submit f"{minutes}m" Prevention
- Submit one integer plus one unit only; convert compound durations to minutes first
- Remember weeks are not supported — use '7d'
- Validate in the UI with the same single-unit regex
When it happens
Trigger: create_job(schedule='1h30m'), schedule='90', schedule='2 hours 15m', or schedule='1w' — all miss the single integer + single unit regex.
Common situations: Users typing compound durations; omitting the unit; asking for weeks which the parser doesn't support; passing a raw number from a config file.
Related errors
- Invalid cron expression '{schedule}': {e}
- Preview mode — launching is disabled.
- no install root
- ${isPosix ? 'install.sh --manifest' : 'install.ps1 -Manifest
- Remote connection is not ready yet. Try again in a moment.
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/f9375230a16e8b6a.
Report an issue: GitHub.