Skip to content

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

Closed as not planned

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

Activity

  1. openclaw-barnacle commented on Apr 29, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  2. added
    stale
    on Apr 29, 2026
  3. clawsweeper commented on Apr 29, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

    Close as superseded by the newer durable routines design item: current main still lacks the literal agents.list[].cron field, but the remaining scheduling-product question is now tracked by the maintainer-labeled routine registry issue, which explicitly treats direct agent-config routines as an overlapping but weaker shape.

    Root-cause cluster
    Relationship: superseded
    Canonical: #98515
    Summary: The newer durable routines issue is the canonical tracker for the recurring scheduled-operations product direction; this issue's direct agent-config cron shape is an overlapping alternative that the canonical issue explicitly calls harder for mutation and status visibility.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Canonical path: Use #98515 as the canonical design path for recurring scheduled operations, with schedule-backed routines compiling to the existing SQLite-backed cron scheduler; revisit declarative seed config only after routine ownership, reconciliation, and mutation semantics are decided.

    So I’m closing this here and keeping the remaining discussion on #98515.

    Review details

    Best possible solution:

    Use #98515 as the canonical design path for recurring scheduled operations, with schedule-backed routines compiling to the existing SQLite-backed cron scheduler; revisit declarative seed config only after routine ownership, reconciliation, and mutation semantics are decided.

    Do we have a high-confidence way to reproduce the issue?

    Not applicable as a bug reproduction: this requests a new public config field. Source inspection confirms current main does not define or load agents.list[].cron.

    Is this the best way to solve the issue?

    No for the literal proposed shape as the current best path: the newer durable routines design preserves one scheduler source and gives mutable status visibility. If declarative config is still desired later, it should be designed as a reconciliation or seed layer over routines/cron, not as a second runtime source of truth.

    Security review:

    Security review: No patch is under review, and this ordinary feature request does not itself report a security vulnerability.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Current agent type has no cron field: AgentConfig includes per-agent workspace, model, skills, heartbeat, sandbox, tools, and runtime fields, but no cron or scheduled-task field. (src/config/types.agents.ts:81, 1d839d33397d)
    • Current schema rejects the proposed key: AgentEntrySchema enumerates accepted agents.list[] keys without cron and ends with .strict(), so the requested config shape is not accepted by current main. (src/config/zod-schema.agent-runtime.ts:1033, 1d839d33397d)
    • Current cron startup uses the cron store: buildGatewayCronService resolves cfg.cron?.store and cfg.cron?.enabled before constructing CronService; it uses agent IDs for execution routing, not declarative agents.list[].cron loading. (src/gateway/server-cron.ts:190, 1d839d33397d)
    • Docs describe the current scheduler source: Scheduled-task docs say jobs, runtime state, and run history persist in the shared SQLite state database, and active changes should use openclaw cron or Gateway cron RPCs rather than editing legacy jobs.json. Public docs: docs/automation/cron-jobs.md. (docs/automation/cron-jobs.md:42, 1d839d33397d)
    • Canonical newer product direction: The newer maintainer-labeled issue proposes a SQLite-backed durable routine registry that compiles schedule triggers to cron and explicitly says direct agent-config routines overlap this request but make mutation and status visibility harder.
    • Candidate implementation is still open: The related routines PR closes the newer routines issue, but it is an open draft and currently conflicting, so it is product-direction evidence rather than an implemented fix.

    Likely related people:

    • steipete: Authored the newer durable routines issue that now owns the product direction, and has recent cron SQLite/storage and scheduler-area commits. (role: product direction and scheduler storage contributor; confidence: high; commits: 005da57957c9, 445976ed49d0; files: src/cron/store.ts, docs/automation/cron-jobs.md, src/gateway/server-cron.ts)
    • joshavant: Authored the merged agent cron caller-scope work that changed how agent-originated cron operations are owned and filtered. (role: recent cron ownership contributor; confidence: high; commits: cee2aca40912; files: src/gateway/server-methods/cron.ts, src/agents/tools/cron-tool.ts, packages/gateway-protocol/src/cron-validators.test.ts)
    • Takhoffman: Authored the merged cron edit parity, run history, and management-surface work that this request would extend. (role: historical cron management contributor; confidence: high; commits: 77c3b142a966; files: src/cron/run-log.ts, src/cron/service/ops.ts, src/gateway/server-methods/cron.ts)

    Codex review notes: model internal, reasoning high; reviewed against 1d839d33397d.

  4. removed
    stale
    on Apr 30, 2026
  5. added
    P2
    clawsweeper:no-new-fix-pr
    clawsweeper:fix-shape-clear
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    issue-rating: 🌊 off-meta tidepool
    and removed
    clawsweeper:fix-shape-clear
    on May 16, 2026
  6. openclaw-barnacle commented on Jun 8, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  7. added
    stale
    on Jun 8, 2026
  8. added
    impact:other
    on Jun 13, 2026
  9. removed
    stale
    on Jun 14, 2026
  10. added
    clawsweeper:fix-shape-clear
    and removed
    clawsweeper:fix-shape-clear
    on Jun 14, 2026
  11. locked as resolved and limited conversation to collaborators on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:needs-maintainer-reviewclawsweeper:needs-product-decisionclawsweeper:no-new-fix-primpact:otherissue-rating: 🌊 off-meta tidepool

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions