Repository navigation
tools: model-callable cron tool (opt-in, schedules installed skills) - #310
Conversation
Brings PasClaw to parity with picoclaw/nanobot/openclaw, which let the model schedule jobs -- previously PasClaw cron was operator-config-only. New 'cron' tool (action=list|add|remove) edits config.json's crons[]: add validates the cron expression (ParseCronExpr) and that the named skill is installed, generates an id, and persists. Bounded by design -- a cron entry only runs an EXISTING operator-installed skill, so the model can schedule but not author the work. Live activation without restart: the scheduler now keeps its own private copy of the entries and reloads them when config.json's mtime changes (one 30s tick), so model edits go live on a running serve/gateway. The reload is scheduler-thread-owned -- no cross-thread mutation of the shared TConfig, no lock, and the raw-JSON edit avoids LoadConfig/SaveConfig baking an active profile's resolved values into config.json. Off by default behind cron_tool_enabled (autonomy opt-in); registered in serve/gateway/agent. New cron_tool_tests pins add/list/remove + validation; live scheduler reload verified by inspection (no socket/thread in tests).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ee252ddfd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Result := Format('Scheduled cron "%s": skill "%s" on "%s". A running ' + | ||
| 'serve/gateway picks it up within ~30s; otherwise it activates on the ' + | ||
| 'next start.', [Id, Skill, Spec]); |
There was a problem hiding this comment.
Ensure scheduled jobs have a live scheduler
When this success path is used from pasclaw serve, no TCronScheduler is ever constructed in that command, and in pasclaw gateway the scheduler is only created at startup when Length(Cfg.Crons) > 0; so an opt-in server that starts with no crons can accept the first cron add but nothing in the running process will fire it until restart. This makes the tool report a live schedule even though the newly persisted job is inactive in the common empty-config case.
Useful? React with 👍 / 👎.
| Skills := LoadSkillManifests(GetHome); | ||
| for i := 0 to High(Skills) do | ||
| if SameText(Skills[i].Name, Name) then Exit(True); |
There was a problem hiding this comment.
Validate skills against the running registry
This accepts any skill currently present on disk, but TCronScheduler later runs jobs through the startup TToolRegistry via RunSkill(Reg, Entry.Skill, ...). If a skill was installed after the server started, for example by skills_manage with auto-approve or by an operator copying it into workspace/skills, the cron tool will schedule it successfully but each fire in the current process fails as unknown tool: skill_<name> until restart.
Useful? React with 👍 / 👎.
…egistry Two Codex P2s on #310: 1. The success path claimed a live schedule, but serve never constructed a TCronScheduler and gateway only started one when Length(Cfg.Crons) > 0 -- so an opt-in server starting with no crons accepted the first add but nothing fired it until restart. Now both serve and gateway start the scheduler when crons exist OR cron_tool_enabled is set (serve gains the scheduler lifecycle + teardown it never had, stopping the thread before the registry it fires through is freed). 2. SkillExists validated against on-disk manifests, but the scheduler runs jobs through the startup registry (Reg.RunTool('skill_<name>')). A skill installed after startup is on disk but not runnable in-process, so the tool would schedule a job that fails as unknown until restart. Validate against the live registry instead (RegisterCronTool stashes it; the same instance serve/gateway hand the scheduler), falling back to disk only when no registry is wired (unit tests).
The README + docs/changelog.md last entry was 2026-06-13 (FMXExpress#244). Five substantial PRs (FMXExpress#314 FMXExpress#315 FMXExpress#316 FMXExpress#317 FMXExpress#318) and ten more feature PRs between them and that entry shipped without changelog entries. This brings both files current through today. Twenty new entries (newest first, matching the existing style): 2026-06-21 FMXExpress#318 Relay pull-worker provider (queue + provider + /v1/relay/* HTTP) 2026-06-20 FMXExpress#317 pasclaw plan + build PLAN.md pickup + build --goal + cog mode FMXExpress#316 Cloudflare AI Gateway provider catalog rows FMXExpress#315 MCP progressive disclosure + tool_search FMXExpress#314 Stock defaults adopt lean-edit shape; fs_grep split-gate 2026-06-18 FMXExpress#312 Web UI workspace.zip export + import FMXExpress#310 Model-callable cron tool FMXExpress#309 FTS5 snippet window widened 24 -> 60 FMXExpress#307 Windows cmd.exe quoting fix 2026-06-17 FMXExpress#306 cog-build honours profile=security sandbox FMXExpress#304 cog-build default profile = max-build FMXExpress#303 cog-build list[Path] outputs + Secret inputs + -q 2026-06-16 FMXExpress#302 cog-build optional workspace_in FMXExpress#300 pasclaw build cmd + cog-build/ predictor (parent feature) FMXExpress#299 Checkpoints zpaq backend + /redo FMXExpress#298 AGENTS.md + pasclaw init + /init FMXExpress#297 tool_choice force-a-specific-tool form FMXExpress#296 Delphi ExtraEnv injection fix FMXExpress#295 KB native PDF ingest 2026-06-15 FMXExpress#292 pasclaw profile diff + bench Skipped per the changelog's stated convention ("Bug fixes and review follow-ups are in the full git log"): FMXExpress#293 cmd/profile dcc64 fix FMXExpress#294 skills_manage gemini empty-enum fix FMXExpress#301 cmd.build dcc64 fix FMXExpress#311 cron dcc64 fix Files updated identically (the docs/changelog.md note at the top says "This file mirrors the changelog section at the top of the root README.md"): M README.md 20 entries + 20 link refs added M docs/changelog.md same The link-ref block at the bottom of each file gained 20 [#NNN] entries keeping the existing one-per-line / sorted-numerically format.
Closes the capability gap from the tool comparison: picoclaw / nanobot / openclaw let the model schedule jobs, but PasClaw's cron was operator-config-only. This adds a model-callable
crontool — opt-in and bounded.The tool
cronwithaction:list/add/remove.{spec, skill, args?, id?}— validates the cron expression (ParseCronExpr) and thatskillis an installed skill, generates an id, and persists.Bounded by design: a cron entry only runs an existing, operator-installed skill on a schedule — the model can schedule work but can't author it (no arbitrary commands). And the whole tool is off unless
cron_tool_enabled=true(model-scheduled background execution is an autonomy step operators should opt into). It's registered inserve/gateway/agent, gated on that flag.Live activation without a lock or restart
The tool edits
config.json'scrons[]via raw JSON (deliberately notLoadConfig/SaveConfig, which would bake an active profile's resolved values into the file). The scheduler now keeps its own private copy of the entries and reloads it whenconfig.json's mtime changes — picked up within one ~30s tick on a runningserve/gateway. Because the reload happens only on the scheduler thread and never mutates the sharedTConfigthe gateway also reads, there's no cross-thread mutation and no lock. Inagent(no scheduler) additions simply apply the next time a server runs.Tests
New
cron_tool_tests(inmake test) seeds a tempPASCLAW_HOMEwith one skill and pins: empty list, add (→ config.json gains the entry), list shows it, duplicate-id refused, invalid cron-expression refused, unknown-skill refused, missing-fields refused, remove (→ entry gone), remove-missing refused, unknown/missing action. Full binary builds clean.Caveat: the live scheduler reload (mtime watch on its background thread) is verified by inspection, not a runtime test — this sandbox can't run the scheduler thread/server. The tool's config-mutation logic is fully unit-tested. A manual check on a running
servewithcron_tool_enabled=trueis worth doing before merge.https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6
Generated by Claude Code