Skip to content

cron: systemEvent on main session silently ignores shell commands in payload text #63107

Description

@liaoandi

Problem

Cron jobs configured with sessionTarget: "main" + payload.kind: "systemEvent" + wakeMode: "next-heartbeat" fire successfully (status: ok, durationMs: 1–8ms) but never actually execute shell commands contained in the payload text.

For example, a job with payload.text: "run: python3 /path/to/script.py" will be recorded as ok but the script will never run. The system event is dispatched to the main agent session, but the agent's systemEvent handler only acknowledges the event — it does not parse or execute shell commands from system event text.

There is no documentation warning, no validation error at job creation time, and no indication in the run log that the command was not executed.

Working workaround: Use sessionTarget: "isolated" + payload.kind: "agentTurn" + wakeMode: "now" to actually run scripts.

Root Cause

executeMainSessionCronJob in src/cron/service/timer.ts calls enqueueSystemEvent(text, ...) and immediately returns { status: "ok" }. System events on the main session are intended for lightweight agent notifications/context injections, not for executing arbitrary commands. The payload text is passed as-is to the agent's system event queue, and the main agent does not treat system event text as executable instructions.

Users who read the docs or examples for --system-event may reasonably assume the text will be executed as a command if it contains shell syntax (python3, bash, uv run, etc.).

Proposed Fix

Add a validation warning at cron add / cron edit time in src/cli/cron-cli/register.cron-add.ts and src/cli/cron-cli/register.cron-edit.ts:

When sessionTarget === "main" (or inferred) + payload.kind === "systemEvent" and the payload text contains shell command heuristics (python3, bash, node, uv run, sh , ./, etc.), print a warning to stderr:

Warning: --system-event on --session main does not execute shell commands.
  The text is dispatched as a notification to the main agent session.
  To run a script, use: --message "..." --session isolated --wake now

This is a non-blocking warning (the job is still created), not a hard error.

Files to change

  • src/cli/cron-cli/register.cron-add.ts — add warning after payload + sessionTarget are resolved
  • src/cli/cron-cli/register.cron-edit.ts — add same warning when --system-event + --session main are both set

Acceptance Criteria

  • cron add --system-event "python3 foo.py" --session main prints a warning to stderr
  • cron add --system-event "hello world" (no shell heuristic) does not warn
  • cron add --message "run python3 foo.py" --session isolated does not warn
  • Warning is printed before the RPC call so it appears even in --json mode
  • Existing tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions