Repository navigation
fix(ai): report interrupted local-model streams instead of empty success - #129794
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 11:17 PM ET / August 26, 2026, 03:17 UTC. ClawSweeper reviewWhat this changesThe PR makes managed OpenAI-compatible streams fail when neither a provider finish reason nor an SSE Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessNo blocking patch defect found. Keep this maintainer-authored PR open for explicit compatibility approval: it intentionally changes managed OpenAI-compatible streams with bare EOF from apparent success to a visible error. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe OpenAI-compatible transport consumes provider HTTP/SSE responses and normalizes text and tool calls into agent events. Its stream owner now decides whether the response has enough terminal evidence to expose a successful assistant outcome. flowchart LR
Provider[OpenAI-compatible provider]
SSE[HTTP and SSE response]
Detector[Raw terminal marker detector]
Owner[Stream outcome owner]
Decision{Terminal evidence present?}
Result[Done event or error event]
Provider --> SSE --> Detector --> Owner --> Decision
Decision -->|Finish reason or DONE| Result
Decision -->|Bare EOF| Result
Decision needed
Why: This is an intentional observable compatibility change for configured local and custom endpoints; source review can validate the implementation, but maintainers must choose the supported endpoint contract. Before merge
Agent review detailsSecurityNone. PR surfaceSource -6, Tests +22. Total +16 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt one managed-stream terminal rule: only an explicit provider finish reason or observed SSE Do we have a high-confidence way to reproduce the issue? Yes. The checked-in localhost HTTP/SSE fixture terminates streams with and without Is this the best way to solve the issue? Yes, subject to the explicit compatibility decision. The terminal evidence is recorded at the managed transport boundary and enforced by its canonical stream owner rather than inferred downstream. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6b02b00e23fa. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Maintainer compatibility decision: a managed OpenAI-compatible stream ending with neither an explicit This restores the already-shipped boundary: This change is more permissive than the existing direct-provider contract: either a valid provider finish reason or an observed The flagged |
|
Merged via squash.
|
…ess (openclaw#129794) * fix(ai): report interrupted local-model streams instead of empty success * test(ai): await asynchronous managed stream fixtures
* origin/main: (24 commits) fix(gateway): reject rootless session permission modes (#128149) docs(memory): document shipped turn-taint propagation for network tool output (#129837) fix(ui): pool reply-less wake activity into one chat rollup (#128442) fix(package): prevent installs from deleting validated runtime assets (#129724) fix(nodes): approve silent initial node surfaces and name the pending surface approval (#129795) fix(backup): preserve configured agent state roots (#129773) fix(ui): own chat history issuance with a closed state machine (#129776) fix(cron): preserve cancellation reason after late finalization (#129331) fix(cron): prevent run waits from failing after clock changes (#129805) fix(telegram): route commentary through one frozen progress owner (#128259) fix(release): start approved VCR mirror recovery jobs (#129829) test: complete current-plugin-metadata-snapshot mock factories (#129791) test(telegram): remove duplicate reaction case (#129848) fix(channels): honor supported account reply-threading policies (#129679) refactor(cli): deduplicate lazy subcommand registration (#129351) fix(ai): report interrupted local-model streams instead of empty success (#129794) refactor(cli): consolidate Gateway fallback and hook ownership (#129802) fix(qa): reject token confidence lanes without executed evidence (#129830) fix(tui): fence session state and delayed actions (#129810) fix(control-ui): keep task progress full width on hover (#129832) ...
|
Follow-up merged: #140367 landed in main on September 6, 2026 (04081aa). This PR established the transport-side distinction between a genuinely interrupted completions stream and valid terminal completion. #140367 handles the resulting The changes are complementary. #140367 does not relax transport terminal validation or authorize replaying completed tools. |
What Problem This Solves
Fixes an issue where users running OpenAI-compatible local models through the managed Gateway could receive an empty successful answer, a silently truncated answer, or a dropped tool call when the provider disconnected before completing its response.
Why This Change Was Made
The OpenAI SDK treats both a real SSE
[DONE]marker and an ordinary connection EOF as the end of its iterator. The managed transport already observes the raw SSE terminal, but its stream owner only used that fact when deciding whether a tool call was executable. Consequently, interrupted empty, text, and tool responses were finalized as successfulstopoutcomes.Record the provider finish reason in the existing canonical stream owner and require either that explicit finish reason or the existing observed
[DONE]marker before completing a managed response. The correction removes six production lines overall. Direct package streams, internal parser callers without terminal observers, malformed-tool safeguards, cancellation, request policy, and existing provider-specific behavior retain their contracts.User Impact
Interrupted local-model responses now fail visibly instead of pretending that an empty, partial, or abandoned tool response succeeded. Compatible providers that omit
[DONE]after an explicit finish reason still work, and providers that emit[DONE]without a finish reason still work.Evidence
The existing real-localhost streaming regression originally accepted a dropped tool stream as a successful empty answer. Replacing it with a table covering real HTTP/SSE streams produced three failing regressions before the fix:
After the owner repair, all five cases pass. A separate real-localhost replay confirmed that each interrupted response ends with
Stream ended without finish_reasonand exposes no executable tool call, while both valid terminal formats remain successful.Focused validation passed 413 tests across 21 suites, covering standalone and managed stream parity, encrypted and Google thought signatures, reasoning and usage contracts, DeepSeek recovery, legacy and modern tool calls, malformed arguments, provider response hooks, cancellation, request timeouts, and local HTTP streaming. Scoped formatting and lint checks passed; the final independent structured review reported no actionable findings.
Production: +7/-13 (net -6). Regression tests: +52/-30.