Repository navigation
fix(cron): job stops right after sending to its own delivery target - #176141
Conversation
A cron job's delivery target is configured, not a conversation to answer, but cron runs it as the current source. Since #170653 a confirmed send there with `final` omitted counted as the final source reply, so Codex interrupted the turn and the embedded runner terminated it before the job's post-send steps. The cron source-delivery plan now sets messageTool.finalByDefault=false and passes it as messageToolFinalByDefault. resolveMessageToolSourceReplyFinal applies it at every finality decision (Codex dynamic tools, embedded terminal hook and subscriber, CLI evidence); an explicit final still wins, chat turns keep the default. Turn guidance states the rule to the model.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesCron jobs continue after sending to their delivery target unless the message explicitly sets final:true. Example: A daily job sends a photo to Telegram chat -1001234567890, then records its ledger entry as sent.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR fixes a current-main cron regression; no blocking correctness or security findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe cron delivery planner supplies run policy to embedded, Codex, and CLI runtimes, which distinguish confirmed delivery from turn completion. flowchart TD
A[Cron scheduler] --> B[Source delivery plan]
B --> C[Agent runtime]
C --> D[Message tool delivery]
D --> E[Shared finality resolver]
E --> F[Continue remaining work]
E --> G[Finish explicit final reply]
Technical reviewBest possible solution: Keep the cron-specific default in the delivery planner and use the existing shared finality resolver across runtimes. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the termination path, and the supplied baseline Gateway runs stop after the send on both affected runtimes; no target code was executed during this review. Is this the best way to solve the issue? The patch is a focused fix: it extends existing policy and finality owners, updates affected consumers together, and preserves delivery evidence independently of termination. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b607b7fefe9c. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +115, Tests +124, Docs +2, Other +168. Total +409 across 29 files. Added test files: 0. View PR surface stats
Review metrics
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 HistoryReview history (1 earlier review cycle)
Reviewed October 18, 2026, 1:16 PM ET / 17:16 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 075b466. Bug: when a cron job sent a message to its own delivery target without Fix: the cron delivery plan sets Proof: the new QA scenario |
The mock provider introduced these three constants with unused exports in #176141. They remain used inside the planner, while the live YAML scenario independently checks post-send continuation, marker-file contents and exactly one channel delivery. No QA coverage or runtime behavior is removed.
…penclaw#176141) Related: openclaw#170653, openclaw#176092 ## What Problem This Solves Fixes: a cron job stops right after it sends a message to its own delivery target, so its next steps never run. ## User Impact User impact: a cron job can send to its configured chat with the `message` tool and then continue, for example to update a state file or ledger. Before this fix the turn ended about 0.3 s after the send. A job that recorded "reserved" before sending never recorded "sent", and the next run refused to post because it could not prove delivery. Chat replies are unchanged. ## Why This Change Was Made Cron runs use the job's delivery target as the turn's current source. Since openclaw#170653, a confirmed send to that source with `final` omitted counts as the final source reply: - Codex interrupts the turn (`turn.dynamic_tool_terminal_release`, then `turn/interrupt`). - The embedded runner returns `terminate: true`. A cron target is a configured destination, not a conversation the turn answers, so the send should not end the turn. What changed: - The cron source-delivery plan now owns this decision: `messageTool.finalByDefault: false`, passed to runs as `messageToolFinalByDefault`. - One resolver, `resolveMessageToolSourceReplyFinal(args, finalByDefault)`, applies it at every place that decides finality: Codex dynamic tools, the embedded terminal hook and subscriber, and CLI evidence. - An explicit `final` still wins. - `resolveMessageToolSourceReplyFinal` is now exported from `plugin-sdk/agent-harness-runtime`, next to its sibling `isDeliveredMessageToolOnlySourceReplyResult`, so Codex uses the same owner. The public export budgets go up by one (callable 2206 to 2207, total 3808 to 3809), each with a recorded reason. - Chat turns keep the default (omitted `final` ends the turn). - Delivery facts do not change. A send still counts as reaching the cron target, so `announce` still skips its fallback and no duplicate posts. - The model's turn guidance (Codex `openclaw_source_delivery` context and embedded runtime instructions) now states the rule when the default is off. Chat guidance text is byte-identical. This change is compatible with openclaw#176093. That PR keys on an explicit `final: false`, and this change does not touch it. Comparison: hermes-agent never ends a turn on a send. Its cron same-target guard returns a skipped tool result and lets the turn continue (NousResearch/hermes-agent#1357). ### Decision Cron turns intentionally stop following the "omitted `final` ends the turn" default from openclaw#119605/openclaw#170653. That default fits a chat, where the send answers the inbound message. A cron target is a configured destination, and the job decides when it is done. - **Tradeoff accepted:** a cron send with `final` omitted costs one more model call, the call openclaw#170653 removed. Losing a job's post-send steps without notice costs more. - **Users see no duplicates:** `announce` still skips its fallback after a send, and `none` keeps the final text private. - **Unchanged:** chat turns and an explicit `final`. ## Evidence **Live failure (Codex runtime, stock main):** - A daily cron photo job sent its photo (`ok: true`). - The trajectory then shows `tool.result`, then `turn.dynamic_tool_terminal_release` 4 ms later, then `model.completed` with no assistant text, then `session.ended`. - The job's next step, marking its ledger entry `sent`, never ran. The next run blocked on the unconfirmed entry. **End-to-end, QA Lab** (real gateway, cron scheduler, qa-channel, mock-openai; the Codex cell runs the real `codex app-server`). New scenario `cron-send-then-continue` covers delivery modes `none` and `announce`. In each, the model sends to the delivery target without `final`, then writes a marker file, then finishes. | | embedded | codex | |---|---|---| | main `6d14590f417` (no fix) | fail: one request, turn ended after send | fail: one request, turn ended after send | | this PR | pass: send, then `write`, one channel message per mode | pass: send, then `bash`, one channel message per mode | Each runtime cell's scenario details now include the request trace for each delivery mode (`message -> next tool -> final`, plus what qa-channel received). This run is at the PR head: ```text codex none: message -> exec_command -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] | announce: message -> exec_command -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] embedded none: message -> write -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] | announce: message -> write -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] ``` On main, both cells stop after the first request: `requests=[{"tool":"message",...}]`, and no further tool call follows. **Regression scenarios on both runtimes:** 10 message-tool, cron, sub-agent and A2A scenarios, run under `--runtime-pair openclaw,codex`. - Pass, with no change in the chat paths: `group-visible-reply-tool`, `message-tool-stranded-final-reply`, `group-message-tool-unavailable-fallback`, `cron-send-then-continue`. `runtime-tool-message-tool` skipped. - Fail: `cron-failed-tool-terminal-finalization` (Codex cell), `a2a-message-tool-mirror-dedupe`, `message-delivery-decision-inspection`, `subagent-forked-context`, `yield-rejection-no-warning` (Codex cell). Each fails in the same runtime cells on unpatched main `6d14590f417` on this host, so these failures already exist on main and are not caused by this change. **Unit:** - New matrices in the Codex dynamic-tool and embedded terminal-hook suites, plus a cron run assertion. On main, exactly the bug cells fail (7 failed); with this PR all pass. - 17 affected files, 572 tests, all passing. This includes the existing duplicate-reply protection suites (`message-tool-terminal*.test.ts`, `dynamic-tools.source-reply`, `run-attempt-lifecycle-controller`, `event-projector.source-finish`, `message-tool-execution`) and `agent-tools.prefix-stability`, all unchanged. **Lint:** `oxlint --type-aware` reports `max-lines` on `run-attempt-dispatch.ts` and three unresolved-type errors in `dynamic-tools.ts`. All four already appear on main with the same local setup. Co-authored-by: Ayaan Zaidi <[email protected]>
The mock provider introduced these three constants with unused exports in openclaw#176141. They remain used inside the planner, while the live YAML scenario independently checks post-send continuation, marker-file contents and exactly one channel delivery. No QA coverage or runtime behavior is removed.
…y target (#177518) fix(openai-agents): keep a cron run going after it sends to its own delivery target On the OpenAI Agents API runtime, a cron job stopped as soon as it sent a message to its own delivery target, even when `final` was omitted, so the rest of the job never ran. A send now ends the run only when it is marked final; ordinary sends let the job continue. Evidence: built Gateway, shipped cron commands, the Agents API host mapped to a local TLS fixture with a trusted test CA (no verification bypass). On main the job stopped right after the send in all four runs (no delivery mode and announce, twice each); with this change it continues to its next tool call and delivers once. An explicit final=true still ends the run, and ordinary chat is unchanged. A live gpt-5.4-mini run passes. A separate, existing issue seen on both main and this change (isolated cron completion waits about 95 s in drainForNativeCleanup) is not touched here. Thanks @masatohoshino. Release adaptation: the stable line lacks #176141, which introduced the cron `messageTool.finalByDefault: false` plan field and the `messageToolFinalByDefault` run parameter this fix reads. Port only the plumbing the Agents API runtime needs (source delivery plan field, cron run executor, AgentRunMessageContext, embedded attempt dispatch) and resolve finality locally in agentsapi-tools instead of extending and exporting the core resolver through the plugin SDK. Embedded and Codex runtimes on this line only end turns in message_tool_only mode, which cron never uses, so they need no change; the auto-mode prompt already says sends do not end the task, so no guidance change is needed. The ported tool-surface test uses a local fixture builder because the stable test file has no shared helper. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 679980c)
Related: #170653, #176092
What Problem This Solves
Fixes: a cron job stops right after it sends a message to its own delivery target, so its next steps never run.
User Impact
User impact: a cron job can send to its configured chat with the
messagetool and then continue, for example to update a state file or ledger. Before this fix the turn ended about 0.3 s after the send. A job that recorded "reserved" before sending never recorded "sent", and the next run refused to post because it could not prove delivery. Chat replies are unchanged.Why This Change Was Made
Cron runs use the job's delivery target as the turn's current source. Since #170653, a confirmed send to that source with
finalomitted counts as the final source reply:turn.dynamic_tool_terminal_release, thenturn/interrupt).terminate: true.A cron target is a configured destination, not a conversation the turn answers, so the send should not end the turn.
What changed:
messageTool.finalByDefault: false, passed to runs asmessageToolFinalByDefault.resolveMessageToolSourceReplyFinal(args, finalByDefault), applies it at every place that decides finality: Codex dynamic tools, the embedded terminal hook and subscriber, and CLI evidence.finalstill wins.resolveMessageToolSourceReplyFinalis now exported fromplugin-sdk/agent-harness-runtime, next to its siblingisDeliveredMessageToolOnlySourceReplyResult, so Codex uses the same owner. The public export budgets go up by one (callable 2206 to 2207, total 3808 to 3809), each with a recorded reason.finalends the turn).announcestill skips its fallback and no duplicate posts.openclaw_source_deliverycontext and embedded runtime instructions) now states the rule when the default is off. Chat guidance text is byte-identical.This change is compatible with #176093. That PR keys on an explicit
final: false, and this change does not touch it.Comparison: hermes-agent never ends a turn on a send. Its cron same-target guard returns a skipped tool result and lets the turn continue (NousResearch/hermes-agent#1357).
Decision
Cron turns intentionally stop following the "omitted
finalends the turn" default from #119605/#170653. That default fits a chat, where the send answers the inbound message. A cron target is a configured destination, and the job decides when it is done.finalomitted costs one more model call, the call feat(agents): end runs after confirmed final source replies #170653 removed. Losing a job's post-send steps without notice costs more.announcestill skips its fallback after a send, andnonekeeps the final text private.final.Evidence
Live failure (Codex runtime, stock main):
ok: true).tool.result, thenturn.dynamic_tool_terminal_release4 ms later, thenmodel.completedwith no assistant text, thensession.ended.sent, never ran. The next run blocked on the unconfirmed entry.End-to-end, QA Lab (real gateway, cron scheduler, qa-channel, mock-openai; the Codex cell runs the real
codex app-server). New scenariocron-send-then-continuecovers delivery modesnoneandannounce. In each, the model sends to the delivery target withoutfinal, then writes a marker file, then finishes.adb12365084(no fix)write, one channel message per modebash, one channel message per modeEach runtime cell's scenario details now include the request trace for each delivery mode (
message -> next tool -> final, plus what qa-channel received). This run is at the PR head:On main, both cells stop after the first request:
requests=[{"tool":"message",...}], and no further tool call follows.Regression scenarios on both runtimes: 10 message-tool, cron, sub-agent and A2A scenarios, run under
--runtime-pair openclaw,codex.group-visible-reply-tool,message-tool-stranded-final-reply,group-message-tool-unavailable-fallback,cron-send-then-continue.runtime-tool-message-toolskipped.cron-failed-tool-terminal-finalization(Codex cell),a2a-message-tool-mirror-dedupe,message-delivery-decision-inspection,subagent-forked-context,yield-rejection-no-warning(Codex cell). Each fails in the same runtime cells on unpatched mainadb12365084on this host, so these failures already exist on main and are not caused by this change.Unit:
message-tool-terminal*.test.ts,dynamic-tools.source-reply,run-attempt-lifecycle-controller,event-projector.source-finish,message-tool-execution) andagent-tools.prefix-stability, all unchanged.Lint:
oxlint --type-awarereportsmax-linesonrun-attempt-dispatch.tsand three unresolved-type errors indynamic-tools.ts. All four already appear on main with the same local setup.