Repository navigation
fix: scheduled runs stop on a malformed tool call - #201117
Conversation
|
🦞👀 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 changesAllows optional-reply runs to use the existing bounded continuation after an eligible malformed tool call is rejected before dispatch. Example: An isolated cron run completes a write, then receives a write call with truncated JSON arguments.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR fixes a current scheduled-run failure with a focused change and sufficient Gateway proof; no actionable defects were found, and exact-head CI remains in progress. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe embedded runner combines provider responses, tool lifecycle evidence, delivery state, and reply expectations to choose continuation or a terminal result for chat and scheduled callers. flowchart TD
A[Scheduled agent turn] --> B[Embedded runner]
B --> C[Provider response]
C --> D[Terminal resolution]
E[Tool and delivery evidence] --> D
D --> F[Bounded continuation]
F --> B
D --> G[Completed run result]
Technical reviewBest possible solution: Keep rejection eligibility in the existing recovery owner and allow optional turns through its bounded continuation without weakening silence, delivery, or tool-settlement guards. Do we have a high-confidence way to reproduce the issue? The supplied isolated Gateway comparison reproduces failure on baseline 1fc5296 and recovery on 6897df4 through cron.run; current-main source retains the same failing gate, and no target code was executed during this read-only review. Is this the best way to solve the issue? The patch is the smallest complete repair: one shared rejection predicate serves the existing recovery selector and optional-policy gate, with one focused scheduled-turn regression and no new state or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2f5bb506ef61. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +12, Tests +12. Total +24 across 3 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 18, 2026, 6:56 AM ET / 11:56 UTC (Revision 3). |
|
@vincentkoc @obviyus PTAL when you get a chance, and could one of you approve the workflow runs? Thank you! |
- isRejectedBeforeDispatch reads the attempt's own assistant; callers keep the delivered-reply veto. - The optional-reply gate reads it in one line; terminal-resolution.ts is one line over the 700-line cap.
|
Gateway proof for this head (6897df4) against main 1fc5296: isolated Gateway from source, local Anthropic Messages fixture. Provider request log, candidate cron run (one continuation, the completed write is not repeated): Fixture and harness: an Anthropic SSE server that returns a write tool call, then a write call with truncated JSON arguments, then (after the host continuation) a final answer or another malformed call. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
- Drops the file-scoped max-lines exception. - Inlines the single-use terminalAssistant local in resolveSettledTurnFinalizationRequest; no behavior change.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks @ericcurtin for the fix and @jaxonparrott for the report. This is merged in 93ec0fe: scheduled (cron) runs now get the same one-time continuation after a malformed tool call that chat turns already get, so the run can recover instead of ending with an error. A model that keeps producing malformed calls still fails after that single continuation. |
Root cause: src/agents/embedded-agent-runner/run/terminal-resolution.ts:231 treats the "optional" reply expectation as unconditional reply-recovery suppression, so a scheduled run (cron sets "optional" at src/cron/isolated-agent/run-prompt-executor.ts:449) never reaches the existing single continuation for a tool call rejected before dispatch. Fixes openclaw#201104 Thanks @jaxonparrott for the report and the source trace, and @ericcurtin for the fix. ## What Problem This Solves A scheduled run ends with "OpenClaw couldn't finish this reply" when the provider sends one malformed tool call. Chat turns and subagents get one continuation for the same failure and finish. ## User Impact Scheduled runs, heartbeats and hooks (every "optional" reply turn) get the same single continuation as chat turns when a tool call is rejected before it ran. Optional turns that author silence stay silent; delivered replies, ordinary empty optional turns and the one-continuation budget are unchanged. ## Why This Change Was Made "Optional reply" means the model may author silence. A call the transport rejected before dispatch is a provider error, not authored silence. The rejected-before-dispatch check moves into one helper in the recovery owner (`isRejectedBeforeDispatch`), and the optional-reply gate exempts only that fact. No new model-facing text: the existing continuation instruction is reused. `terminal-resolution.ts` stays within its 700-line cap: a single-use local in `resolveSettledTurnFinalizationRequest` is inlined (no behavior change). Production +28/-16 (mostly the moved check), tests +13/-1. ## Evidence Isolated Gateway from source (`ocx src`) on main 2076d8a vs this branch, with a local Anthropic Messages fixture: a side-effecting `write` call, then a `write` call with truncated JSON arguments (rejected with `malformed_tool_call_arguments`). - Cron run (cron.add isolated agentTurn, cron.run force): main ends `status=error` "couldn't finish this reply" with no continuation request; this branch sends one continuation and the run ends `status=ok` with the model's answer. The completed `write` is not repeated. - Cron run where the model keeps sending malformed calls: one continuation ("retrying 1/1"), then the run fails as before. - Chat control: one continuation and recovery on both main and this branch, unchanged. - An executed tool that returned an error before the malformed call (openclaw#199537) still ends without a continuation on both; that is a separate guard and not changed here. - Regression `continues a rejected call once in a scheduled run`: fails on main, passes here. terminal-resolution, incomplete-turn-recovery and cron message-tool-policy suites pass; oxfmt and oxlint clean. Proof log: openclaw#201117 (comment) Merge danger: two-way door; a revert restores the old suppression. No config, schema or state change. Blast radius: optional-reply turns (cron, heartbeat, hooks) whose last model response was a tool call rejected before dispatch. Co-authored-by: Ayaan Zaidi <[email protected]>
Root cause: src/agents/embedded-agent-runner/run/terminal-resolution.ts:231 treats the "optional" reply expectation as unconditional reply-recovery suppression, so a scheduled run (cron sets "optional" at src/cron/isolated-agent/run-prompt-executor.ts:449) never reaches the existing single continuation for a tool call rejected before dispatch. Fixes #201104 Thanks @jaxonparrott for the report and the source trace, and @ericcurtin for the fix. ## What Problem This Solves A scheduled run ends with "OpenClaw couldn't finish this reply" when the provider sends one malformed tool call. Chat turns and subagents get one continuation for the same failure and finish. ## User Impact Scheduled runs, heartbeats and hooks (every "optional" reply turn) get the same single continuation as chat turns when a tool call is rejected before it ran. Optional turns that author silence stay silent; delivered replies, ordinary empty optional turns and the one-continuation budget are unchanged. ## Why This Change Was Made "Optional reply" means the model may author silence. A call the transport rejected before dispatch is a provider error, not authored silence. The rejected-before-dispatch check moves into one helper in the recovery owner (`isRejectedBeforeDispatch`), and the optional-reply gate exempts only that fact. No new model-facing text: the existing continuation instruction is reused. `terminal-resolution.ts` stays within its 700-line cap: a single-use local in `resolveSettledTurnFinalizationRequest` is inlined (no behavior change). Production +28/-16 (mostly the moved check), tests +13/-1. ## Evidence Isolated Gateway from source (`ocx src`) on main 1fc5296 vs this branch, with a local Anthropic Messages fixture: a side-effecting `write` call, then a `write` call with truncated JSON arguments (rejected with `malformed_tool_call_arguments`). - Cron run (cron.add isolated agentTurn, cron.run force): main ends `status=error` "couldn't finish this reply" with no continuation request; this branch sends one continuation and the run ends `status=ok` with the model's answer. The completed `write` is not repeated. - Cron run where the model keeps sending malformed calls: one continuation ("retrying 1/1"), then the run fails as before. - Chat control: one continuation and recovery on both main and this branch, unchanged. - An executed tool that returned an error before the malformed call (#199537) still ends without a continuation on both; that is a separate guard and not changed here. - Regression `continues a rejected call once in a scheduled run`: fails on main, passes here. terminal-resolution, incomplete-turn-recovery and cron message-tool-policy suites pass; oxfmt and oxlint clean. Proof log: #201117 (comment) Merge danger: two-way door; a revert restores the old suppression. No config, schema or state change. Blast radius: optional-reply turns (cron, heartbeat, hooks) whose last model response was a tool call rejected before dispatch. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 93ec0fe) Co-authored-by: RomneyDa <[email protected]>
Root cause: src/agents/embedded-agent-runner/run/terminal-resolution.ts:231 treats the "optional" reply expectation as unconditional reply-recovery suppression, so a scheduled run (cron sets "optional" at src/cron/isolated-agent/run-prompt-executor.ts:449) never reaches the existing single continuation for a tool call rejected before dispatch. Fixes openclaw#201104 Thanks @jaxonparrott for the report and the source trace, and @ericcurtin for the fix. ## What Problem This Solves A scheduled run ends with "OpenClaw couldn't finish this reply" when the provider sends one malformed tool call. Chat turns and subagents get one continuation for the same failure and finish. ## User Impact Scheduled runs, heartbeats and hooks (every "optional" reply turn) get the same single continuation as chat turns when a tool call is rejected before it ran. Optional turns that author silence stay silent; delivered replies, ordinary empty optional turns and the one-continuation budget are unchanged. ## Why This Change Was Made "Optional reply" means the model may author silence. A call the transport rejected before dispatch is a provider error, not authored silence. The rejected-before-dispatch check moves into one helper in the recovery owner (`isRejectedBeforeDispatch`), and the optional-reply gate exempts only that fact. No new model-facing text: the existing continuation instruction is reused. `terminal-resolution.ts` stays within its 700-line cap: a single-use local in `resolveSettledTurnFinalizationRequest` is inlined (no behavior change). Production +28/-16 (mostly the moved check), tests +13/-1. ## Evidence Isolated Gateway from source (`ocx src`) on main 1fc5296 vs this branch, with a local Anthropic Messages fixture: a side-effecting `write` call, then a `write` call with truncated JSON arguments (rejected with `malformed_tool_call_arguments`). - Cron run (cron.add isolated agentTurn, cron.run force): main ends `status=error` "couldn't finish this reply" with no continuation request; this branch sends one continuation and the run ends `status=ok` with the model's answer. The completed `write` is not repeated. - Cron run where the model keeps sending malformed calls: one continuation ("retrying 1/1"), then the run fails as before. - Chat control: one continuation and recovery on both main and this branch, unchanged. - An executed tool that returned an error before the malformed call (openclaw#199537) still ends without a continuation on both; that is a separate guard and not changed here. - Regression `continues a rejected call once in a scheduled run`: fails on main, passes here. terminal-resolution, incomplete-turn-recovery and cron message-tool-policy suites pass; oxfmt and oxlint clean. Proof log: openclaw#201117 (comment) Merge danger: two-way door; a revert restores the old suppression. No config, schema or state change. Blast radius: optional-reply turns (cron, heartbeat, hooks) whose last model response was a tool call rejected before dispatch. Co-authored-by: Ayaan Zaidi <[email protected]> Release adaptation: Source rejected-before-dispatch optional scheduled reply recovery retained. (cherry picked from commit 93ec0fe) Co-authored-by: RomneyDa <[email protected]>
Root cause: src/agents/embedded-agent-runner/run/terminal-resolution.ts:231 treats the "optional" reply expectation as unconditional reply-recovery suppression, so a scheduled run (cron sets "optional" at src/cron/isolated-agent/run-prompt-executor.ts:449) never reaches the existing single continuation for a tool call rejected before dispatch.
Fixes #201104
Thanks @jaxonparrott for the report and the source trace, and @ericcurtin for the fix.
What Problem This Solves
A scheduled run ends with "OpenClaw couldn't finish this reply" when the provider sends one malformed tool call. Chat turns and subagents get one continuation for the same failure and finish.
User Impact
Scheduled runs, heartbeats and hooks (every "optional" reply turn) get the same single continuation as chat turns when a tool call is rejected before it ran. Optional turns that author silence stay silent; delivered replies, ordinary empty optional turns and the one-continuation budget are unchanged.
Why This Change Was Made
"Optional reply" means the model may author silence. A call the transport rejected before dispatch is a provider error, not authored silence. The rejected-before-dispatch check moves into one helper in the recovery owner (
isRejectedBeforeDispatch), and the optional-reply gate exempts only that fact. No new model-facing text: the existing continuation instruction is reused.terminal-resolution.tsstays within its 700-line cap: a single-use local inresolveSettledTurnFinalizationRequestis inlined (no behavior change). Production +28/-16 (mostly the moved check), tests +13/-1.Evidence
Isolated Gateway from source (
ocx src) on main 1fc5296 vs this branch, with a local Anthropic Messages fixture: a side-effectingwritecall, then awritecall with truncated JSON arguments (rejected withmalformed_tool_call_arguments).status=error"couldn't finish this reply" with no continuation request; this branch sends one continuation and the run endsstatus=okwith the model's answer. The completedwriteis not repeated.continues a rejected call once in a scheduled run: fails on main, passes here. terminal-resolution, incomplete-turn-recovery and cron message-tool-policy suites pass; oxfmt and oxlint clean.Proof log: #201117 (comment)
Merge danger: two-way door; a revert restores the old suppression. No config, schema or state change. Blast radius: optional-reply turns (cron, heartbeat, hooks) whose last model response was a tool call rejected before dispatch.