Conversation
a6ebbf6 to
3f675d8
Compare
|
Pushed a fix into the PR branch directly (I was on the assignee list and the branch had What changed ( Only one line in # Before:
final_delta = reasoning_parser.finalize_stream()
# After:
finalize = getattr(reasoning_parser, "finalize_stream", None)
final_delta = finalize() if callable(finalize) else NoneWhy guard instead of patching the fixtures: Validation (Python 3.14, macOS ARM64, fresh clone of All four previously-failing tests now pass, and your new Authorship preserved as yours on the commit; I added CI should re-run automatically on the force-push. If you'd prefer a stacked commit or a separate PR structure, no problem — say the word and I'll revert my amend and open it as a follow-up instead. |
3f675d8 to
093365e
Compare
|
Rebased onto current The problemThis PR was written against Git merges both cleanly — no conflict — but the result was split-brained: reasoning_parser = _build_reasoning_parser(engine) # from #644, per-request
delta_msg = reasoning_parser.extract_reasoning_streaming(…) # local — buffers here
resolved_delta = _resolve_reasoning_stream_delta(
_reasoning_parser, output, delta_msg, request # global — finalizes here
)Extraction buffers into the request-local parser; finalization calls The Verified, not inferredTest-merged this PR onto The CI stayed green because it last ran 2026-07-29 22:08, about thirteen hours before #644 merged. The combination was never tested. FixOne line in resolved_delta = _resolve_reasoning_stream_delta(
- _reasoning_parser, output, delta_msg, request
+ reasoning_parser, output, delta_msg, request
)After it, on the rebased branch:
Authorship preserved as yours; Worth checking on neighbours#652 and #654 also touch streaming parser state and were both authored against pre-#644 More generally: any PR whose CI predates 09:56 today and touches Credit where due — this was surfaced by a scheduled agent run doing the audit, not by me reading the diff. I had pushed to this branch yesterday and did not catch it. |
Co-Authored-By: janhilgard <jan.hilgard@gmail.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-Authored-By: janhilgard <jan.hilgard@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
093365e to
93c85d3
Compare
|
@janhilgard The corrective rebase at 93c85d3 addresses the post-#644 request-local parser mismatch, but #653 was closed afterward and upstream main does not yet contain the terminal-finalizer wiring. Was the closure intentional because a replacement is planned? If not, please reopen this branch so CI can validate the corrected current-main diff. |
Summary
Flush parser-buffered terminal text before emitting a streamed completion's
terminal chunk.
Gemma 4's reasoning parser already implements
finalize_stream()for atruncated channel marker, but
stream_chat_completion()did not invoke it.The finalizer is now called only for the terminal output and its content or
reasoning is merged into that terminal delta.
Reproduction
With Gemma 4 reasoning enabled, a stream that ends at
finish_reason=lengthafter the parser has buffered a partial channel marker could omit that buffered
tail from the client stream.
The regression simulates a Gemma thought-to-response transition that ends at a
length boundary. It verifies the thought text, the buffered final content, and
the terminal
lengthreason all reach the emitted stream.Scope
it preserves parser-buffered terminal content when it exists.
Validation
pytest -q tests/test_server.py -k 'gemma_stream_flushes_pending_content_before_length_finish or stream_without_parser_flags_keeps_plain_text'ruff check vllm_mlx/server.py tests/test_server.py --select E,F,W --ignore E402,E501,E731,F811,F841/opt/ai-runtime/run/gemma4-stream-finalizer-certification/20260728T183900Z-live-manifest-replay/summary.json.