Skip to content

fix(cron): make isolated agent watchdogs configurable - #82223

Closed
14-TR wants to merge 3 commits into
openclaw:mainfrom
14-TR:fix/cron-isolated-agent-watchdogs
Closed

14-TR wants to merge 3 commits into
openclaw:mainfrom
14-TR:fix/cron-isolated-agent-watchdogs

Conversation

@14-TR

@14-TR 14-TR commented May 15, 2026 •

Copy link
Copy Markdown

Summary

  • raises isolated-agent cron setup/pre-execution watchdog defaults from 60s to 3m
  • adds cron.isolatedAgentSetupWatchdog and cron.isolatedAgentPreExecutionWatchdog config fields
  • documents the new knobs and adds schema/timer regression coverage

Why

Some isolated agent cron jobs can spend more than 60s in provider/runtime startup before first execution progress, especially on loaded hosts or with larger bootstraps. The previous hardcoded watchdog could abort these jobs at the pre-execution dispatch phase even when direct agent execution is healthy.

Safety

  • existing configs continue to work
  • setup watchdog remains separate from the execution timeout budget so queued runner-lane time does not spend timeoutSeconds
  • pre-execution watchdog remains capped to half of the job timeout
  • invalid non-positive duration config is rejected by schema validation
  • failure diagnostics remain phase-specific

Real behavior proof

  • Behavior or issue addressed: Isolated agentTurn cron jobs could fail during setup or pre-execution startup at the old hardcoded 60s watchdog, even when the underlying agent execution was otherwise healthy.
  • Real environment tested: Corroborating live proof from @kip-claw on a self-hosted Raspberry Pi 5 (4 GB, ARM64), Debian bookworm, OpenClaw 2026.5.12 (f066dd2), systemd service, OAuth via openai-codex, openai/gpt-5.4 primary with openai/gpt-5.4-mini fallback. See Kip's PR comment: fix(cron): make isolated agent watchdogs configurable #82223 (comment)
  • Exact steps or command run after this patch: Kip reproduced the failure with 19 isolated cron jobs, patched both built cron watchdog constants from 60000 to 180000, cleared Node compile cache, restarted Gateway, and reran the affected isolated cron class. This PR matches that observed fix by making both setup and pre-execution watchdog defaults 3m through typed source/config/docs coverage.
  • Evidence after fix: Kip's redacted live output shows the representative run progressing beyond the old 60s watchdog and completing:
06:40:38.036  lane dequeue
06:40:50.488  session state -> processing (runner started, 12s)
06:42:48.542  session state -> idle (run_completed)
06:42:48.622  embedded run done: durationMs=130542 aborted=false
  • Observed result after fix: The Pi hardware health check job changed from error to ok and completed successfully in about 130s with aborted=false, which is inside the new 180s default setup/pre-execution watchdog budget.
  • What was not tested: No production cron cutover, public side effects, or unrelated cron lanes were exercised by this PR proof. The exact PR-head source/config path is covered by schema and timer regression tests; Kip's live proof validates the same 180s runtime behavior in a real OpenClaw deployment.

Additional redacted local Gateway proof from a real OpenClaw setup:

Before the watchdog change, representative isolated agent cron runs failed during startup/pre-execution cleanup with the phase-specific diagnostic below, even though direct agent execution was healthy:

status: error
error: cron: isolated agent run stalled before execution start (last phase: attempt-dispatch)
durationMs: ~60000

After applying the equivalent local runtime change to use a longer isolated-agent setup/pre-execution watchdog and restarting the Gateway, the same representative isolated cron class completed instead of being aborted at the old 60s ceiling:

status: ok
error: null
startup/pre-execution time: >60000ms and <300000ms

This PR turns that local recovery into typed config, schema validation, docs, and regression coverage rather than keeping a dist-only local patch. The public evidence above is intentionally redacted to avoid exposing local paths, private job names, or private network details.

Test plan

  • git diff --check
  • Local targeted Vitest rerun after matching Kip's 180s proof is pending CI or a dependency-restored checkout; this clean local checkout has no node_modules, so node scripts/run-vitest.mjs ... cannot resolve vitest/package.json without installing dependencies.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 15, 2026
@clawsweeper

clawsweeper Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

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

Keep open: the PR addresses a real cron timeout failure and has sufficient live-log proof, but the current head still has a blocking config-help mismatch and a maintainer-visible availability tradeoff from lengthening the default watchdog window.

Canonical path: Close this PR as superseded by #83111.

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

Review details

Best possible solution:

Close this PR as superseded by #83111.

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

Yes, with source and live-log evidence rather than a local rerun. Current main hardcodes 60s watchdogs, and the linked real deployment completed the same isolated cron class after the equivalent 180s watchdog change.

Is this the best way to solve the issue?

Mostly yes, after the help-text fix. The runtime/config/test shape is narrow and matches the observed recovery, but the 3m default is still an availability policy choice for maintainers.

Security review:

Security review cleared: The diff touches cron timer/config logic, docs, and tests; I found no dependency, workflow, secret-handling, package, or supply-chain concern.

What I checked:

  • linked superseding PR: fix(cron): remove /2 divisor from pre-execution watchdog formula #83111 (fix(cron): remove /2 divisor from pre-execution watchdog formula) is still open as the canonical replacement.
  • cluster evidence: the durable review links that PR in the work cluster or recommended risk path.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • steipete: Current-main blame for the cron watchdog constants and recent shortlog/history over the timer, tests, and config-help files point strongly to Peter Steinberger for recent routing. (role: recent area contributor; confidence: high; commits: e510042870cf, a03a8d91f636, 60b61288c40b; files: src/cron/service/timer.ts, src/cron/service/timer.regression.test.ts, src/config/schema.help.ts)
  • vincentkoc: Vincent Koc carried the cron main/detached dispatch split and related task-scope work that shaped the timer service boundary this PR changes. (role: major cron refactor contributor; confidence: medium; commits: 1c9053802a98, 80ed55332d77, 338d31304314; files: src/cron/service/timer.ts, src/cron/service/timer.regression.test.ts)
  • Takhoffman: Tak Hoffman has prior cron timeout, startup replay, maxConcurrentRuns, and schema-help coverage commits that are adjacent to this PR's watchdog/config surface. (role: adjacent cron and config-help contributor; confidence: medium; commits: 7417c3626816, 73e5bb763530, 556af3f08bb1; files: src/cron/service/timer.ts, src/cron/service/timer.regression.test.ts, src/config/schema.help.ts)

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

@kip-claw

Copy link
Copy Markdown
Contributor

I can provide the real-behavior proof this PR needs. I hit the exact same issue on a self-hosted Raspberry Pi 5 running OpenClaw 2026.5.12 (f066dd2) with 19 isolated cron jobs all failing.

Environment

  • Hardware: Raspberry Pi 5 (4 GB), ARM64
  • OS: Debian bookworm
  • OpenClaw: 2026.5.12 (f066dd2), systemd service
  • Auth: OAuth via openai-codex provider (ChatGPT/Codex subscription)
  • Model: openai/gpt-5.4 primary, openai/gpt-5.4-mini fallback
  • Codex plugin config: requestTimeoutMs: 300000, transport: "stdio", mode: "yolo"

Failure Mode

All 19 isolated agentTurn cron jobs failed with two distinct timeout patterns:

  1. Setup watchdog (60s): "cron: isolated agent setup timed out before runner start" — the Codex app-server process takes ~70-90s to spawn, handshake, resolve OAuth, and initialize the sandbox on Pi hardware.

  2. Pre-execution watchdog (60s): After patching only the setup watchdog, runs still aborted silently at 60s (durationMs=60502 aborted=true) with no error message — the pre-execution watchdog fired because the first model call had not started within 60s of runner start.

Timeline of a Failing Run (before fix)

06:28:00.936  lane dequeue (embedded run starts)
06:28:01.300  before_agent_reply hook fires
06:28:03.342  agent harness selected (codex)
06:28:13.504  session state → processing (runner started, ~13s after dequeue)
06:29:00.979  aborting run (60s from dequeue)
06:29:01.438  embedded run done: durationMs=60502 aborted=true

Fix Applied

Patched both constants in dist/server-cron-C6BmZ1gR.js:

CRON_AGENT_SETUP_WATCHDOG_MS: 60_000 → 180_000
CRON_AGENT_PRE_EXECUTION_WATCHDOG_MS: 60_000 → 180_000

Cleared Node compile cache, restarted gateway.

Result After Fix

06:40:38.036  lane dequeue
06:40:50.488  session state → processing (runner started, 12s)
06:42:48.542  session state → idle (run_completed)
06:42:48.622  embedded run done: durationMs=130542 aborted=false ✅

The Pi hardware health check job completed successfully in ~130s. Job status changed from error to ok. The 180s default gives a comfortable 2× margin over observed startup times.

Cross-reference

I independently submitted #83066 with the same fix before finding this PR. Happy to close mine in favor of this one — just wanted to provide the live proof the maintainers are asking for.

cc @joshavant (assigned to #82662 which is the same root cause)

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. gateway Gateway runtime and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 17, 2026
@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
@14-TR
14-TR marked this pull request as ready for review May 17, 2026 19:29
@14-TR
14-TR force-pushed the fix/cron-isolated-agent-watchdogs branch from ce2357a to 1490aa8 Compare May 17, 2026 19:46
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 17, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 17, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 17, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 17, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 18, 2026
@14-TR

14-TR commented May 18, 2026

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. labels May 18, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed impact:crash-loop Crash, hang, restart loop, or process-level availability failure. labels May 18, 2026
@14-TR
14-TR force-pushed the fix/cron-isolated-agent-watchdogs branch from dc131bb to 9913404 Compare May 22, 2026 16:33
@openclaw-barnacle openclaw-barnacle Bot removed the gateway Gateway runtime label May 22, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels May 22, 2026
@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress.

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.
What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants