Repository navigation
fix(agents): continue after rejected malformed tool calls - #158568
MagMueller wants to merge 1 commit into
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 changes before merge. Reviewed October 3, 2026, 11:06 PM ET / October 4, 2026, 03:06 UTC (Revision 3). ClawSweeper reviewWhat this changesThe embedded agent runner resumes the existing transcript up to twice after a malformed tool call is rejected, provided earlier tools have fully settled. Merge readiness⛔ Needs changes before merge - 1 item remains This remains a useful, proven fix that current main does not implement. No introduced correctness defect was found, but the pinned head has confirmed merge conflicts. Priority: P1 Review scores
Verification
How this fits togetherThe embedded agent runner coordinates model responses, tool execution, and conversation history. Its recovery layer decides whether a failed response can continue safely or must end the run. flowchart TD
A[Model response] --> B[Tool argument validation]
B --> C[Malformed call rejected]
C --> D[Recovery safety checks]
E[Recorded tool results and lifecycle] --> D
D --> F[Continue existing transcript]
D --> G[End failed run]
F --> A
Before merge
Agent review detailsSecurityNone. PR surfaceSource +43, Tests +41. Total +84 across 3 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep malformed-call recovery in the existing runner owner, preserving settled results, cancellation, approval boundaries, and the bounded continuation budget. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the settled-tool malformed-response path, and the supplied real-run trace observes it. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes, the patch extends the existing recovery and transcript owners without replaying the original request or adding configuration; the conflict-resolved version still needs assessment against current main. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cc740dfaf528. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
bd3163d to
f116ada
Compare
ericcaiwx-star
left a comment
There was a problem hiding this comment.
Reproduced on qq-ci-158568 at head f116adaa665fa5e5eafdd2bdb31790cc6e642a47.
Lane: qq-ci-158568 (v24.19.0)
Command: python3 /Users/ericstudio/repos/oc-pr-management/.tmp/qq-upstream-review-20261004/ci-proof.py --pr 158568
Result: exit 0, passed 3 Vitest shards in 117.53s
Independent secretless Ubuntu 24.04 fork CI used Node 24.19.0, pnpm 12.4.2, the built native CLI, a deterministic loopback Chat Completions stream, and a real exec effect ledger. Workflow, artifacts, and raw logs; pinned harness.
Parent deb168691b2a10fde299ec0f911c8a5cbd9d0dda failed the continuation assertions and the CLI recovery scenario. At this head, the selected tests passed. The recovery scenario completed on the third model request with the original user turn present once, the existing tool result retained, and the preparation command executed once. Persistent malformed output failed after six model requests, with the preparation command still executed once. A settled foreground tool timeout also continued with the prior failure retained and explicitly reported by the synthetic response.
These are deterministic stream and native-runner observations. They do not establish live provider compliance, actual channel delivery, or executor-enforced exactly-once semantics.
Additional evidence: Adds publicly inspectable exact-parent/head Chat Completions CLI regression evidence with real tool-effect and transcript counts, including persistent rejection and a settled foreground tool timeout; the supplied real-provider trace uses an older combined benchmark revision.
Sibling surface checked: src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts:297; src/agents/embedded-agent-runner/run/terminal-resolution.ts:246; src/agents/embedded-agent-runner/run/message-tool-terminal.ts:94.
Not covered: live DeepSeek, real QQ delivery, Browser Harness/Codex/native-provider routes, and concurrency races; message/spawn producer probes use synthetic receipts and a mocked recovery seam.
|
Thanks @MagMueller for this fix and the careful fail-closed conditions. The same behavior is now on We re-verified the shared continuation scenario on current main with a local Gemma 4 Gateway run while working on the related #168500 (auth misclassification of 401/403-character arguments, also now fixed), so I'm closing this as superseded. If you have a case where a settled tool batch still ends the turn on a current build, please open an issue with the provider stream and we'll look again. |
What Problem This Solves
A provider can reject a malformed tool call before dispatch after earlier tools have already completed. OpenClaw currently terminates that run even though the transcript has settled results and can be continued safely.
Change
This is deliberately separate from #126255: it is a generic embedded-runner fix, not Browser Harness integration code. It changes three files.
Safety
The original user request and already-completed tools are never replayed. Recovery is allowed only after all prior tool calls are settled; otherwise the existing terminal failure remains unchanged.
Evidence
attempt-recovery.test.ts: 94/94 passing in 7.90s; the new malformed-call continuation case completed in 3msgit diff --check: passingRedacted real-path recovery trace
One retained exact-run task used target
4a1081fbeda9182f8c99710bafe7706715e0237f(the benchmarked revision of this patch), real Anthropic Claude Opus 5, and the normal embedded OpenClaw runner. Its terminal log records the provider rejection, the guarded continuation on the same run/session, and a normal stop:The preserved result envelope is
status=completedwith a 7,443-character final answer, and the independent semantic judge awarded1.0. This is the real provider/transcript path; the prompt, task identifier, run identifier, and task output are omitted because the benchmark is private. The settled-tool gate and continuation budget are the same paths covered by the focused test.Current head
f116adaa665fa5e5eafdd2bdb31790cc6e642a47is rebased ondeb168691b2a10fde299ec0f911c8a5cbd9d0dda. Hosted general lint passes. The only current hosted CI failure ischeck-lint-core-2, which reports that unchanged base filesrc/gateway/server-kernel.test.tsis over its line cap; that file is 1,033 lines on the exact base and is not in this PR diff.