openclaw - ✅(Solved) Fix cron: systemEvent on main session silently ignores shell commands in payload text [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#63107Fetched 2026-04-09 07:58:28
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
referenced ×2cross-referenced ×1

Error Message

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. This is a non-blocking warning (the job is still created), not a hard error.

  • cron add --system-event "hello world" (no shell heuristic) does not warn
  • cron add --message "run python3 foo.py" --session isolated does not warn

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.).

Fix Action

Fix / Workaround

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.

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

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

PR fix notes

PR #63112: fix(cron): warn when --system-event on main session contains shell commands

Description (problem / solution / changelog)

Summary

  • cron add --system-event "python3 script.py" --session main (and similar) currently creates the job silently without warning that the script will never run
  • Adds looksLikeShellCommand() helper with SHELL_COMMAND_PATTERN regex matching common shell runtimes (python3, bash, node, uv run, npx, etc.)
  • Emits a non-blocking stderr warning in both registerCronAddCommand and registerCronEditCommand when sessionTarget === "main" + payload.kind === "systemEvent" + shell heuristic matches

Fixes #63107

Root Cause

System events on the main session are dispatched as context notifications to the agent — they are not executed as shell commands. Users who pass shell command syntax via --system-event on --session main get a silently non-functional job with no indication of the limitation.

Changes

  • src/cli/cron-cli/register.cron-add.ts: Added SHELL_COMMAND_PATTERN, looksLikeShellCommand(), and pre-RPC warning block
  • src/cli/cron-cli/register.cron-edit.ts: Same pattern — mirrors the warning for edit operations when --system-event + --session main are both provided

Test plan

  • cron add --name test --every 10m --system-event "python3 foo.py" --session main prints warning to stderr
  • cron add --name test --every 10m --system-event "hello world" --session main does NOT print warning
  • cron add --name test --every 10m --message "run python3 foo.py" --session isolated does NOT print warning
  • cron edit <id> --system-event "bash script.sh" --session main prints warning to stderr
  • Warning is non-blocking — job is still created/updated
  • Existing CLI and cron service tests pass

🤖 Generated with Claude Code

Changed files

  • src/cli/cron-cli/register.cron-add.ts (modified, +20/-0)
  • src/cli/cron-cli/register.cron-edit.ts (modified, +38/-1)
  • src/cli/cron-cli/shared.ts (modified, +12/-0)

Code Example

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
RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

To fix the issue where cron jobs with sessionTarget: "main" and payload.kind: "systemEvent" do not execute shell commands, add a validation warning at job creation time and consider using sessionTarget: "isolated" instead.

Guidance

  • Add a warning in src/cli/cron-cli/register.cron-add.ts and src/cli/cron-cli/register.cron-edit.ts when sessionTarget === "main" and payload.kind === "systemEvent" with shell command heuristics in the payload text.
  • Use sessionTarget: "isolated" and payload.kind: "agentTurn" with wakeMode: "now" as a workaround to execute shell commands.
  • Verify the fix by checking for the warning message when creating a cron job with sessionTarget: "main" and payload.kind: "systemEvent" containing shell commands.

Example

// src/cli/cron-cli/register.cron-add.ts
if (sessionTarget === "main" && payload.kind === "systemEvent" && containsShellHeuristics(payload.text)) {
  console.warn("Warning: --system-event on --session main does not execute shell commands.");
}

Notes

  • The proposed fix only adds a warning and does not prevent the creation of the cron job.
  • The workaround using sessionTarget: "isolated" may have different behavior and implications than the original sessionTarget: "main".

Recommendation

Apply workaround: Use sessionTarget: "isolated" and payload.kind: "agentTurn" with wakeMode: "now" to execute shell commands, as this is a more reliable and intended way to run scripts.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING