-
-
Notifications
You must be signed in to change notification settings - Fork 52.6k
Description
Summary
When a cron job uses sessions_spawn to create a subagent, the subagent is spawned successfully but does not send output. The cron job completes with only a status message indicating the subagent was started, without the actual task results.
Steps to reproduce
- Create a cron job with the following configuration:
openclaw cron add \
--name "搜索新闻测试-子代理" \
--at "2026-02-24T04:50:28Z" \
--delete-after-run \
--session isolated \
--deliver \
--message "使用 sessions_spawn 创建子代理,agentId 设为 grok,model 设为 grok/grok-4.20-beta,task 内容为:请搜索并用中文总结今天关于「马斯克、OpenAI、DeepSeek」三个人物的最新新闻、X动态、热搜,用 bullet point 格式,每人最多 5 条,附来源链接。" \
--channel telegram \
--to "7966882940"- Wait for the cron job to execute
- Check the delivered result
Expected behavior
The cron job should:
- Spawn the Grok subagent with the specified task
- Wait for the subagent to complete the search task
- Deliver the actual search results (news summary with bullet points and links) to the user
Actual behavior
The subagent executes the task successfully (confirmed by checking subagent session history), but the actual search results are never delivered to the user. The subagent's output is not routed back to the cron job's delivery channel.
OpenClaw version
2026.2.23
Operating system
Linux 6.8.0-51-generic (x64) - Docker container on Zeabur
Install method
Docker container deployment
Logs, screenshots, and evidence
**Cron job configuration** (`/home/node/.openclaw/cron/jobs.json`):
{
"id": "574a793e-5cbb-427a-ab00-3015b3642e62",
"name": "搜索新闻测试-子代理",
"enabled": true,
"deleteAfterRun": true,
"createdAtMs": 1771908517981,
"updatedAtMs": 1771908517981,
"schedule": {
"kind": "at",
"at": "2026-02-24T04:50:28.000Z"
},
"sessionTarget": "isolated",
"wakeMode": "now",
"payload": {
"kind": "agentTurn",
"message": "使用 sessions_spawn 创建子代理,agentId 设为 grok,model 设为 grok/grok-4.20-beta,task 内容为:请搜索并用中文总结今天关于「马斯克、OpenAI、DeepSeek」三个人物的最新新闻、X动态、热搜,用 bullet point 格式,每人最多 5 条,附来源链接。"
},
"delivery": {
"mode": "announce",
"channel": "telegram",
"to": "7966882940"
},
"state": {
"nextRunAtMs": 1771908628000
}
}
**Cron job completion message**:
[System Message] A cron job "搜索新闻测试-子代理" just completed successfully.
Result:
子代理已启动,正在使用 Grok 模型搜索并总结马斯克、OpenAI、DeepSeek 的最新新闻。完成后会自动返回结果。
Stats: runtime 10s • tokens 264 (in 100 / out 164) • prompt/cache 11.3k
**Comparison with direct cron execution** (without subagent):
When the same task is executed directly in a cron job without `sessions_spawn`, it works correctly and delivers the actual search results.Impact and severity
Affected: Users who want to use subagents (especially different models like Grok) within cron jobs for scheduled tasks
Severity: High - blocks the ability to use specialized models (Grok for search, etc.) in automated scheduled tasks
Frequency: 100% reproducible with the configuration above
Consequence:
- Cannot leverage subagent capabilities in cron jobs
- Workaround requires direct execution without subagents, losing the benefit of model specialization
- Scheduled tasks that require specific model capabilities (e.g., Grok for web search) cannot be automated properly
Additional information
The issue is related to how cron jobs handle subagent result delivery. The subagent is created and executes the task successfully, but its results are not properly routed back to the cron job's delivery channel.
When sessions_spawn is used in a cron job with --deliver flag, the parent session completes and delivers its own message (the "subagent started" status), but the subagent's completion results are lost and never delivered to the specified channel/target.
Direct execution of the same sessions_spawn command in a regular chat session works correctly - the subagent results are automatically pushed back to the requester.