Skip to content

[Bug] Cron jobs with delivery.announce send duplicate messages (delivery + system message) #27018

@hong418884611

Description

@hong418884611

Bug Description

Cron jobs configured with delivery.announce mode send the same message twice:

  1. Once via delivery.announce (automatic delivery to configured channel)
  2. Once via System Message to the main agent (causing the agent to manually forward it again)

This causes duplicate messages in the target channel.

Expected Behavior

When a cron job has delivery.announce configured:

  • ✅ Deliver the result to the configured channel via delivery
  • ❌ Do NOT send a System Message to the main agent (since the result has already been sent)

When a cron job does NOT have delivery configured:

  • ✅ Send a System Message to the main agent so it can forward the result manually

Current Behavior

Currently, both happen:

  • Result is delivered via delivery.announce
  • System Message is sent to the main agent ❌
  • Main agent receives the System Message and forwards it again ❌

Result: Duplicate messages in the target channel

Use Case

This is particularly important in multi-agent environments with bindings.

Scenario:

User says in tech-group chat: "Create a cron job to send news every day at 9am"
  ↓
tech-group agent receives message (via bindings)
  ↓
tech-group creates the cron job
  ↓
But cron jobs are created in the main agent (OpenClaw limitation)
  ↓
At the scheduled time, the job executes in the main agent
  ↓
❓ Where should the result go?
   - If no `delivery` → the main agent receives a System Message, but where to forward?
   - If `delivery.to` is configured → the main agent delivers to the tech group

The delivery configuration is necessary to route the result to the correct group.

Reproduction Steps

  1. Create a cron job with delivery.announce configuration:
{
  "delivery": {
    "mode": "announce",
    "channel": "telegram",
    "to": "123456789"
  }
}
  1. Wait for the cron job to execute

  2. Observe that the message appears twice in the target channel:

    • First: Automatic delivery via delivery
    • Second: Manual forward from the agent after receiving the System Message

Suggested Fix

// In the cron job completion handler
if (task.delivery?.mode === 'announce') {
  // Result has been delivered via delivery.announce
  // Do not send System Message to the main agent
  return;
}

// Only send System Message for jobs without delivery
sendSystemMessage(task.result);

Temporary Workaround

In the agent's logic (AGENTS.md), when receiving a System Message:

  1. Extract jobId from sessionId (format: agent:main:cron:{jobId}:run:...)
  2. Read /Users/hong/.openclaw/cron/jobs.json
  3. Check if the job has delivery configuration
  4. If delivery.mode === 'announce' → Reply with NO_REPLY (already delivered)
  5. If no delivery → Process normally (forward manually)

Environment

  • OpenClaw version: 2026.2.24
  • Gateway mode: local
  • Agent configuration: Multiple agents with bindings (main, tech-group, invest-group)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions