#5624: add support_human_readable_time_format in cron
docs
agents
Cluster:
Cron Enhancements and Fixes
## Summary
One-shot cron jobs (`schedule.kind: "at"`) no longer require callers to send Unix timestamps. Agents and tools can send a human-readable `at` string (and optional `tz`) instead, avoiding timestamp math and timezone mistakes.
## Problem
- Models struggle to convert phrases like "tomorrow 11pm" into correct Unix ms.
- Off-by-one or timezone errors can create jobs in the past, so they are marked `enabled: false` / `lastStatus: "ok"` without running (e.g. user: "提醒我睡觉" → job 1 minute after scheduled time).
## Solution
- **`schedule.at`** (string): ISO 8601 with offset (e.g. `2026-02-01T23:00:00+08:00`) or local datetime without offset (e.g. `2026-02-01 23:00:00`).
- **`schedule.tz`** (optional): IANA timezone when `at` has no trailing `Z` or offset (e.g. `Asia/Shanghai`).
- Gateway normalizes to `atMs` before validation and storage; existing `atMs` (number) remains supported.
## Changes
- **`src/cron/parse.ts`**: `parseAbsoluteTimeMs(input, tz?)` — optional `tz`; if set and string has no offset, interpret as local time in that IANA zone (Intl-only, no new deps). Round to whole seconds when input has no fractional part.
- **`src/cron/normalize.ts`**: Coerce `schedule.at` / `schedule.atMs` (string) using `schedule.tz`; strip `at` and `tz` from stored schedule.
- **`src/agents/tools/cron-tool.ts`**: Tool description updated to recommend human-readable `at` (with optional `tz`).
- **`docs/automation/cron-jobs.md`**: Schedules and JSON examples updated for `at` + `tz`.
- **Tests**: `src/cron/parse.test.ts` (new), `src/cron/normalize.test.ts` (new case for `at` + `tz`).
## Example
{ "kind": "at", "at": "2026-02-01T23:00:00+08:00" }
{ "kind": "at", "at": "2026-02-01 23:00:00", "tz": "Asia/Shanghai" }
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds support for specifying one-shot cron schedules as a human-readable `schedule.at` string (optionally with `schedule.tz` IANA timezone) instead of requiring callers to send epoch milliseconds. Gateway normalization now coerces `at`/string `atMs` into numeric `atMs` using the updated `parseAbsoluteTimeMs(input, tz?)`, and docs/tool descriptions are updated accordingly.
The change primarily touches the cron input normalization layer (`src/cron/normalize.ts`) and time parsing utilities (`src/cron/parse.ts`), with new tests covering ISO strings and timezone-local parsing behavior.
<h3>Confidence Score: 4/5</h3>
- This PR looks safe to merge after addressing one correctness issue around stripping `tz` during inferred-kind normalization.
- Core behavior (parsing/normalizing `at` to `atMs`) is localized and covered by new tests, but `normalize.ts` currently only deletes `tz` when the original input included `kind: "at"`, which can cause unexpected persisted fields when `kind` is inferred. The timezone parsing logic is non-trivial but appears deterministic and guarded against invalid IANA zones.
- src/cron/normalize.ts; src/cron/parse.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#8811: fix(cron): handle atMs fallback for kind=at jobs
by hlibr · 2026-02-04
85.2%
#11813: fix(cron): ensure 'at' schedule type correctly registers nextWakeAt...
by leo-reifying · 2026-02-08
83.4%
#9670: fix: handle numeric string timestamps in cron schedule normalizatio...
by divol89 · 2026-02-05
83.2%
#12303: fix(cron): correct nextRunAtMs calculation and prevent timer stall
by colddonkey · 2026-02-09
82.3%
#5428: fix(Cron): prevent one-shot loop on skip
by imshrishk · 2026-01-31
79.2%
#15754: fix: handle Unix timestamps in seconds in parseAbsoluteTimeMs
by MisterGuy420 · 2026-02-13
78.8%
#8698: fix(cron): default enabled to true for new jobs
by emmick4 · 2026-02-04
78.5%
#10836: feat(session_status): include ISO-8601 and Unix timestamps for sche...
by jeanlucthumm · 2026-02-07
78.2%
#7919: feat: implement timezone support for console timestamps and add ver...
by southpy · 2026-02-03
77.9%
#2071: fix: accept JSON string for cron.add job parameter (#1940)
by andrescardonas7 · 2026-01-26
77.8%