Skip to content

fix(cron): increase watchdog timeouts and make them configurable - #83066

Closed
kip-claw wants to merge 1 commit into
openclaw:mainfrom
kip-claw:fix/cron-watchdog-timeouts
Closed

kip-claw wants to merge 1 commit into
openclaw:mainfrom
kip-claw:fix/cron-watchdog-timeouts

Conversation

@kip-claw

Copy link
Copy Markdown
Contributor

Problem

All isolated-session cron jobs (sessionTarget: "isolated", payload.kind: "agentTurn") fail with:

cron: isolated agent setup timed out before runner start

or silently abort at exactly 60 seconds when the Codex app-server harness takes longer than 60s to spawn and reach the first model call.

Root Cause

Two hardcoded 60-second watchdog constants in src/cron/service/timer.ts:

  • CRON_AGENT_SETUP_WATCHDOG_MS — fires if the runner never starts within 60s
  • CRON_AGENT_PRE_EXECUTION_WATCHDOG_MS — fires if execution phase (first model call) is not reached within 60s of runner start

These are too aggressive for environments where Codex app-server startup involves OAuth token resolution, sandbox provisioning, and model prewarm — all of which routinely exceed 60s on modest hardware (Raspberry Pi, low-end VPS).

Meanwhile, the per-job timeoutSeconds (default 300s) is generous enough. The watchdogs fire long before the job timeout would.

Changes

  • Increase default CRON_AGENT_SETUP_WATCHDOG_MS from 60s to 180s
  • Increase default CRON_AGENT_PRE_EXECUTION_WATCHDOG_MS from 60s to 180s
  • Make both configurable via cronConfig.setupWatchdogMs and cronConfig.preExecutionWatchdogMs
  • Backward compatible: no config change needed, just better defaults

Why 180s?

  • Codex app-server startup on a Pi 5: consistently 70–90s (process spawn → stdio handshake → OAuth → sandbox → session binding)
  • Pre-execution phase adds: model resolution → context assembly → turn dispatch → first model call (another 30–60s)
  • 180s = 2× safety margin while still catching genuinely stalled processes before the 300s job timeout

Testing

Patched the compiled JS on OpenClaw 2026.5.12 (f066dd2):

  • Before: 19/19 isolated cron jobs failing
  • After: Jobs complete successfully (e.g. durationMs=130542 aborted=false)

The hardcoded 60-second setup and pre-execution watchdog timeouts are too
aggressive for environments where the Codex app-server startup takes longer
(OAuth resolution, sandbox provisioning, model prewarm on modest hardware).

Changes:
- Increase default CRON_AGENT_SETUP_WATCHDOG_MS from 60s to 180s
- Increase default CRON_AGENT_PRE_EXECUTION_WATCHDOG_MS from 60s to 180s
- Make both configurable via cronConfig.setupWatchdogMs and
  cronConfig.preExecutionWatchdogMs

This fixes all isolated-session cron jobs failing with:
  'cron: isolated agent setup timed out before runner start'
or silently aborting at 60s before the first model call.

Tested on OpenClaw 2026.5.12 running on Raspberry Pi 5 where Codex
app-server startup consistently takes 70-90s.
@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 17, 2026
@clawsweeper

clawsweeper Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close this PR as duplicate/superseded: #82223 already tracks the same isolated-cron watchdog fix with broader schema, docs, and tests, and this PR's author supplied detailed proof there while saying this branch could close in favor of that one.

Canonical path: #82662 remains open for the same root behavior and now links both overlapping PRs and the author's live proof.

So I’m closing this here and keeping the remaining discussion on #82223 and #82662.

Review details

Best possible solution:

Keep the proof and implementation discussion consolidated on #82223 and the root issue, then land one complete schema/docs/tests-backed fix if maintainers approve the timeout policy.

Do we have a high-confidence way to reproduce the issue?

No high-confidence local reproduction was run in this review. Source inspection shows the current 60s watchdog path and the author's related live logs show the failure/recovery pattern on OpenClaw 2026.5.12, but exact current-main or PR-head behavior was not executed here.

Is this the best way to solve the issue?

No. Raising the watchdogs may be part of the fix, but this branch is the weaker duplicate because its public config keys are not wired into the strict config schema while #82223 already carries the broader contract work.

Security review:

Security review cleared: The diff touches cron timer logic and TypeScript config types only; I found no concrete dependency, workflow, secret, or supply-chain concern.

What I checked:

Likely related people:

  • steipete: Related ClawSweeper reviews for the canonical issue and prior PR identify recent current-main cron watchdog and isolated-cron execution milestone work by this handle in the affected timer/test surface. (role: recent cron watchdog contributor; confidence: high; commits: 5b3e2497bd55, 5a80be35e982, aedcfa76a439; files: src/cron/service/timer.ts, src/cron/service/timer.regression.test.ts, src/cron/isolated-agent/run.ts)
  • joshavant: The canonical issue is assigned to joshavant, and the related review context ties this handle to adjacent embedded-runner timeout work in the affected isolated-cron path. (role: assigned triage owner and adjacent reviewer; confidence: medium; files: src/agents/pi-embedded-runner/run.ts, src/cron/isolated-agent/run.ts)
  • samzong: The overlapping canonical PR and related review context identify recent config-schema work adjacent to the cron schema keys needed for this change. (role: recent config schema contributor; confidence: medium; commits: 87724c964f41; files: src/config/zod-schema.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 69a0c925b890.

@kip-claw

Copy link
Copy Markdown
Contributor Author

Note: #82223 is an existing PR with the same fix (raises watchdogs from 60s to 5m, makes configurable). That PR is labeled triage: needs-real-behavior-proof — I have posted detailed live proof there from my Pi 5 deployment.

Happy to close this in favor of #82223 if the maintainers prefer to consolidate. Both patches address the same root cause (issues #82662, #81368, #81475, #80888, #74803).

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. P2 Normal backlog priority with limited blast radius. impact:crash-loop Crash, hang, restart loop, or process-level availability failure. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. labels May 17, 2026
@clawsweeper clawsweeper Bot closed this May 17, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. impact:crash-loop Crash, hang, restart loop, or process-level availability failure. P2 Normal backlog priority with limited blast radius. size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant