Skip to content

[Bug]: Cron systemEvent queued to wrong session key ('main' vs 'agent:main:main') #510

@STop211650

Description

@STop211650

Summary

Cron jobs with sessionTarget: "main" enqueue system events to session key "main", but Telegram heartbeats run in session key "agent:main:main". The queued event is never drained.

Steps to reproduce

  1. Create a cron job with sessionTarget: "main" and wakeMode: "now"
  2. Wait for the cron to fire
  3. Observe that the systemEvent is queued but never delivered to the agent

Expected behavior

The cron system event should be delivered to the active agent session and processed on the next heartbeat.

Actual behavior

  • Cron fires and calls enqueueSystemEvent(text) with no sessionKey → defaults to "main"
  • Heartbeats run under session key "agent:main:main" (for Telegram provider)
  • drainSystemEvents("agent:main:main") returns empty because events are queued under "main"
  • The cron shows lastStatus: "ok" and lastDurationMs: 1 (it completed instantly) but the task never executes

Evidence from sessions.json

{
  "main": { "sessionId": "fbeab70b-..." },
  "agent:main:main": { "sessionId": "72690105-...", "lastProvider": "telegram" }
}

The cron enqueues to "main" but heartbeats drain from "agent:main:main".

Environment

  • Clawdbot version: 2026.1.7 (built from source)
  • OS: macOS Darwin 24.6.0 (arm64)
  • Install method: pnpm build with ALLOW_ADHOC_SIGNING=1

Suggested fix

Either:

  1. Cron service should resolve the correct session key for the target agent (e.g., agent:main:main)
  2. Or drainSystemEvents should check both "main" and the provider-specific session key
  3. Or heartbeat processing should always drain "main" in addition to the current session

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