mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3039] [Issue]: ChatGPT subscription streaming silently returns truncated/filtered output as a clean completion #1610
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1610
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3039
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The ChatGPT-subscription provider always routes through the Responses API and always streams, so the interactive streaming generator is the main code path for those chats. In that generator, the
response.incompleteSSE event — emitted when generation stops atmax_output_tokensor a content filter — is handled by a barelogger.warnandbreak, with no signal to the caller. The partial text already yielded is presented as a normal, complete reply with no truncation or content-filter indicator. A ChatGPT Pro user who hits a length cap or a content filter gets a silently cut-off answer indistinguishable from a finished one, and auto-continue logic that keys offfinishReasoncannot detect it. The non-streaming Responses helpers already mapstatus === 'incomplete'tofinishReason: 'length'; the streaming path does not.How to reproduce (try it yourself)
openai_chatgptconnection (Codex/ChatGPT login).max_output_tokens(or trip a content filter), so the Responses stream ends withresponse.incomplete.You'll see: the generator yields the partial text and returns normally; only a server-side warn is logged. The client receives the truncated text with no truncation indicator, and the message is persisted with
generationInfo.finishReason = null(generate.routes.ts:7007).Expected: the truncation surfaces as
finishReason: "length", recorded and detectable like the non-streaming Responses path.Where it is
packages/server/src/services/llm/providers/openai.provider.ts: the streamingchatResponses()response.incompletehandler (lines 1870-1875, only logs +break); generator signature with no finish-reason channel (line 1683); forced stream for ChatGPT-subscription (lines 1599-1606). Contrast: non-streamingparseResponsesResult/chatCompleteResponsesmap incomplete→length (lines 2263, 2114, 2138). Consumer:generate.routes.ts:6543-6595(streaming send captures only usage) and:7007(persisted).What's happening
The streaming generator has no out-of-band channel for
finishReason, and theresponse.incompletecase only logs. Because the ChatGPT-subscription provider forces streaming for every request, the truncation/content-filter signal is dropped on the primary interactive path for that provider. (Note:chatComplete()callers delegate to the non-streaming helper, which handles incomplete correctly — so this is specific to the streamingchat()/chatResponses()generator, which is the main interactive send.)Suggested fix
Surface the signal through the existing
LLMUsage.finishReasonchannel and teach the route to read it. Two edits:openai.provider.ts, replace theresponse.incompletehandler (1870-1875) so it extracts usage, emits encrypted reasoning, runs the no-text fallback (mirroringresponse.completedat 1845-1861), and marks the finish reason:generate.routes.ts:6595, propagate the reason out of the returned usage in the streaming branch: afterusage = result.value;, addif (result.value.finishReason) finishReason = result.value.finishReason;.Regressions avoided: do NOT append a sentinel to the yielded token stream — that stream is the assistant message body (accumulated into
fullResponse, persisted/displayed), so a sentinel would corrupt visible content. Do NOT emit a distinctcontent_filterfinish reason — the codebase's truncation detectors only recognize"length"(game.routes.ts:1639,workspace-agent.service.ts:581), and the non-streaming Responses siblings already collapse both incomplete reasons to"length"; the filter reason is still logged via the existing warn. The route edit is required because, without it, the streaming branch never assigns the outerfinishReasonfromusage.finishReason(contrast the tool branches at 6400/6538), so the signal would still never reachgenerationInfo.finishReason. The happyresponse.completedpath is unchanged (still returns usage with no finish reason → persisted null, as today).Related: one of a family of provider-level "finish/stop reason dropped → truncation reported as a clean stop" issues filed together (Gemini non-streaming, Anthropic non-streaming, OpenAI streaming, ChatGPT-subscription streaming). Same root-cause class, separate per-provider fix.
AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Claiming this for the current staging sweep in draft PR #3053 (branch
codex/issue-sweep-3033-3052).@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in PR #3053 on branch
codex/issue-sweep-3033-3052(commitbfb1bc76). Closing this issue as addressed; the PR remains open for staging review/merge.