Repository navigation
fix(cron): a cron run that hands off to a child times out even when the child answers in seconds - #197695
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Proof runs (built Gateway, node:24.22.1, stand-in model and Telegram Bot API). Driver and per-run artifacts kept in the loop proof folder. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThe PR lets a cron run consume its child’s completion after the parent’s agent attempt ends, even while the run still holds its session turn. Example: A cron run has a 40-second timeout, spawns a child, ends with NO_REPLY, and receives the child’s answer after 5 seconds.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — suspected predecessor, not a causality claim: source commit Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR fixes a current cron completion deadlock with a narrow change; source review and shipped Gateway/Telegram evidence support merging, with no actionable findings. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherChild completion enters the subagent announcement owner, which either steers an active parent attempt or leaves settlement to cron; cron records the child’s result and applies the job’s delivery policy. flowchart TD
A[Cron run holds session turn] --> B[Parent spawns child and ends attempt]
B --> C[Child completion]
C --> D[Announcement owner checks live attempt]
D --> E[Cron consumes settled child result]
E --> F[Record summary and optional announcement]
Technical reviewBest possible solution: Keep cron settlement in its existing owner and use live agent-attempt activity solely to decide whether the child completion needs a parent handoff. Do we have a high-confidence way to reproduce the issue? The held controller turn, child-settlement wait, and requester dispatch establish the circular wait in source, corroborated by the contributor’s before/after Gateway traces; no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete repair: it reuses the existing attempt query and cron handoff, adds one distinct regression case, and introduces no new owner, state, option, or fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5dd83baa10f3. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +7, Tests -1. Total +6 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 12, 2026, 6:49 AM ET / 11:49 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Live Telegram proof for the delivered case. Setup. Built Gateway ( The model is a stand-in on purpose: loop proofs carry no secrets or real model keys. Everything else is live: Gateway, cron, sessions_spawn, the child session, announce, and the Telegram Bot API to a real chat that a real user account sees.
Result (2 runs per tree)
On main the child answers 5 s in, but the parent only gets the child's result about 35 s later, after the job has already timed out. It then answers On the PR the run ends 1.2 s / 1.5 s after the child answers, with no extra parent turn. The DM gets exactly one message per case: Telegram counts per run (bot messages in the DM): main ANN 0 / 0, PR ANN 1 / 1, DLV 1 on all four runs. No |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 9215601. |
…he child answers in seconds (openclaw#197695) fix(cron): let an owed child's answer settle the cron run before its timeout An isolated cron run that spawned a child owing its result and ended with NO_REPLY held its session turn for the whole run (openclaw#175837). When the child answered, the result handoff saw the cron run's session as busy and queued a parent turn that could only start after the run released that turn, while the run's own descendant wait returned only at the job timeout. So the run timed out as an error even when the child answered within seconds, and announce-delivered runs sent nothing. A cron-run requester now counts as busy for this handoff only while its agent attempt is live; after the attempt ends, the existing handoff lets the cron run read the child's result itself. That path never starts a turn, so there are still never two parent turns at once. No text changes. Evidence: a built Gateway with the shipped cron driver and a stand-in model where the parent spawns an owed child that answers in about 5 s and then ends with NO_REPLY, with a 40 s job timeout. On main the run timed out at 40 s with an error; with this change it finishes ok and silent within about a second of the child's answer. With --announce to a live Telegram Test Server DM, main timed out at about 40 s and sent nothing, and this change succeeded in about 11.5 s with the child's answer delivered once, in two runs each. A child slower than the timeout still times out, a failed child now reports the existing handoff error, and a child answering while the parent attempt is live, a parent that replies itself, a fire-and-forget child and a collector child behave the same on both. One row in the existing delivery table fails on main, at -1 net test lines. Details: openclaw#197695 (comment). Co-authored-by: Ayaan Zaidi <[email protected]>
…he child answers in seconds (openclaw#197695) fix(cron): let an owed child's answer settle the cron run before its timeout An isolated cron run that spawned a child owing its result and ended with NO_REPLY held its session turn for the whole run (openclaw#175837). When the child answered, the result handoff saw the cron run's session as busy and queued a parent turn that could only start after the run released that turn, while the run's own descendant wait returned only at the job timeout. So the run timed out as an error even when the child answered within seconds, and announce-delivered runs sent nothing. A cron-run requester now counts as busy for this handoff only while its agent attempt is live; after the attempt ends, the existing handoff lets the cron run read the child's result itself. That path never starts a turn, so there are still never two parent turns at once. No text changes. Evidence: a built Gateway with the shipped cron driver and a stand-in model where the parent spawns an owed child that answers in about 5 s and then ends with NO_REPLY, with a 40 s job timeout. On main the run timed out at 40 s with an error; with this change it finishes ok and silent within about a second of the child's answer. With --announce to a live Telegram Test Server DM, main timed out at about 40 s and sent nothing, and this change succeeded in about 11.5 s with the child's answer delivered once, in two runs each. A child slower than the timeout still times out, a failed child now reports the existing handoff error, and a child answering while the parent attempt is live, a parent that replies itself, a fire-and-forget child and a collector child behave the same on both. One row in the existing delivery table fails on main, at -1 net test lines. Details: openclaw#197695 (comment). Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 9215601) Release adaptation: Use existing active attempt handle rather than session turn activity for cron child settlement. Baseline 1 failed/110 passed; fixed 111 passed. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 7d536a79ce11952bf2db832bcec55f50983f581a)
What Problem This Solves
Fixes: an isolated cron job fails with "cron: job execution timed out" when its agent hands work to a child that owes it a result (
sessions_spawn, defaultexpectsCompletionMessage: true) and then ends withNO_REPLY, even when the child answers within seconds. The failure counts toward the job's error backoff. With--announcedelivery the child's answer is also never sent.User Impact
Supervisor-style cron jobs that hand off to a child now finish
okright after the child answers. With deliverynonethe run records the child's answer quietly; with--announcethe child's answer is delivered. A child slower than the job timeout still times the run out, and runs whose agent replies itself are unchanged.Why This Change Was Made
The run waits for the child's result before it finishes (#162474). When the child finished, the completion handoff asked whether the cron run's session was busy. Since #175837, a cron run holds its session turn for its whole run, including this wait, so the answer was always "busy". The handoff then started a new parent turn, which had to wait for that same held turn. The run waited for the child, the child's handoff waited for the run, and the job timeout broke the tie. The queued parent turn then ran right after the timeout.
Before #175837 this check asked whether the parent's agent run was live (
isEmbeddedAgentRunActive). #175837 moved it to the session controller as part of a broad migration; its body and reviews do not discuss cron handoffs. Now a cron run counts as busy for this handoff only while its agent attempt is live. After the attempt ends, the existing handoff applies: the completion is recorded and the cron run reads the child's result itself (completion_handoff_pending, which already says "an idle cron turn settles this completion").What #175837 needs stays in place: the cron run still holds its session turn, and this path never starts a turn, so no second parent turn can run beside it. While the cron agent attempt is live, the completion still steers into or queues behind it, as before. The shared requester activity check used elsewhere is unchanged. No new text, nothing stored changes.
Related work:
requester-run-settlement.ts): different trigger and files. A yielded requester already takes theisCompletionOwnedByRequesterYieldhandoff before this check, so the two compose.Evidence
A built Gateway in a secretless node:24.22.1 container, with a stand-in model and a stand-in Telegram Bot API. Each scenario is an isolated cron
agentTurnwith a 40 s timeout whose agent callssessions_spawnand then answers exactlyNO_REPLY, unless noted. Two runs on maince76ed2and two on this PR; two more runs on the earlier main37e568bmatch main.--no-delivererror: job execution timed out at 40 s, consecutiveErrors 1; the parent is woken only after the timeoutokin 8-13 s, silent, consecutiveErrors 0; finishes under 1 s after the child answers; child answer recorded as the run summary--announceto Telegramerror(timeout); nothing sentokin 6-8 s; the child's answer is sent onceerror(timeout)error(timeout), unchangederror(timeout)error: "cron child-session handoff completed without a final assistant payload" (existing text) after about 16 sok; the completion reaches the live attempt--announceto Telegram, no spawnok; reply sent onceokerror(timeout)An instrumented copy of main (log lines only) shows the blocking point: the child answered at 10:10:23.116, the handoff saw the cron run's session as busy at 10:10:23.354 and started a parent turn, the run's child wait returned unsettled at the 40 s timeout (10:10:53.585), and the queued parent turn ran at 10:10:54.888.
Regression: one row in
subagent-announce-delivery.test.ts(a cron run holding its turn after its attempt ended) fails on the base (path: direct, a requester turn is dispatched) and passes on this branch; paid for by inlining a test helper (tests net -1). Focused announce suites pass. Production +7 lines in one file.Run details: #197695 (comment)