fix(pixel-edge): accumulate content before finish reason in stream fallback guard - #5604
Open
vaibhavsrv wants to merge 1 commit into
Open
vaibhavsrv wants to merge 1 commit into
vaibhavsrv wants to merge 1 commit into
Conversation
This was referenced Sep 17, 2026
vaibhavsrv
force-pushed
the
fix/pixel-edge-stream-single-chunk
branch
from
September 17, 2026 04:08
2aa48c5 to
7606c52
Compare
vaibhavsrv
force-pushed
the
fix/pixel-edge-stream-single-chunk
branch
from
September 17, 2026 04:25
7606c52 to
736cb40
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
In the baseline Pixel Edge streaming proxy (
_stream_upstream), concise model completions or single-chunk model responses (common with smaller, faster models or inference engines emitting the final token andfinish_reason: "stop"concurrently in the same chunk) trigger the empty-reply fallback prematurely. Becausefinish_reasonwas evaluated before accumulatingcontentintopending_text,pending_textwas evaluated as empty"", causing the edge to injectempty_reply_fallback("I couldn't produce a useful response to that request...") before the actual model content. Furthermore, whenreplace_pendingwas called on unverified turns, the unparsedlinewas written unconditionally afterwards, leaking reserved phrases likeNO_REPLYinto the client stream.This change accumulates incoming SSE
contentintopending_textbefore evaluatingfinish_reason, and cleanly synthesizesfinish_reason: "stop"when replacing pending empty or reserved replies (synthesize_finish=True) without leaking the unverified or reserved payload. Existing SSE chunk framing limits, CRLF normalization, and reserved reply definitions remain completely untouched.Validation
{"choices": [{"delta": {"content": "Paris"}, "finish_reason": "stop"}]}failed with'FALLBACK_CALLED' unexpectedly foundin the stream output, erroneously prepending the fallback error message before"Paris". Single-chunkNO_REPLYresponses leaked'NO_REPLY'into the output after the fallback message."Paris"cleanly without triggering the fallback; reservedNO_REPLYpayloads are cleanly replaced with synthesized fallback frames without leakingNO_REPLY. The full test suite intest_pixel_edge.py(102 tests) and new regressiontest_pixel_edge_single_chunk.py(3 tests) pass cleanly.Overlap check
pixel-inference.dashboard-apiresource calculation.This PR touches only
pixel_edge.pySSE event accumulation and does not overlap with or invalidate any of the above changes.Risk / AI disclosure
AI-assisted investigation, implementation and CLI regressions. This strengthens an SSE stream delivery check, not runtime admission or model authorization. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.
Follow-up integration evidence
Composed with #5600 at 3f44dce without conflicts. Production and test diffs passed together; pixel edge and inference checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.