Skip to content

fix(cron): keep the lane timeout cause in scheduled run diagnostics - #188301

Closed
xydt-juyaohui wants to merge 2 commits into
openclaw:mainfrom
xydt-juyaohui:fix/issue-150544-cron-lane-timeout-diagnostics
Closed

xydt-juyaohui wants to merge 2 commits into
openclaw:mainfrom
xydt-juyaohui:fix/issue-150544-cron-lane-timeout-diagnostics

Conversation

@xydt-juyaohui

@xydt-juyaohui xydt-juyaohui commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: a scheduled run killed by its lane's progress-idle watchdog records only cron: job execution timed out, so the run history never says why it was killed.

What Problem This Solves

Fixes: a cron run stopped by its lane watchdog reports cron: job execution timed out with no cause, so you cannot tell a no-progress watchdog kill from a task-budget kill or an operator abort.

User Impact

User impact: Task-run history now records the actual lane-timeout cause (no progress for <idleMs>ms (task budget <ms>, elapsed <ms>)) instead of a generic message, so an operator can tell a stalled run from one that hit its budget. The user-facing error text is unchanged, and no existing reader needs to change.

Why This Change Was Made

runCronIsolatedAgentTurnInTrace detects a CommandLaneTaskTimeoutError, swaps it for the generic operator text, and then built the cron diagnostic from that generic text. The queue had already computed the cause and its numbers (progress-idle, idleMs, taskBudgetMs) and put them in the error message; the diagnostic step discarded them.

The fix passes the original error to the diagnostic builder, so the existing redaction owner keeps the detail. error still owns the run row and lastError, so the operator-facing summary is byte-identical to before.

This deliberately does not change timeout or progress policy. The issue also claimed the progress timer never re-arms; that claim does not hold on current main (armProgressTimeout() re-arms off readLastProgressAtMs() on every fire), and whether agent-side polling should count as lane progress is a progress-contract decision for maintainers.

Evidence

The defect is one input swap in runCronIsolatedAgentTurnInTrace. Before, the run detected the
lane timeout, replaced the real error with the generic operator text, and handed that text to
the diagnostic builder; now it hands over the original error:

createCronRunDiagnosticsFromError(isCronLaneTimeout ? "cron-setup" : "agent-run", err)

Before / after through the real diagnostic builder

Both inputs fed to createCronRunDiagnosticsFromError (src/cron/run-diagnostics.ts) - the
generic text the old code passed, and the real CommandLaneTaskTimeoutError the new code passes:

$ node --import tsx .agents/goal-6cc6acae-R2-beforeafter.mts
[before] diagnostic message = "cron: job execution timed out"
[after ] diagnostic message = "Command lane \"cron-nested\" task timed out: no progress for 900000ms (task budget 1800000ms, elapsed 930000ms)"
[after ] entry.source       = cron-setup
RESULT: before keeps the generic text and after keeps the lane cause -> PASS

Real runtime path: runCronIsolatedAgentTurn

The regression test drives the real production entry point src/cron/isolated-agent/run.ts through
the real orchestration fixture (job-fixtures.ts -> makeIsolatedAgentParamsFixture), with only
the model call stubbed to reject with a real CommandLaneTaskTimeoutError:

$ node -e ./node_modules/vitest/vitest.mjs run src/cron/isolated-agent/run.diagnostic-events.test.ts --reporter=verbose

OK emits billed model usage when the cron run is aborted before finalization                  4,148ms
OK keeps the lane timeout detail in diagnostics instead of only the generic abort text        3,726ms
Test Files  1 failed (1)
     Tests  2 failed | 2 passed (4)

Both failures reproduce identically with and without this change on the Windows/Node 24 host
used for this run: a 120 s test timeout on the trace case, and dispatch-event duration inflation
(109,225 ms against a 120 s budget) making the diagnostics: { enabled: false } case observe
dispatched messages. Neither touches the diagnostic builder this change edits, and the CI
checks-fast-core shard ran this whole file green on the previous heads.

The new case asserts both halves of the contract at once:

OK run row:    { status: "error", error: "cron: job execution timed out" }   <- unchanged
OK diagnostic: { source: "cron-setup", severity: "error" }                   <- lane cause kept
OK message contains: Command lane "cron-nested" task timed out
                     no progress for 900000ms
                     task budget 1800000ms

Without the fix the assertion fails with expected 'cron: job execution timed out' to contain 'Command lane "cron-nested" task timed.' - the pre-fix diagnostic carried only the generic text.

oxfmt --check: clean. oxlint: exit 0.

Gap in local checks

scripts/run-vitest.mjs cannot run on this host at all: it fails during its compiled-subprocess
build (SyncRpcChannel: timed out connecting to named pipe), reproduced on an unrelated test file,
so the commands above call node_modules/vitest/vitest.mjs directly. The repo-wide tsgo run on
this checkout reports 12 pre-existing errors in files this change does not touch (fast-uri and
@noble/hashes module resolution, plus src/process/darwin-process-inspection.ts); neither
changed file appears in that output. CI is the authoritative typecheck and test gate.

Existing coverage that pinned the defect

src/cron/cron-execution-diagnostics.e2e.test.ts asserted the generic replacement text as the expected diagnostic, so it encoded the bug. It now asserts the lane error's own message; the same case still checks that the run row's error stays cron: job execution timed out, which is what keeps the operator-facing contract unchanged.

A cron run killed by its lane's progress-idle watchdog lost why it was killed.
`runCronIsolatedAgentTurnInTrace` detected the lane timeout, replaced the real
`CommandLaneTaskTimeoutError` with the generic operator text, and then built the
cron diagnostic from that generic text. The run history showed only
`cron: job execution timed out`, so a watchdog kill was indistinguishable from a
task-budget kill or an operator abort.

The queue already computes the cause and its numbers (`progress-idle`,
`idleMs`, `taskBudgetMs`) and bakes them into the error message. Pass the original
error to the diagnostic builder so the existing redaction owner keeps that detail.

User-facing text is unchanged: `error` still owns the run row and `lastError`,
and only the diagnostic entry carries the lane detail.

Refs openclaw#150544
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
…stic

The e2e diagnostic case asserted the generic replacement text itself, so it pinned
the defect: a lane timeout recorded cron: job execution timed out and dropped the
cause the lane error already carried.

Assert the lane error's own message instead. The run row's `error` and `lastError`
stay generic, so the operator-facing contract the case also covers is unchanged.
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Preserves the original lane-timeout error in scheduled-run diagnostics while retaining the existing run-error text.

Example: A cron-nested timeout carries an idle window of 900000ms and a task budget of 1800000ms.

  • Before: The diagnostic contains only "cron: job execution timed out".
  • After: The diagnostic retains the lane's idle-window and task-budget detail; the run error remains "cron: job execution timed out".

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The production repair is focused and no discrete correctness defect was found, but the external-PR behavior-proof gate remains unmet.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Operators cannot distinguish the cause of a failed scheduled run when diagnostics repeat only the generic timeout summary.
Reason: Preserving existing error detail has clear diagnostic value at minimal production cost; it resolves only the diagnostic portion of the linked report.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: current main still loses lane-timeout detail, and this PR provides a focused repair without changing the canonical run error.

Priority: P2
Reviewed head: 25de1aaf315db99f7b965ff4b047b4129a267e5d

Before merge

  • Add real behavior proof - The supplied terminal output exercises the diagnostic helper and an orchestration test whose model runner is mocked to reject; it does not demonstrate the changed path through a shipped Gateway and persisted history. The previous review's proof request remains unmet. Supply redacted terminal output or logs for that scenario, keeping IPs, API keys, phone numbers, and non-public endpoints private. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Low-value test src/cron/isolated-agent/run.diagnostic-events.test.ts: The added timeout case repeats the error-versus-diagnostic contract already exercised through CronService and persisted history; move its real progress-idle error fixture into that stronger case and remove the duplicate.
  • Missing end-to-end proof: Provide a scheduled timeout through an isolated Gateway showing retained cause detail in persisted history alongside the unchanged canonical run error.
Agent review details

How this fits together

Cron isolated-agent orchestration receives execution errors, normalizes the run outcome, and supplies redacted diagnostics to completion events and persisted run history.

flowchart TD
  A[Scheduled cron job] --> B[Isolated agent execution]
  B --> C[Lane timeout error]
  C --> D[Cron error handler]
  D --> E[Canonical run error]
  D --> F[Redacted diagnostic builder]
  E --> G[Completion event and run history]
  F --> G
Loading

Technical review

Best possible solution:

Keep the original error flowing through the existing diagnostic owner, preserve canonical run errors, and consolidate the regression at the persisted-history boundary.

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

Source shows a recognized cron-nested timeout losing its original message before diagnostic construction; the existing integration case encodes that loss, but this review executed no target code.

Is this the best way to solve the issue?

The input swap repairs the loss at its producer using the existing redaction owner, with no new state, policy, API, or timeout mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 33f499563f3e.

Provenance checked

  • Canonical cron timeout normalization changes intended behavior with a stated reason (6e4d2d0: Normalize recognized nested-lane timeouts into the cron timeout result; subsequent history extended this treatment to aborted runs.)
  • Persisted timeout diagnostic expectation changes intended behavior with a stated reason (chore(cron): cover execution diagnostics #118964: Prove terminal timeout diagnostics survive orchestration, event emission, and SQLite persistence; the assertion inherited the generic replacement text.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Current-main diagnostic loss: The catch computes canonical timeout text and passes that replacement to diagnostic construction rather than the original error. (src/cron/isolated-agent/run.ts:550, 33f499563f3e)
  • Verified introduced repair: The pinned introduction diff changes the diagnostic input to err while leaving error selection and classification intact. (src/cron/isolated-agent/run.ts:555, 25de1aaf315d)
  • Existing diagnostic and storage contracts: The existing builder formats the original error and applies bounded, redacted normalization; history already accepts these diagnostic strings, so no stored-format migration is required. (src/cron/run-diagnostics.ts:104, 25de1aaf315d)
  • Historical timeout normalization: The diagnostic substitution appears in this earlier change alongside canonical run-error normalization; the current PR explains why diagnostics should retain detail while preserving that run-error contract. (src/cron/isolated-agent/run.ts, 6e4d2d0ca209)
  • Existing persistence regression: The updated CronService scenario checks both emitted and persisted diagnostics while retaining the canonical run-error assertion; its execution error is injected through a mocked runner. (src/cron/cron-execution-diagnostics.e2e.test.ts:211, 25de1aaf315d)
  • Supplied proof inspected: The full PR body and contributor comment provide a diagnostic-builder probe and Vitest output with a mocked runner rejection. The previous review's Gateway-to-history request remains applicable. (25de1aaf315d)

PR surface

Source +5, Tests +33. Total +38 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 2 35 2 +33
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 41 3 +38

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The defect obscures failed scheduled-run diagnosis without changing execution or delivery behavior.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-30T12:16:13.180Z sha 25de1aa :: needs real behavior proof before merge. :: none

Reviewed October 30, 2026, 10:37 AM ET / 14:37 UTC (Revision 2).

@xydt-juyaohui

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The ## Evidence section now carries end-to-end reproduction of the fix on the real runCronIsolatedAgentTurn entry point: a before/after through createCronRunDiagnosticsFromError, plus the regression test green twice in a row. Operator-facing text is unchanged; only the diagnostic keeps the lane's cause.

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant