Repository navigation
fix(agents): completions-API models leak tool-call preambles into chats — tag pre-tool narration as commentary - #109057
Conversation
f325daf to
ffadaa2
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 7:49 AM ET / 11:49 UTC. Summary PR surface: Source +155, Tests +385. Total +540 across 16 files. Reproducibility: yes. The PR provides a concrete current-main baseline and an after-fix real OpenAI-compatible SSE scenario with a tool-call preamble, final reply, persisted transcript output, and rendered webchat result. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Keep the shared phase-tagging contract at the stream boundary, preserve it through redaction, and land only after exact-head checks confirm the covered tool-use and ordinary-reply paths remain intact. Do we have a high-confidence way to reproduce the issue? Yes. The PR provides a concrete current-main baseline and an after-fix real OpenAI-compatible SSE scenario with a tool-call preamble, final reply, persisted transcript output, and rendered webchat result. Is this the best way to solve the issue? Yes. Resolving the phase before tool-call events and reusing the existing commentary delivery gate is narrower and more maintainable than adding per-channel suppression logic; the redaction preservation closes the corresponding reload/resume path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f98bcb7fa73c. Label changesLabel justifications:
Evidence reviewedPR surface: Source +155, Tests +385. Total +540 across 16 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (7 earlier review cycles)
|
3778f8d to
c22c0b8
Compare
c22c0b8 to
9826b15
Compare
9826b15 to
c78009d
Compare
c78009d to
e18d1e8
Compare
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(agents): completions-API models leak tool-call preambles into chats — tag pre-tool narration as commentary This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Co-authored-by: Arseniy Palagin <[email protected]>
e18d1e8 to
a44f89c
Compare
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(agents): completions-API models leak tool-call preambles into chats — tag pre-tool narration as commentary This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Merged via squash.
|
…aw#109057) Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Arseniy Palagin <[email protected]>
Closes #108945
Related: #25592, #80458
What Problem This Solves
Providers using
api: "openai-completions"could deliver model narration such as “I’ll check that…” as an ordinary chat reply before a tool call. Chat Completions streaming exposes content deltas, tool-call deltas, and finish reasons, but no commentary phase, so OpenClaw must resolve that phase at the tool boundary.Why This Change Was Made
Both completions processors now provisionally tag buffered text immediately before the first consumer-visible tool-call event. A shared helper also serves the Anthropic transport, assigns deterministic v1 commentary signatures, and tracks the exact blocks/signatures generated by the current turn.
If the provider later resolves to
finish_reason: "stop"and tool calls are stripped as spurious, only those exact provisional signatures are rolled back. Emptytool_calls: []arrays never trigger tagging. Confirmed tool turns receive a final backstop tag for text arriving after the last tool-call delta.The embedded subscriber withholds unphased Chat Completions text from durable block replies until the authoritative
message_end: commentary is suppressed, while ordinary and rolled-back spurious-tool answers use the existing final delivery path. Valid v1 phase signatures are preserved through transcript redaction for Completions and Anthropic routes, without broadening reasoning-replay exemptions.No new config or stored-data shape is introduced;
textSignatureis an existing optional text-block field.User Impact
Tool-call preambles stay in the transient commentary/progress lane and never become durable chat bubbles. Final answers, ordinary no-tool replies, and text from stripped spurious tool calls remain deliverable in full and in order.
Evidence
read, delivered onlyFINAL_RESULT, and omittedPREAMBLE_SHOULD_NOT_DELIVER;PLAIN_RESULT;finish_reason=stopplus a spurious tool call deliveredSPURIOUS_RESULTwith no tool execution.git diff --check origin/main...HEAD: passed.Credit is retained with
Co-authored-by: Arseniy Palagin <[email protected]>.