You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eff3c5c
Browse filesBrowse the repository at this point in the historyBrowse files
- Providers/Vercel AI Gateway: accept Claude shorthand model refs (`vercel-ai-gateway/claude-*`) by normalizing to canonical Anthropic-routed model ids. (#23985) Thanks @sallyom, @markbooch, and @vincentkoc.
- Gateway/HTTP security headers: add optional `gateway.http.securityHeaders.strictTransportSecurity` support to emit `Strict-Transport-Security` for direct HTTPS deployments, with runtime wiring, validation, tests, and hardening docs.
14
+
- Sessions/Cron: harden session maintenance with `openclaw sessions cleanup`, per-agent store targeting, disk-budget controls (`session.maintenance.maxDiskBytes` / `highWaterBytes`), and safer transcript/archive cleanup + run-log retention behavior. (#24753) thanks @gumadeiras.
- Run history: `~/.openclaw/cron/runs/<jobId>.jsonl` (JSONL, auto-pruned).
352
+
- Run history: `~/.openclaw/cron/runs/<jobId>.jsonl` (JSONL, auto-pruned by size and line count).
353
+
- Isolated cron run sessions in `sessions.json` are pruned by `cron.sessionRetention` (default `24h`; set `false` to disable).
353
354
- Override store path: `cron.store` in config.
354
355
355
356
## Configuration
@@ -362,10 +363,21 @@ Notes:
362
363
maxConcurrentRuns:1, // default 1
363
364
webhook:"https://example.invalid/legacy", // deprecated fallback for stored notify:true jobs
364
365
webhookToken:"replace-with-dedicated-webhook-token", // optional bearer token for webhook mode
366
+
sessionRetention:"24h", // duration string or false
367
+
runLog: {
368
+
maxBytes:"2mb", // default 2_000_000 bytes
369
+
keepLines:2000, // default 2000
370
+
},
365
371
},
366
372
}
367
373
```
368
374
375
+
Run-log pruning behavior:
376
+
377
+
-`cron.runLog.maxBytes`: max run-log file size before pruning.
378
+
-`cron.runLog.keepLines`: when pruning, keep only the newest N lines.
379
+
- Both apply to `cron/runs/<jobId>.jsonl` files.
380
+
369
381
Webhook behavior:
370
382
371
383
- Preferred: set `delivery.mode: "webhook"` with `delivery.to: "https://..."` per job.
@@ -380,6 +392,85 @@ Disable cron entirely:
380
392
-`cron.enabled: false` (config)
381
393
-`OPENCLAW_SKIP_CRON=1` (env)
382
394
395
+
## Maintenance
396
+
397
+
Cron has two built-in maintenance paths: isolated run-session retention and run-log pruning.
398
+
399
+
### Defaults
400
+
401
+
-`cron.sessionRetention`: `24h` (set `false` to disable run-session pruning)
402
+
-`cron.runLog.maxBytes`: `2_000_000` bytes
403
+
-`cron.runLog.keepLines`: `2000`
404
+
405
+
### How it works
406
+
407
+
- Isolated runs create session entries (`...:cron:<jobId>:run:<uuid>`) and transcript files.
408
+
- The reaper removes expired run-session entries older than `cron.sessionRetention`.
409
+
- For removed run sessions no longer referenced by the session store, OpenClaw archives transcript files and purges old deleted archives on the same retention window.
410
+
- After each run append, `cron/runs/<jobId>.jsonl` is size-checked:
411
+
- if file size exceeds `runLog.maxBytes`, it is trimmed to the newest `runLog.keepLines` lines.
412
+
413
+
### Performance caveat for high volume schedulers
414
+
415
+
High-frequency cron setups can generate large run-session and run-log footprints. Maintenance is built in, but loose limits can still create avoidable IO and cleanup work.
416
+
417
+
What to watch:
418
+
419
+
- long `cron.sessionRetention` windows with many isolated runs
420
+
- high `cron.runLog.keepLines` combined with large `runLog.maxBytes`
421
+
- many noisy recurring jobs writing to the same `cron/runs/<jobId>.jsonl`
422
+
423
+
What to do:
424
+
425
+
- keep `cron.sessionRetention` as short as your debugging/audit needs allow
426
+
- keep run logs bounded with moderate `runLog.maxBytes` and `runLog.keepLines`
427
+
- move noisy background jobs to isolated mode with delivery rules that avoid unnecessary chatter
428
+
- review growth periodically with `openclaw cron runs` and adjust retention before logs become large
429
+
430
+
### Customize examples
431
+
432
+
Keep run sessions for a week and allow bigger run logs:
433
+
434
+
```json5
435
+
{
436
+
cron: {
437
+
sessionRetention:"7d",
438
+
runLog: {
439
+
maxBytes:"10mb",
440
+
keepLines:5000,
441
+
},
442
+
},
443
+
}
444
+
```
445
+
446
+
Disable isolated run-session pruning but keep run-log pruning:
447
+
448
+
```json5
449
+
{
450
+
cron: {
451
+
sessionRetention:false,
452
+
runLog: {
453
+
maxBytes:"5mb",
454
+
keepLines:3000,
455
+
},
456
+
},
457
+
}
458
+
```
459
+
460
+
Tune for high-volume cron usage (example):
461
+
462
+
```json5
463
+
{
464
+
cron: {
465
+
sessionRetention:"12h",
466
+
runLog: {
467
+
maxBytes:"3mb",
468
+
keepLines:1500,
469
+
},
470
+
},
471
+
}
472
+
```
473
+
383
474
## CLI quickstart
384
475
385
476
One-shot reminder (UTC ISO, auto-delete after success):
Copy file name to clipboardExpand all lines: docs/cli/cron.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,11 @@ Note: one-shot (`--at`) jobs delete after success by default. Use `--keep-after-
23
23
24
24
Note: recurring jobs now use exponential retry backoff after consecutive errors (30s → 1m → 5m → 15m → 60m), then return to normal schedule after the next successful run.
25
25
26
+
Note: retention/pruning is controlled in config:
27
+
28
+
-`cron.sessionRetention` (default `24h`) prunes completed isolated run sessions.
Copy file name to clipboardExpand all lines: docs/cli/doctor.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ Notes:
27
27
28
28
- Interactive prompts (like keychain/OAuth fixes) only run when stdin is a TTY and `--non-interactive` is **not** set. Headless runs (cron, Telegram, no terminal) will skip prompts.
29
29
-`--fix` (alias for `--repair`) writes a backup to `~/.openclaw/openclaw.json.bak` and drops unknown config keys, listing each removal.
30
+
- State integrity checks now detect orphan transcript files in the sessions directory and can archive them as `.deleted.<timestamp>` to reclaim space safely.
`openclaw sessions cleanup` uses `session.maintenance` settings from config:
62
+
63
+
- Scope note: `openclaw sessions cleanup` maintains session stores/transcripts only. It does not prune cron run logs (`cron/runs/<jobId>.jsonl`), which are managed by `cron.runLog.maxBytes` and `cron.runLog.keepLines` in [Cron configuration](/automation/cron-jobs#configuration) and explained in [Cron maintenance](/automation/cron-jobs#maintenance).
64
+
65
+
-`--dry-run`: preview how many entries would be pruned/capped without writing.
66
+
- In text mode, dry-run prints a per-session action table (`Action`, `Key`, `Age`, `Model`, `Flags`) so you can see what would be kept vs removed.
67
+
-`--enforce`: apply maintenance even when `session.maintenance.mode` is `warn`.
68
+
-`--active-key <key>`: protect a specific active key from disk-budget eviction.
69
+
-`--agent <id>`: run cleanup for one configured agent store.
70
+
-`--all-agents`: run cleanup for all configured agent stores.
71
+
-`--store <path>`: run against a specific `sessions.json` file.
72
+
-`--json`: print a JSON summary. With `--all-agents`, output includes one summary per store.
0 commit comments