#8315: fix(cron): Add 'none' option to postToMainMode to prevent duplicate messages
app: web-ui
gateway
cli
stale
Cluster:
Cron Job Enhancements
Fixes #8281
## Summary
Adds the `none` option to `isolation.postToMainMode` to prevent isolated cron jobs from automatically posting to the main session, eliminating duplicate messages.
## Problem
Cron jobs configured with `sessionTarget: "isolated"` were always posting a status message to the main session after completing, causing duplicate messages:
1. The isolated session delivers its message ✓
2. The main session **also** receives a system event and responds ✗
## Solution
Added `"none"` as a valid option for `isolation.postToMainMode`:
- **`none`**: Don't post to main session (isolated only) — **NEW**
- `summary`: Post status/summary line (existing default)
- `full`: Post full agent output (existing option)
## Changes
**Type definitions:**
- Updated `CronIsolation` type to include `"none"` in postToMainMode union
**Runtime logic:**
- Modified `timer.ts` to skip `enqueueSystemEvent` when `mode === "none"`
**Schema validation:**
- Updated TypeBox schema to validate `"none"` option
**CLI:**
- Updated help text: `--post-mode <mode>` now shows `(none|summary|full)`
- Updated validation to accept `"none"`
## Usage
### Config file:
```json
{
"id": "my-cron-job",
"sessionTarget": "isolated",
"isolation": {
"postToMainMode": "none"
},
"payload": {
"kind": "agentTurn",
"deliver": true,
"channel": "telegram"
}
}
```
### CLI:
```bash
openclaw cron add --name "Standup" --cron "0 10 * * *" --session isolated --post-mode none --message "Daily standup" --deliver --channel telegram
```
## Backward Compatibility
✅ Default behavior unchanged (`"summary"`) for existing jobs
✅ No breaking changes to existing API or config
✅ Purely additive — new option, no removals
## Testing
- Manually tested with isolated cron job + `postToMainMode: "none"`
- Confirmed main session no longer receives duplicate system events
- Existing behavior preserved when `postToMainMode` is `"summary"` or omitted
🤖 Generated by agent-2875bc2c833f via [AgentGit](https://github.com/agentgit)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Adds a new `"none"` option for `isolation.postToMainMode` so isolated cron jobs can avoid posting a completion/system event back into the main session (preventing duplicate messages). This change is wired through the cron type definitions, gateway TypeBox schema validation, the timer execution logic (skip `enqueueSystemEvent` when mode is `"none"`), and the cron-add CLI help/argument parsing.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge and does what it claims with low behavioral risk.
- Changes are small and consistent across types/schema/runtime. Main risk area is UX: the CLI currently silently accepts invalid `--post-mode` values and falls back to default behavior, which can hide misconfiguration but won’t break runtime execution.
- src/cli/cron-cli/register.cron-add.ts
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#23501: fix(cron): force new session ID for isolated cron jobs (#23470)
by stakeswky · 2026-02-22
76.6%
#23562: feat: add sessionFreshness config for isolated cron jobs (#23539)
by MunemHashmi · 2026-02-22
76.3%
#21896: fix(cron): disable messaging tool when delivery.mode is none
by lailoo · 2026-02-20
76.2%
#6315: fix(cron): persist isolated sessions (fixes #6217) - attempt 2
by ChaitanyaSai-Meka · 2026-02-01
75.8%
#23699: fix(cron): isolated sessions must generate fresh UUID on every run ...
by echoVic · 2026-02-22
74.8%
#13383: fix(cron): route text-only payloads through direct delivery
by Masha-L · 2026-02-10
74.2%
#16511: feat(cron): support custom session IDs and auto-bind to current ses...
by kkhomej33-netizen · 2026-02-14
73.9%
#8341: feat: add per-job cache control for cron jobs
by vishaltandale00 · 2026-02-03
73.0%
#8097: fix: auto-convert one-shot reminders for reliable delivery
by Gerrald12312 · 2026-02-03
72.7%
#16390: fix(cron): jobs land in wrong agent session when agentId isn't in a...
by yinghaosang · 2026-02-14
72.6%