Skip to content

vllm.entrypoints.openai.responses.utils

Functions:

_construct_message_from_response_item(item, prev_msg=None)

Returns a new message or None. If None, prev_msg might be updated. If prev_msg is None, a new message is always returned.

build_response_output_items(reasoning, content, tool_calls, logprobs=None, tools=None, finish_reason=None)

Build the output items of one generation.

Only the last item can have been cut short, so finish_reason decides that item's status and every earlier item is completed.

construct_chat_messages_with_tool_call(input_messages)

Build chat messages from response items.

Some chat messages span multiple response items (e.g., reasoning + tool calls).

convert_tool_responses_to_completions_format(tool)

Convert a flat Responses tool schema

{"type": "function", "name": "...", "description": "...", "parameters": {...}}

into a Chat Completions tool param for chat-template rendering.

decode_custom_tool_input(arguments)

Payload of a completed shim call; bare text is passed through.

decode_custom_tool_input_prefix(arguments)

Longest decodable payload prefix of partial shim arguments, so that streamed custom_tool_call_input deltas stay a prefix of the final input.

extend_custom_tool_input_prefix(arguments, payload, end)

decode_custom_tool_input_prefix of arguments, decoding only arguments[end:]. payload and end come from the previous call on a prefix of arguments ("" and 0 at first). Returns None when the arguments do not start as encode_custom_tool_input writes them, or once the payload string closes; only a full decode is exact then.

extract_tool_types(tools)

Extracts the tool types from the given tools.

response_item_status(finish_reason)

Status of the output item that ended a generation with finish_reason.

reuse_streamed_item_ids(items, streamed_items)

Give rebuilt output items the ids already streamed for the same message.

Items are paired by type in order; an item without a streamed counterpart keeps its own id.

should_continue_final_message(request_input)

Determine if the last input message is a partial assistant message that should be continued rather than starting a new generation.

This enables partial message completion similar to Anthropic's Messages API, where users can provide an incomplete assistant message and have the model continue from where it left off.

A message is considered partial if: 1. It's a ResponseOutputMessage or ResponseReasoningItem 2. Its status is "in_progress" or "incomplete"

Parameters:

  • request_input

    (str | list[ResponseInputOutputItem]) –

    The input to the Responses API request

Returns:

  • bool –

    True if the final message should be continued, False otherwise