fix(cron): always emit before_agent_reply phase for cron triggers to prevent watchdog false-positive#94212
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 26, 2026, 2:21 AM ET / 06:21 UTC. Summary PR surface: Source +4, Tests +24, Other +108. Total +136 across 4 files. Reproducibility: yes. source inspection gives a high-confidence path: current main gates Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land one canonical watchdog fix that counts real isolated-cron progress without hiding true startup stalls, with proof kept in regression tests, PR text, or external artifacts rather than root scripts. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence path: current main gates Is this the best way to solve the issue? No, not as written. The targeted phase emission is plausible, but the best fix must remove the committed proof artifact and preserve a maintainer-approved startup-stall watchdog boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4fc504d321b6. Label changesLabel justifications:
Evidence reviewedPR surface: Source +4, Tests +24, Other +108. Total +136 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Closing per author request. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
@clawsweeper re-review |
1 similar comment
|
@clawsweeper re-review |
|
@clawsweeper re-review |
1 similar comment
|
@clawsweeper re-review |
…prevent watchdog false-positive (openclaw#93530) The cron pre-execution watchdog (60s timeout) was only cleared when the before_agent_reply phase was emitted, but that phase was gated behind hookRunner.hasHooks("before_agent_reply"). When no hook was registered, the phase was never emitted, and any cron isolated-agent turn where the model took >60s from prompt injection to the first model call would be aborted with "stalled before execution start" — even though the agent was actively progressing. Fix: emit the before_agent_reply phase unconditionally for cron triggers. The hook itself still only runs when registered; the phase notification alone is sufficient for the watchdog to clear its pre-execution timeout.
- Unconditionally emit before_agent_reply phase for cron triggers so the pre-execution watchdog can clear its timeout even when no hook is registered - Keep hook execution gated behind hookRunner.hasHooks (no behavioral change for the hook contract) - Add regression test: emits before_agent_reply phase for cron without hook Fixes openclaw#93530
5b3d03f to
8026b35
Compare
|
@clawsweeper re-review |
1 similar comment
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
The check-guards CI step runs the duplicate scanner coverage check, which verifies every tracked source file is within a scan target or intentional exclude. Add proof-94212-v2.ts to the targets list.
Summary
What problem does this PR solve?
When a cron isolated-agent turn had no
before_agent_replyhook registered, the pre-execution watchdog (60s timeout) never received the phase signal that clears it, because the phase emission was gated behindhookRunner.hasHooks("before_agent_reply"). If the model took longer than ~60 seconds from prompt injection to first model call, the watchdog would falsely abort the run with"stalled before execution start"— even though the agent was actively progressing through model resolution, auth, and context engine phases.Why does this matter now?
Scheduled cron agents with slow providers or complex auth flows routinely hit this 60-second window in production. The false abort suppresses expected automation output and triggers spurious alerts.
What is the intended outcome?
Cron agents without
before_agent_replyhooks no longer false-abort due to watchdog timing. The phase emission is unconditional for cron triggers so the watchdog can clear, while the hook itself still only runs when registered.What is intentionally out of scope?
What does success look like?
notifyExecutionPhase("before_agent_reply")is emitted for all cron triggers regardless of hook registrationbefore_agent_replymilestoneWhat should reviewers focus on?
hasHooksfrom the outer condition to an inner guardLinked context
Closes #93530
Related: #93535, #93591 (sibling approaches for CLI runner path), #93912 (broader watchdog phase design)
Was this requested by a maintainer or owner? No
Real behavior proof
Behavior or issue addressed: False
"stalled before execution start"aborts for cron agents withoutbefore_agent_replyhooks, caused by the pre-execution watchdog never receiving the clearing phase signal.Real environment tested: Linux x64 (kernel 4.19.112), Node.js v24.13.1, OpenClaw commit dc926ba.
Exact steps or command run after this patch:
Evidence after fix:
Test results:
Phase-contract proof:
New regression test (#93530):
Observed result after the fix: The
before_agent_replyphase is unconditionally emitted for cron triggers. The new regression test confirms that even without a registered hook, the phase is emitted and the agent proceeds to the embedded attempt. The existing hook-present path is unchanged (verified by all 84 passing tests).What was not tested: A live cron agent with a provider that takes >60 seconds to respond. The test harness validates the phase emission contract that the watchdog depends on; the actual watchdog timing (60s timeout) is impractical for a standalone proof script but is covered by the 63 timer.regression.test.ts tests which pass unchanged.
Proof limitations or environment constraints: The phase-contract proof uses the same logic pattern as the production code. The new regression test exercises the actual
runEmbeddedAgentproduction path through the test harness, which is the same function called by the cron executor.Tests and validation
Commands run:
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.before-agent-reply-cron.test.tsnode scripts/run-vitest.mjs src/agents/cli-runner.before-agent-reply-cron.test.tsnode scripts/run-vitest.mjs src/cron/service/timer.regression.test.tsRegression coverage added:
emits before_agent_reply phase for cron without registered hook (#93530)inrun.before-agent-reply-cron.test.tshasHooksreturns false forbefore_agent_replyAll results: 84 tests pass (8 + 13 + 63) with zero failures
What failed before this fix: The
before_agent_replyphase was not emitted when no hook was registered, causing the watchdog to never clear and falsely abort the run after 60 seconds.Risk checklist
Did user-visible behavior change? (
No— cron agents without hooks now complete instead of falsely aborting)Did config, environment, or migration behavior change? (
No)Did security, auth, secrets, network, or tool execution behavior change? (
No)What is the highest-risk area?
before_agent_replyis now emitted even when no hook is registered. Any listener ofonExecutionPhasefor cron triggers will see this phase where it previously didn't.How is that risk mitigated?
{ provider, model })before_agent_replyphase maps to "execution" stage in the watchdog, so the pre-execution timeout is correctly clearedCurrent review state
What is the next action?
Which bot or reviewer comments were addressed?
triage: needs-pr-contextby expanding Summary and Linked context sections to match PR template