Repository navigation
fix(cron): use agent-turn safety timeout for systemEvent jobs with wakeMode=now - #50723
Hollychou924 wants to merge 2 commits into
Conversation
…keMode=now When a cron job has sessionTarget="main", payload.kind="systemEvent", and wakeMode="now", executeJobCore() calls runHeartbeatOnce() which blocks until the full agent turn completes. The turn duration is unbounded (multi-step tasks may take 30+ minutes), but resolveCronJobTimeoutMs() was returning DEFAULT_JOB_TIMEOUT_MS (10 minutes) for all systemEvent jobs, causing spurious "cron: job execution timed out" errors. Fix: when wakeMode="now" + sessionTarget="main" + kind="systemEvent", return AGENT_TURN_SAFETY_TIMEOUT_MS (60 minutes) instead of the short 10-minute default. Fixes openclaw#50621
Greptile SummaryThis PR fixes a legitimate bug where The root cause was that
Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/cron/service/timeout-policy.ts
Line: 31-37
Comment:
**Redundant `sessionTarget === "main"` guard**
`assertSupportedJobSpec()` in `src/cron/service/jobs.ts` (line 138) already enforces that `isolated` jobs must have `payload.kind === "agentTurn"`, which means any valid job with `payload.kind === "systemEvent"` is *always* `sessionTarget === "main"`. The `job.sessionTarget === "main"` check here is therefore always `true` for a well-formed `systemEvent` job and doesn't add filtering power at runtime.
This is harmless (and adds some defensive clarity), but the condition could be simplified without any behavioral change:
```suggestion
if (job.payload.kind === "systemEvent" && job.wakeMode === "now") {
return AGENT_TURN_SAFETY_TIMEOUT_MS;
}
```
Leaving it as-is is also acceptable if you prefer the explicit self-documentation.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "test(cron): add cove..." |
| if ( | ||
| job.payload.kind === "systemEvent" && | ||
| job.sessionTarget === "main" && | ||
| job.wakeMode === "now" | ||
| ) { | ||
| return AGENT_TURN_SAFETY_TIMEOUT_MS; | ||
| } |
There was a problem hiding this comment.
Redundant
sessionTarget === "main" guard
assertSupportedJobSpec() in src/cron/service/jobs.ts (line 138) already enforces that isolated jobs must have payload.kind === "agentTurn", which means any valid job with payload.kind === "systemEvent" is always sessionTarget === "main". The job.sessionTarget === "main" check here is therefore always true for a well-formed systemEvent job and doesn't add filtering power at runtime.
This is harmless (and adds some defensive clarity), but the condition could be simplified without any behavioral change:
| if ( | |
| job.payload.kind === "systemEvent" && | |
| job.sessionTarget === "main" && | |
| job.wakeMode === "now" | |
| ) { | |
| return AGENT_TURN_SAFETY_TIMEOUT_MS; | |
| } | |
| if (job.payload.kind === "systemEvent" && job.wakeMode === "now") { | |
| return AGENT_TURN_SAFETY_TIMEOUT_MS; | |
| } |
Leaving it as-is is also acceptable if you prefer the explicit self-documentation.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cron/service/timeout-policy.ts
Line: 31-37
Comment:
**Redundant `sessionTarget === "main"` guard**
`assertSupportedJobSpec()` in `src/cron/service/jobs.ts` (line 138) already enforces that `isolated` jobs must have `payload.kind === "agentTurn"`, which means any valid job with `payload.kind === "systemEvent"` is *always* `sessionTarget === "main"`. The `job.sessionTarget === "main"` check here is therefore always `true` for a well-formed `systemEvent` job and doesn't add filtering power at runtime.
This is harmless (and adds some defensive clarity), but the condition could be simplified without any behavioral change:
```suggestion
if (job.payload.kind === "systemEvent" && job.wakeMode === "now") {
return AGENT_TURN_SAFETY_TIMEOUT_MS;
}
```
Leaving it as-is is also acceptable if you prefer the explicit self-documentation.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This comment was marked as spam.
This comment was marked as spam.
|
Closing this as stale. The wakeMode/systemEvent timeout behavior was folded into the closed isolated cron timeout family (#40868), and this PR is red. |
Problem
Closes #50621
When a cron job has
sessionTarget: "main",payload.kind: "systemEvent", andwakeMode: "now",executeJobCore()callsrunHeartbeatOnce()which blocks until the full agent turn completes. Multi-step tasks (file I/O, web search, git push, etc.) can take 30+ minutes.However,
resolveCronJobTimeoutMs()was returningDEFAULT_JOB_TIMEOUT_MS(10 minutes) for allsystemEventjobs, regardless ofwakeMode. This caused legitimate long-running main-session heartbeats to be killed witherror: "cron: job execution timed out".Root cause
The two
wakeModepaths have fundamentally different blocking behaviour:next-heartbeatrequestHeartbeatNow(), returns immediatelyDEFAULT_JOB_TIMEOUT_MS(10 min) is finenowrunHeartbeatOnce()until turn finishesAGENT_TURN_SAFETY_TIMEOUT_MS(60 min)Fix
In
resolveCronJobTimeoutMs(), detect thesystemEvent + sessionTarget=main + wakeMode=nowcombination and returnAGENT_TURN_SAFETY_TIMEOUT_MS(60 min) instead of the short default.Jobs with
wakeMode !== "now"are unaffected — they remain fire-and-forget and keep the 10-minute ceiling.Testing
wakeMode=nowcase intimeout-policy.test.ts5 tests passed)