[Frontend] Parse tool calls and reasoning from checkpoint response templates (#58604)

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Bugen Zhao <i@bugenzhao.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yoni Gozlan <yonigozlan@users.noreply.github.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
This commit is contained in:
Yoni Gozlan
2026-10-02 02:33:00 +00:00
committed by GitHub
co-authored by Cursor Bugen Zhao Claude Opus 5.5
parent 5a661487e2
commit 9bd993564f
18 changed files with 2298 additions and 21 deletions
+16 -1
View File
@@ -141,6 +141,7 @@ class OpenAIServingResponses(GenerateBaseServing):
tool_strict_level=tool_strict_level,
model_name=self.model_config.model,
is_harmony=self.model_config.hf_config.model_type == "gpt_oss",
tokenizer=self.renderer.tokenizer,
)
self.enable_prompt_tokens_details = enable_prompt_tokens_details
self.enable_force_include_usage = enable_force_include_usage
@@ -446,6 +447,12 @@ class OpenAIServingResponses(GenerateBaseServing):
response_parser = self._make_response_parser(
request, tokenizer, chat_template_kwargs
)
if response_parser is not None:
prompt_token_ids = self._extract_prompt_components(
engine_input
).token_ids
if prompt_token_ids is not None:
response_parser.set_prompt_token_ids(prompt_token_ids)
context: ConversationContext
function_tool_names = extract_function_tool_names(request.tools)
@@ -703,6 +710,12 @@ class OpenAIServingResponses(GenerateBaseServing):
context.request,
context.response_messages,
)
if context.response_parser is not None:
prompt_token_ids = self._extract_prompt_components(
engine_input
).token_ids
if prompt_token_ids is not None:
context.response_parser.set_prompt_token_ids(prompt_token_ids)
sampling_params.max_tokens = get_max_tokens(
max_model_len,
@@ -1187,7 +1200,9 @@ class OpenAIServingResponses(GenerateBaseServing):
) -> AsyncGenerator[StreamingResponsesResponse, None]:
processor = SimpleStreamingEventProcessor(tools=request.tools)
hide_stream_metadata = not request.include_reasoning and self.parser is not None
hide_stream_metadata = (
not request.include_reasoning and context.response_parser is not None
)
def _get_logprobs(output: CompletionOutput) -> list[Logprob]:
if not request.is_include_output_logprobs():