Problem
Currently, all cron jobs are stored centrally in ~/.openclaw/cron/jobs.json at the Gateway layer, detached from Agent configuration. While jobs can be bound to an agent via agentId, the task ownership and configuration are separated, causing:
- Configuration fragmentation: Agent settings (workspace, model, tools) are in
openclaw.json, but their scheduled tasks are in a separate file
- Ownership ambiguity: In multi-agent setups, it's unclear which Agent "owns" which tasks
- Management overhead: Tasks must be managed via CLI (
openclaw cron add/edit) rather than declarative config
Current Architecture
Gateway Layer
├── cron/jobs.json ← All tasks here
│ └── job.agentId: "main" ← Can bind to Agent
└── openclaw.json
└── agents.list[] ← No cron field
Agent Layer
├── workspace/AGENTS.md
├── workspace/SOUL.md
└── ❌ No native scheduled task definition
Proposed Solution
Add a cron field to agents.list[] configuration:
{
agents: {
list: [{
id: "main",
workspace: "~/.openclaw/workspace",
model: "anthropic/claude-opus-4-6",
// NEW: Agent-owned scheduled tasks
cron: [{
id: "daily-news",
schedule: "0 13 * * *",
tz: "Asia/Shanghai",
message: "Execute news briefing",
enabled: true
}, {
id: "health-check",
schedule: "*/30 * * * *",
message: "Check system health",
sessionTarget: "isolated",
delivery: { mode: "none" }
}]
}]
}
}
Behavior
- On Gateway startup: Scan all
agents.list[].cron and load into scheduler
- Task ID namespacing: Internally prefix with
agent:<id>:<cronId> to avoid collisions
- Inheritance: Tasks inherit Agent's workspace, model, and tool settings
- Backward compatibility: Existing
cron/jobs.json continues to work; Agent-defined tasks are merged
- Precedence: If same task ID exists in both locations, CLI-defined (jobs.json) takes precedence
Benefits
- Colocation: Agent config and its scheduled tasks are together
- Declarative: Can version-control Agent + tasks as a unit
- Portability: Copy Agent workspace + config = copy all related scheduled tasks
- Multi-tenant clarity: Each Agent's tasks are clearly defined in its config
Alternative Considered
Continue using agentId binding on CLI-managed jobs. This works but keeps configuration fragmented. The proposed solution follows the principle of "Agent autonomy" - an Agent's behavior should be fully defined in its configuration.
Related
- Current cron implementation:
docs/automation/cron-jobs.md
- Multi-agent routing:
docs/concepts/multi-agent.md
Problem
Currently, all cron jobs are stored centrally in
~/.openclaw/cron/jobs.jsonat the Gateway layer, detached from Agent configuration. While jobs can be bound to an agent viaagentId, the task ownership and configuration are separated, causing:openclaw.json, but their scheduled tasks are in a separate fileopenclaw cron add/edit) rather than declarative configCurrent Architecture
Proposed Solution
Add a
cronfield toagents.list[]configuration:Behavior
agents.list[].cronand load into scheduleragent:<id>:<cronId>to avoid collisionscron/jobs.jsoncontinues to work; Agent-defined tasks are mergedBenefits
Alternative Considered
Continue using
agentIdbinding on CLI-managed jobs. This works but keeps configuration fragmented. The proposed solution follows the principle of "Agent autonomy" - an Agent's behavior should be fully defined in its configuration.Related
docs/automation/cron-jobs.mddocs/concepts/multi-agent.md