Repository navigation
fix(ai): retain usage and provider errors after rejected Responses tool calls - #149071
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review blockedAutomated review did not run, so no review verdict was produced. Reason: The input-safety check could not safely complete for this revision. ClawSweeper will not retry this unchanged revision. Next step: No contributor action is requested. Maintainers should inspect the linked workflow run. |
|
Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 5:40 AM ET / 09:40 UTC (Revision 5). ClawSweeper reviewWhat this changesThe Responses transport retains token usage and provider errors after rejecting unfinished or malformed tool calls while preventing later calls from executing. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main and the latest release still lose terminal facts for these rejection paths. The refreshed patch preserves the existing parser and identity checks, and no actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s Responses transport converts provider stream events into assistant messages and executable tool completions. Its terminal accounting and errors feed the agent loop’s settlement and recovery decisions. flowchart TD
A[Provider stream] --> B[Responses transport]
B --> C{Tool completion valid?}
C -->|Yes| D[Agent tool execution]
C -->|No| E[Close further tool admission]
E --> F[Collect terminal usage and errors]
D --> G[Settle admitted work]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +11, Tests +178. Total +189 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep strict tool validation and the existing admission owner while retaining terminal accounting and authoritative provider failures on rejected responses. Do we have a high-confidence way to reproduce the issue? Yes, from source: an invalid completed tool call or in-progress item completion throws on current main before a later terminal response can supply usage and provider errors. Tests were inspected but not executed during this read-only review. Is this the best way to solve the issue? Yes. Extending the existing rejection latch is a narrow repair that retains the canonical parser, identity checks, and terminal-error projection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d2580ac064bc. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
060b447 to
b16ee3b
Compare
Drain terminal accounting after rejected item completions without admitting later tools or replacing the original validation error. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
b16ee3b to
81d78bd
Compare
|
@clawsweeper re-review Refreshed onto current main, preserving output-identity tracking and parse-once argument selection. The terminal validator now remains unchanged from main. All 150 focused tests pass and the fresh dependency-grounded autoreview is clean. Updated scope and verification evidence are in the PR body. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Merge canonical main after openclaw#149071 landed and PR147611 became conflicting. Preserve the published PR head and original contributor ancestry. Keep canonical transport drain and current retry-policy ownership unchanged. Retain both the bounded terminal-coherence tests and the landed rejection-ending fencing matrix. Adapt the real Gateway/Responses/file-tool proof to allow early malformed item completion only after coherent terminal evidence, retain all unsafe negatives, and add the no-terminal EOF boundary. Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: RomneyDa <[email protected]>
…aw#149071) Drain terminal accounting after rejected item completions without admitting later tools or replacing the original validation error. Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
Related: #147040, #147611
What Problem This Solves
Fixes: Responses tool-call rejection can discard final token usage and provider failure details when an item completes with an unfinished status or malformed JSON arguments.
User Impact
Rejected and subsequent tool calls remain non-executable, while already-admitted work settles and reported accounting is retained. Malformed JSON is neither repaired nor automatically classified as token exhaustion. No configuration or migration is required.
Why This Change Was Made
Extend the existing admission latch to retain completion-validation errors and drain terminal facts before reporting the rejection. Cancellation and provider refusal/failure retain their precedence. Runner recovery and terminal diagnostic contracts are unchanged.
The September 21 conflict resolution retains main’s output-identity tracking and parse-once argument selection. The terminal validator is now unchanged from main; no competing argument-selection path remains. No unrelated baseline-CI repair is included.
Evidence
--maxWorkers=1, the combined runner wall was 5.07 seconds (Vitest 4.12 seconds). An admitted async call settles; rejected and later calls never execute.81d78bdacb0d74656a383e04448942af808b8627; base:be3d22b1745917a2c03a1adb999ed51960a3c275.git range-diffconfirms unchanged regression tests and the deliberate removal of the old argument-selection relocation in favor of main’s parse-once owner. Whitespace checks pass.node scripts/check-changed.mjs --base be3d22b1745917a2c03a1adb999ed51960a3c275 --stagedpassed, including production/test typechecks, formatting, lint, dead-export scans, and applicable guards.--maxWorkers=1also passed: terminal-error 42 cases / 1.79 s wall, terminal-recovery 38 cases / 1.72 s, real-loop rejection 3 cases / 1.82 s. These reruns overlap the 150-case suite and are not additional test counts.openclaw/ci-gatechecks pass, and the repository watcher returnedGREEN. CodeQL’s neutral advisory is not a failed check.These are synthetic transport and real agent-loop boundary tests, not live-provider proof. No visual changes.
Worked on by: @RomneyDa
Work sessions