Skip to content

Feature Request: Add cron field to Agent configuration for Agent-owned scheduled tasks #46590

@roamer-remote

Description

@roamer-remote

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:

  1. Configuration fragmentation: Agent settings (workspace, model, tools) are in openclaw.json, but their scheduled tasks are in a separate file
  2. Ownership ambiguity: In multi-agent setups, it's unclear which Agent "owns" which tasks
  3. 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

  1. On Gateway startup: Scan all agents.list[].cron and load into scheduler
  2. Task ID namespacing: Internally prefix with agent:<id>:<cronId> to avoid collisions
  3. Inheritance: Tasks inherit Agent's workspace, model, and tool settings
  4. Backward compatibility: Existing cron/jobs.json continues to work; Agent-defined tasks are merged
  5. Precedence: If same task ID exists in both locations, CLI-defined (jobs.json) takes precedence

Benefits

  1. Colocation: Agent config and its scheduled tasks are together
  2. Declarative: Can version-control Agent + tasks as a unit
  3. Portability: Copy Agent workspace + config = copy all related scheduled tasks
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions