[BugFix][Frontend] Pass reasoning_ended through render → generate (#60059) (#60062)

Signed-off-by: Yida Weng <84164537+YidaWeng@users.noreply.github.com>
Signed-off-by: Flora Feng <4florafeng@gmail.com>
Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
Yida Weng
2026-10-05 20:39:25 +00:00
committed by GitHub
co-authored by Flora Feng
parent 74c5cbcd7b
commit 18c8a65edd
11 changed files with 249 additions and 22 deletions
@@ -4,6 +4,7 @@ from typing import Annotated, Any, Literal, TypeAlias
from pydantic import (
BaseModel,
ConfigDict,
Discriminator,
Field,
NonNegativeInt,
@@ -147,6 +148,16 @@ class MultiModalFeatures(BaseModel):
return self
class ReasoningParserKwargs(BaseModel):
"""Kwargs for the engine-side reasoning parser that gates structured
outputs. Typed so clients cannot pass arbitrary constructor kwargs."""
model_config = ConfigDict(extra="forbid")
chat_template_kwargs: dict[str, Any] = Field(default_factory=dict)
"""The effective chat template kwargs the prompt was rendered with."""
class GenerateRequest(BaseModel):
request_id: str = Field(
default_factory=lambda: f"{random_uuid()}",
@@ -212,6 +223,15 @@ class GenerateRequest(BaseModel):
model: str | None = None
reasoning_ended: bool | None = None
"""Whether reasoning has ended before the first generated token, as
resolved by /render. `True` applies structured outputs from the first
token; `None` lets the engine check the prompt with its reasoning parser."""
reasoning_parser_kwargs: ReasoningParserKwargs | None = None
"""Set by /render when it has a reasoning parser, so the engine-side
parser agrees with the frontend on flags such as `enable_thinking`."""
return_token_ids: bool | None = Field(
default=None,
description=(
@@ -349,6 +349,12 @@ class ServingTokens(GenerateBaseServing):
priority=request.priority,
data_parallel_rank=data_parallel_rank,
session_id=session_id,
reasoning_ended=request.reasoning_ended,
reasoning_parser_kwargs=(
request.reasoning_parser_kwargs.model_dump()
if request.reasoning_parser_kwargs is not None
else None
),
)
assert result_generator is not None