[CI][MCP][Harmony] Heavy refactoring Harmony & MCP response tests and stabilizing with deterministic test infrastructure (#33949)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
@@ -392,13 +392,27 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
max_model_len = self.model_config.max_model_len
|
||||
generators: list[AsyncGenerator[ConversationContext, None]] = []
|
||||
|
||||
# Only include builtin tools that the request actually asked for.
|
||||
# Without this filter, tools registered on the server (e.g. via
|
||||
# --tool-server demo) would be available for execution even when
|
||||
# the request didn't enable them.
|
||||
requested_tool_types = extract_tool_types(request.tools)
|
||||
builtin_tool_list: list[str] = []
|
||||
if self.tool_server is not None:
|
||||
if self.tool_server.has_tool("browser"):
|
||||
if (
|
||||
self.tool_server.has_tool("browser")
|
||||
and "web_search_preview" in requested_tool_types
|
||||
):
|
||||
builtin_tool_list.append("browser")
|
||||
if self.tool_server.has_tool("python"):
|
||||
if (
|
||||
self.tool_server.has_tool("python")
|
||||
and "code_interpreter" in requested_tool_types
|
||||
):
|
||||
builtin_tool_list.append("python")
|
||||
if self.tool_server.has_tool("container"):
|
||||
if (
|
||||
self.tool_server.has_tool("container")
|
||||
and "container" in requested_tool_types
|
||||
):
|
||||
builtin_tool_list.append("container")
|
||||
|
||||
if self.tool_server is not None:
|
||||
@@ -1049,9 +1063,15 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
# FIXME(woosuk): Currently, request params like reasoning and
|
||||
# instructions are ignored.
|
||||
prev_msgs = self.msg_store[prev_response.id]
|
||||
# Remove the previous chain-of-thoughts if there is a new "final"
|
||||
# message. Note that this also removes these messages from the
|
||||
# msg_store.
|
||||
|
||||
# FIXME(woosuk): The slice-delete-reappend cycle below is
|
||||
# currently a no-op --- it removes messages then puts them all
|
||||
# back unfiltered. It may be intentionally deferred (see FIXME
|
||||
# above) or redundant if the Harmony encoder already strips
|
||||
# analysis messages at render time. If analysis messages need
|
||||
# to be dropped here, add a channel != "analysis" filter when
|
||||
# re-appending, similar to auto_drop_analysis_messages in
|
||||
# harmony_utils.py.
|
||||
if len(prev_msgs) > 0:
|
||||
last_msg = prev_msgs[-1]
|
||||
assert isinstance(last_msg, OpenAIHarmonyMessage)
|
||||
@@ -1072,7 +1092,11 @@ class OpenAIServingResponses(OpenAIServing):
|
||||
# Append the new input.
|
||||
# Responses API supports simple text inputs without chat format.
|
||||
if isinstance(request.input, str):
|
||||
messages.append(get_user_message(request.input))
|
||||
# Skip empty string input when previous_input_messages supplies
|
||||
# the full conversation history --- an empty trailing user message
|
||||
# confuses the model into thinking nothing was sent.
|
||||
if request.input or not request.previous_input_messages:
|
||||
messages.append(get_user_message(request.input))
|
||||
else:
|
||||
if prev_response is not None:
|
||||
prev_outputs = copy(prev_response.output)
|
||||
|
||||
Reference in New Issue
Block a user