Skip to content

fix(openai): preserve complete tool calls from clean streams without finish_reason - #98124

Merged
steipete merged 3 commits into
openclaw:mainfrom
SunnyShu0925:fix/openai-stream-no-finish-tool-97994
Jul 10, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
SunnyShu0925:fix/openai-stream-no-finish-tool-97994

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenAI-compatible providers that emit delta.tool_calls during streaming but terminate with data: [DONE] without a final finish_reason chunk (e.g. Evolink DeepSeek V4) have their tool calls silently stripped, so the agent never executes the tool.

  • Problem: processOpenAICompletionsStream post-loop requires sawStopFinishReason to be true before promoting silent tool-call-only responses to toolUse. When the stream completes cleanly via data: [DONE] but no chunk carried finish_reason, the tool calls are dropped. However, unconditionally promoting tool calls on any EOF would execute tools from truncated streams (connection drops without [DONE]).
  • Solution: Track two signals independently. sawNativeToolCallDelta is set when structured delta.tool_calls arrives. sawStreamDONE is detected at the HTTP response body level via TransformStream.pipeThrough — the OpenAI SDK consumes [DONE] internally, so we intercept the raw SSE stream. For post-loop promotion: sawStopFinishReason (legacy, covers DSML text-recovered calls) OR (sawNativeToolCallDelta AND sawStreamDONE) (clean [DONE] without finish_reason). EOF without [DONE] remains fail-closed.
  • What changed: src/agents/openai-transport-stream.ts (add sawNativeToolCallDelta + sawStreamDONE; intercept fetch with TransformStream to detect data: [DONE] in raw SSE body; update promotion to (sawStopFinishReason || (sawNativeToolCallDelta && sawStreamDONE))), src/agents/openai-transport-stream.test.ts (update test + add 2 new tests including no-[DONE] fail-closed case)
  • What did NOT change: DSML-recovered tool call behavior (still requires sawStopFinishReason), the hasToolCalls && stopReason !== "toolUse" strip guard, finalizeTransportStream / failTransportStream paths

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Motivation

Providers like Evolink's deepseek-v4-pro stream valid delta.tool_calls with data: [DONE] as the stream terminator but no finish_reason: "tool_calls" chunk. The agent appears to reason about using a tool but never executes it — toolMetas: [], the turn fails, and the user sees no action. Non-streaming requests to the same provider return finish_reason: "tool_calls" correctly.

The reporter confirmed that a local patch preserving tool-call blocks without finish_reason made the same read-tool self-test pass, and a comparison route (evolink/gpt5.5) in the same OpenClaw setup did not show the issue.

The non-transport openai-completions.ts path already promotes on (stopReason === "stop" && hasToolCalls && !hasVisibleText) without requiring an explicit finish_reason — the transport path diverged when 6316648bab added the sawStopFinishReason guard to prevent EOF-as-truncation promotion. But clean-stream EOF is architecturally different from a truncated stream (which throws before reaching post-loop), so the guard over-corrects.

Evidence

  • Behavior addressed: Streaming tool-call-only responses without finish_reason were dropped; they are now promoted to toolUse.
  • Real environment tested: Linux x64, Node.js v22.19.0, branch fix/openai-stream-no-finish-tool-97994
  • Exact steps or command run after this patch:
# 1. Exact SSE data: [DONE] line-boundary proof (8 cases)
node -e "
  const RE = /^data:\s*\[DONE\]\s*$/i;
  // data: [DONE] → yes;  {\"args\":[DONE]} → no;  event: [DONE] → no
"

# 2. Loopback SSE proof through createOpenAICompletionsTransportStreamFn
#    (real HTTP server → fetch wrapper → TransformStream → promotion gating)
node --import tsx proof-loopback.mjs   # [DONE] without finish_reason
node --import tsx proof-loopback.mjs   # EOF without [DONE]

# 3. Vitest regression suite (18 tests across 2 projects)
node scripts/run-vitest.mjs --run src/agents/openai-transport-stream.test.ts \
  -t 'cleanly without finish_reason|visible text and no finish_reason|does not promote native|does not authorize recovered DeepSeek|finish_reason stop|finish_reason tool_calls'
  • Evidence after fix:
$ node -e "..."   # Exact SSE data: [DONE] parsing

exact data: [DONE]                            ✅ detected
data:[DONE] (no space)                        ✅ detected
data: [DONE] (trailing)                       ✅ detected
content with [DONE] inside                    ✅ rejected
tool_calls containing [DONE]                  ✅ rejected
comment line with [DONE]                      ✅ rejected
event: [DONE] (wrong field)                   ✅ rejected
$ node --import tsx proof-loopback.mjs   # real HTTP → fetch wrapper → promotion

=== Loopback SSE Proof (#97994) ===
events: 4 | stopReason: toolUse | toolCalls: 1
  tool: read({"file":"/tmp/test.txt"})

✅ PASS — loopback SSE: [DONE] without finish_reason → toolUse
$ node --import tsx proof-loopback-eof.mjs   # EOF without [DONE]

=== Loopback SSE Proof — EOF without [DONE] ===
events: 4 | stopReason: stop | toolCalls: 0

✅ PASS — EOF without [DONE] remains fail-closed
$ node scripts/run-vitest.mjs --run src/agents/openai-transport-stream.test.ts -t '...'
 Test Files  2 passed (2)
      Tests  18 passed | 558 skipped (568)
```| Input scenario | sawStreamDONE | stopReason | tool calls retained | expected |
|---|---|---|---|---|
| `finish_reason: "tool_calls"`, no text | N/A | `toolUse` | ✅ yes | executes tools |
| `finish_reason: "stop"`, no text | N/A | `toolUse` | ✅ yes | executes tools (#88791) |
| **native tool calls + `finish_reason: null` + `[DONE]`** | ✅ true | **`toolUse`** | ✅ **yes** | **executes tools (this fix)** |
| **native tool calls + `finish_reason: null` + EOF only** | ❌ false | **`stop`** | **❌ no (stripped)** | **fail-closed (safety)** |
| tool calls + visible text, `finish_reason: null` | N/A | `stop` | ❌ no | conservative (ambiguous) |
| DSML-recovered + no `finish_reason` + `[DONE]` | N/A | `stop` | ❌ no | DSML still requires `finish_reason` |

- **Observed result after fix**:
  1. Native `delta.tool_calls` with a clean SSE `[DONE]` but no `finish_reason` are promoted to `toolUse` and tool blocks are retained.
  2. Native `delta.tool_calls` with EOF only (no `[DONE]`, no `finish_reason`) remain fail-closed — connection drops do not execute tools.
  3. DSML text-recovered tool calls still require `sawStopFinishReason` — no regression.
  4. All existing behaviors are unchanged.
- **What was not tested**: Live Evolink API endpoint (no API key); non-streaming fallback via that exact provider.

### Live Provider Regression Proof (DeepSeek Official API)

DeepSeek official `deepseek-chat` tested through the complete fetch wrapper path to prove the TransformStream `[DONE]` detection does not break normal providers.

```console
=== DeepSeek Live Regression Proof (#98124) ===
API key: sk-ef782...b866
Model: deepseek-chat
Base URL: https://api.deepseek.com/v1

[model-fetch] start provider=deepseek api=openai-completions model=deepseek-chat ...
[model-fetch] response status=200 elapsedMs=372 contentType=text/event-stream
Events: 12 | types: start, text_start, text_delta, done
Done reason: stop
✅ text response completed normally
✅ stream completed without errors
✅ fetch wrapper + TransformStream handled real SSE without issues

✅ PASS — DeepSeek official API regression proof: fix does not break normal providers
  • Verified: Real SSE stream → fetch wrapper → TransformStream → OpenAI SDK consumption. The data: [DONE] detection correctly observes the stream terminal without false matches on provider content. Normal provider behavior is unchanged.
  • Not verified: DeepSeek official returns text-form tools, not native delta.tool_calls, so the promotion path was not exercised via this provider. The no-finish promotion path is covered by the loopback SSE tests added to the test file.

Root Cause (if applicable)

processOpenAICompletionsStream in src/agents/openai-transport-stream.ts:3245-3252: the post-loop promotion condition required sawStopFinishReason (set only when a chunk carries finish_reason with stop type "stop"). When the stream completes cleanly (for-await exits normally) but no chunk carries finish_reason, the promotion is skipped and the downstream hasToolCalls && stopReason !== "toolUse" guard strips the parsed tool-call blocks.

Provenance: introduced by 6316648bab (MonkeyLeeT / Ted Li, 2026-05-31, PR #88791 "fix(openai): keep stop-finished tool calls"), made visible by Evolink DeepSeek V4 streaming API omitting finish_reason. Confidence: clear.

Regression Test Plan

  • Target test file: src/agents/openai-transport-stream.test.ts
  • Covered scenarios: clean-stream no-finish promotion, visible-text no-finish conservative strip, finish_reason: "stop" promotion (regression), finish_reason: "tool_calls" promotion (regression), finish_reason: "stop" with visible text strip (regression)
  • Minimal guard rationale: The hasToolCalls && stopReason !== "toolUse" post-loop strip guard and the !hasVisibleText promotion guard remain active — the only change is that clean-stream completion (reaching post-loop) is now sufficient to trigger promotion, symmetric with the non-transport path.

User-visible / Behavior Changes

Previously, agents using OpenAI-compatible streaming providers that omit finish_reason would silently skip tool execution. After this fix, those tool calls execute normally. No observable change for users of providers that already emit finish_reason.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No (tool calls were already parsed and structured; this fix only promotes them to execution when the stream completes cleanly — same safety contract as the finish_reason: "stop" path)
  • Data access scope changed? No

Human Verification (required)

  • Verified scenarios: Clean-stream no-finish tool calls promoted (tsx runtime), visible-text no-finish tool calls stripped (vitest), all regression tests pass
  • Edge cases checked: Mixed text+tool-calls without finish_reason (conservative strip), clean-stream with finish_reason (unchanged), finish_reason="tool_calls" (unchanged)
  • What you did NOT verify: Live Evolink endpoint behavior, truncated stream error-path behavior (throws before post-loop, architecturally unchanged)

Compatibility / Migration

  • Backward compatible? Yes — existing behaviors for finish_reason-bearing providers are unchanged
  • Config/env changes? No
  • Migration needed? No

Best-fix Verdict

  • Best fix: Yes — adding sawNativeToolCallDelta + sawStreamDONE gives the post-loop a structured-provider signal gated by a clean SSE terminal. The TransformStream.pipeThrough interceptor detects data: [DONE] before the OpenAI SDK consumes it, distinguishing clean termination from connection drops. This matches ClawSweeper's recommendation: "[P1] Carry an explicit clean SSE terminal signal so [DONE] without finish_reason promotes tool calls while EOF without [DONE] remains fail-closed."
  • Safety guard: EOF without [DONE] (connection drop, truncated response) remains fail-closed because sawStreamDONE is never set. The (sawNativeToolCallDelta && sawStreamDONE) conjunction ensures both conditions: provider signaled tool-use intent AND stream terminated cleanly.
  • Alternative considered:
    • Adding a separate !sawStopFinishReason condition block alongside the existing one — maintains sawStopFinishReason as unused dead code and creates two parallel promotion paths with asymmetric conditions. Rejected: less clean, harder to audit.
    • Defaulting sawStopFinishReason to true — too aggressive; changes behavior for all non-finish streams including potential future error paths.
    • Adding a sawCleanDone tracker that detects data: [DONE] at the SSE level — over-engineered; the for-await normal exit is the architectural equivalent.

AI Assistance 🤖

  • AI-assisted: Yes
  • Co-Authored-By: Claude Opus 4.8 [email protected]
  • Human confirmed understanding of code changes: Yes
  • AI prompts / session excerpts: See commit message and PR body for full analysis chain (provenance → root cause → invariant → fix → test matrix).

Risks and Mitigations

  • Highest risk area: A provider that streams tool calls but the connection drops mid-stream without throwing (extremely rare — Node fetch typically throws on TCP reset). Mitigation: finishAllToolCallBlocks() runs parseStreamingJson on partial arguments before promotion; a genuinely truncated tool call would likely fail JSON parse, but the current code does not check for parse success. This is a pre-existing condition, not introduced by this PR, and also applies to the finish_reason: "stop" promotion path.
  • Compatibility: No breaking change. Providers that emit finish_reason are unaffected. Providers that omit it now get correct tool execution.
  • Fallback: If a provider emits both visible text and tool calls without finish_reason, the conservative !hasVisibleText guard still strips tool calls (the model likely hallucinated tool-like text).

Fixes #97994

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jun 30, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 9:11 AM ET / 13:11 UTC.

Summary
The PR wraps the OpenAI-completions transport fetch to observe raw SSE [DONE], promotes native no-finish tool-call streams only when that clean terminal was seen, and adds direct plus fetch-wrapper regression tests.

PR surface: Source +67, Tests +342. Total +409 across 2 files.

Reproducibility: yes. at source level: current main still strips parsed streamed tool calls when no final finish reason is present, and the canonical issue provides provider logs showing valid delta.tool_calls followed by [DONE] with no tool execution. I did not rerun the live Evolink route in this read-only review.

Review metrics: 1 noteworthy metric.

  • Tool-execution promotion gate: 1 widened finalizer path. The diff can turn native no-finish streamed tool calls into executable toolUse only when raw SSE DONE was observed, so maintainers should notice the execution-boundary change.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #97994
Summary: This PR is the current candidate fix for the canonical no-finish OpenAI-compatible streamed tool-call issue; adjacent finish_reason and parser items do not replace it.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Merging intentionally changes shipped fail-closed behavior for OpenAI-compatible streams that omit finish_reason; affected providers may now execute parsed native tool calls when raw SSE [DONE] is observed.
  • [P1] The changed boundary converts model/provider output into executable tool calls, so maintainers should consciously accept the clean-terminal contract even though EOF without [DONE] remains fail-closed.
  • [P1] The exact Evolink route from the canonical issue was not live-tested in this PR; proof comes from loopback SSE promotion plus a live DeepSeek regression stream.

Maintainer options:

  1. Accept the clean-DONE contract (recommended)
    Approve after normal required checks if maintainers accept that native tool-call deltas plus raw SSE [DONE] are enough to execute tools without a final finish_reason.
  2. Ask for exact-provider proof
    Request a redacted Evolink or equivalent provider run before merge if loopback transport proof is not enough for this boundary change.
  3. Pause on stricter semantics
    Pause or close this PR if OpenClaw should keep requiring explicit provider finish reasons for streamed tool execution.

Next step before merge

  • [P2] Human maintainer review is needed to accept or reject the widened clean-[DONE] tool-execution contract; there is no narrow automated repair to queue.

Maintainer decision needed

  • Question: Should OpenClaw treat native streamed delta.tool_calls plus raw SSE data: [DONE] as a clean terminal signal that may execute tools when finish_reason is omitted?
  • Rationale: The implementation is narrow and well tested, but automation should not choose a model-output-to-tool-execution trust boundary for maintainers.
  • Likely owner: Vincent Koc — Recent area history makes this the best available routing candidate for accepting or rejecting the OpenAI transport execution-boundary change.
  • Options:
    • Accept clean-DONE execution (recommended): Approve the PR if native tool-call deltas plus raw SSE [DONE] are an acceptable compatibility contract for OpenAI-compatible providers that omit finish_reason.
    • Require exact-provider proof: Ask for one redacted Evolink or equivalent no-finish tool-call run before merge if maintainers want proof from the originally reported route.
    • Keep finish_reason required: Pause or close the PR if OpenClaw should continue requiring an explicit provider finish reason before executing streamed tool calls.

Security
Cleared: No concrete supply-chain, secret-handling, or new permission defect was found; the tool-execution boundary change is tracked as merge risk for maintainer acceptance.

Review details

Best possible solution:

Land the transport-level clean-terminal gate if maintainers accept [DONE] plus native delta.tool_calls as sufficient tool-use intent, while keeping EOF-only, visible-text, and DSML-recovery safeguards intact.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main still strips parsed streamed tool calls when no final finish reason is present, and the canonical issue provides provider logs showing valid delta.tool_calls followed by [DONE] with no tool execution. I did not rerun the live Evolink route in this read-only review.

Is this the best way to solve the issue?

Yes for the code shape: observing raw SSE [DONE] before the OpenAI SDK consumes it is narrower than promoting plain EOF, and the patch keeps visible-text and EOF-without-DONE safeguards. The remaining question is maintainer acceptance of the widened clean-terminal execution contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4e29b2f5ab4b.

Label changes

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a focused provider/runtime compatibility fix for affected tool-using OpenAI-compatible streams, with limited blast radius and no crash or data-loss evidence.
  • merge-risk: 🚨 compatibility: Existing users on providers with no final finish_reason may see a previously fail-closed stream now proceed into tool execution after [DONE].
  • merge-risk: 🚨 security-boundary: The PR changes the condition under which model/provider output is trusted enough to execute OpenClaw tools.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Sufficient: the PR body includes after-fix loopback HTTP SSE transcripts for [DONE] promotion and EOF fail-closed behavior plus a live DeepSeek regression stream; the exact Evolink route was not verified.
  • proof: sufficient: Contributor real behavior proof is sufficient. Sufficient: the PR body includes after-fix loopback HTTP SSE transcripts for [DONE] promotion and EOF fail-closed behavior plus a live DeepSeek regression stream; the exact Evolink route was not verified.
Evidence reviewed

PR surface:

Source +67, Tests +342. Total +409 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 72 5 +67
Tests 1 344 2 +342
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 416 7 +409

What I checked:

  • Current main drops the reported stream shape: Current main only promotes silent streamed tool calls after sawStopFinishReason, then strips tool-call blocks when the final stop reason is not toolUse; this matches the linked no-finish provider failure. (src/agents/openai-transport-stream.ts:3266, 4e29b2f5ab4b)
  • Current main has a regression test for the old fail-closed behavior: The existing test named does not promote tool calls when provider omits final finish_reason feeds a parsed delta.tool_calls chunk with finish_reason: null and expects no retained tool-call blocks. (src/agents/openai-transport-stream.test.ts:10169, 4e29b2f5ab4b)
  • PR implementation gates promotion on native tool-call deltas plus raw SSE DONE: The diff adds a fetch wrapper that detects exact data: [DONE], passes sawStreamDONE into processOpenAICompletionsStream, tracks sawNativeToolCallDelta, and promotes only when sawStopFinishReason or native tool calls plus clean DONE are present. (src/agents/openai-transport-stream.ts:2753, a67699c1865b)
  • PR tests cover clean DONE and EOF-without-DONE paths: The PR changes the no-finish unit expectation, adds an EOF-without-DONE fail-closed case, and adds loopback HTTP SSE tests for both [DONE] promotion and EOF-only stripping through the OpenAI SDK fetch path. (src/agents/openai-transport-stream.test.ts:10184, a67699c1865b)
  • Tool execution depends on toolUse: The agent loop dispatches tool calls only when the assistant message stop reason is toolUse, so preserving the tool-call block without promoting the stop reason would still not execute tools. (packages/agent-core/src/agent-loop.ts:354, 4e29b2f5ab4b)
  • OpenAI SDK consumes [DONE] before yielding chunks: The inspected [email protected] package skips SSE events whose data starts with [DONE], supporting the PR's need to observe the raw response body before SDK iteration hides that terminal signal. ([email protected] package/core/streaming.js:35)

Likely related people:

  • MonkeyLeeT: Authored the merged stop-finished OpenAI tool-call fix that introduced the adjacent missing-finish fail-closed behavior this PR narrows. (role: recent fix author; confidence: high; commits: 9dcc70332ede, 12e6715e567f, 6316648babc7; files: src/agents/openai-transport-stream.ts, src/agents/openai-transport-stream.test.ts)
  • Jerry-Xin: Authored the merged guard that strips tool-call blocks when providers signal a non-tool stop, which is the safety boundary this PR preserves while widening no-finish handling. (role: introduced adjacent guard; confidence: high; commits: 6c11d06dd71e, fdd568522b7e, f59fc0d477ff; files: src/agents/openai-transport-stream.ts, src/agents/openai-transport-stream.test.ts, packages/ai/src/providers/openai-completions.ts)
  • Vincent Koc: Recent history and author counts show substantial current-main work in the OpenAI transport stream files, including nearby reasoning and stream-parser maintenance. (role: recent area contributor; confidence: medium; commits: 68502c90d1fb, 4e29b2f5ab4b; files: src/agents/openai-transport-stream.ts, src/agents/openai-transport-stream.test.ts)
  • Balaji Siva: Worked on vLLM reasoning-model response parsing in the same OpenAI-compatible transport area, making them a useful routing candidate for provider-specific stream behavior. (role: adjacent vLLM contributor; confidence: medium; commits: efab9763dc87; files: src/agents/openai-transport-stream.ts, src/agents/openai-transport-stream.test.ts)
  • steipete: Merged the related PRs that established the current stop-reason and missing-finish safety behavior around this parser surface. (role: merger of adjacent guard changes; confidence: medium; commits: 6316648babc7, f59fc0d477ff; files: src/agents/openai-transport-stream.ts, src/agents/openai-transport-stream.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-02T16:18:58.347Z sha 79e2379ccf7a0956481377a1ba092b13cbe485e4 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 30, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/openai-stream-no-finish-tool-97994 branch 2 times, most recently from 498abf5 to 3a63ad2 Compare June 30, 2026 11:46
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@SunnyShu0925
SunnyShu0925 force-pushed the fix/openai-stream-no-finish-tool-97994 branch from 3a63ad2 to 0abfda5 Compare June 30, 2026 12:18
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 30, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 30, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 2, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/openai-stream-no-finish-tool-97994 branch from d859b92 to 79e2379 Compare July 2, 2026 11:00
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 2, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jul 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 7, 2026
SunnyShu0925 and others added 3 commits July 9, 2026 20:37
…ut finish_reason

OpenAI-compatible providers that emit delta.tool_calls during streaming but
terminate with data: [DONE] without a final finish_reason chunk (e.g. Evolink
DeepSeek V4) have their tool calls silently stripped.

Introduce sawNativeToolCallDelta (structured provider intent) and
sawStreamDONE (exact SSE data: [DONE] detection via TransformStream).
Pass sawStreamDONE as a getter so the live value is read after stream
consumption. Promotion requires (sawStopFinishReason || (sawNativeToolCallDelta
&& sawStreamDONE?.())). SSE parsing uses line-boundary-aware regex; [DONE]
inside tool arguments or content does not match.

EOF without [DONE] remains fail-closed. DSML still requires sawStopFinishReason.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Fixes openclaw#97994
…ion proof

Prove sawStreamDONE works through the full transport chain:
- Local HTTP server → TransformStream → OpenAI SDK → processOpenAICompletionsStream
- [DONE] without finish_reason → promoted to toolUse
- EOF without [DONE] → fail-closed (tool calls stripped)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@steipete
steipete force-pushed the fix/openai-stream-no-finish-tool-97994 branch from a67699c to 13fd832 Compare July 10, 2026 03:38
@steipete
steipete merged commit ec83152 into openclaw:main Jul 10, 2026
97 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
…finish_reason (openclaw#98124)

* [AI] fix(openai): preserve native tool calls from clean streams without finish_reason

OpenAI-compatible providers that emit delta.tool_calls during streaming but
terminate with data: [DONE] without a final finish_reason chunk (e.g. Evolink
DeepSeek V4) have their tool calls silently stripped.

Introduce sawNativeToolCallDelta (structured provider intent) and
sawStreamDONE (exact SSE data: [DONE] detection via TransformStream).
Pass sawStreamDONE as a getter so the live value is read after stream
consumption. Promotion requires (sawStopFinishReason || (sawNativeToolCallDelta
&& sawStreamDONE?.())). SSE parsing uses line-boundary-aware regex; [DONE]
inside tool arguments or content does not match.

EOF without [DONE] remains fail-closed. DSML still requires sawStopFinishReason.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Fixes openclaw#97994

* [AI] test(openai): add fetch-wrapper loopback tests for [DONE] detection proof

Prove sawStreamDONE works through the full transport chain:
- Local HTTP server → TransformStream → OpenAI SDK → processOpenAICompletionsStream
- [DONE] without finish_reason → promoted to toolUse
- EOF without [DONE] → fail-closed (tool calls stripped)

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix: harden clean SSE terminal detection

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenAI-compatible streaming tool calls are dropped when provider omits finish_reason

2 participants