Skip to content

Commit f13f45b

Browse files
committed
[Bug] Fix gpt-oss missing tool content
The changes include adding 'with_recipient' and the Assistant's 'analysis' content. Without adding this content, there was an issue where the gpt-oss model had a higher probability of outputting abnormal tokens when calling tools. Signed-off-by: kyt <[email protected]>
1 parent 784c231 commit f13f45b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

vllm/entrypoints/harmony_utils.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ def parse_chat_input(chat_msg) -> list[Message]:
241241
tool_calls = chat_msg.get("tool_calls")
242242
if role == "assistant" and tool_calls:
243243
msgs: list[Message] = []
244+
content = chat_msg.get("content") or ""
245+
analysis_msg = Message.from_role_and_content(Role.ASSISTANT, content)
246+
analysis_msg = analysis_msg.with_channel("analysis")
247+
msgs.append(analysis_msg)
248+
244249
for call in tool_calls:
245250
func = call.get("function", {})
246251
name = func.get("name", "")
@@ -265,9 +270,13 @@ def parse_chat_input(chat_msg) -> list[Message]:
265270
if isinstance(item, dict) and item.get("type") == "text"
266271
)
267272

268-
msg = Message.from_author_and_content(
269-
Author.new(Role.TOOL, f"functions.{name}"), content
270-
).with_channel("commentary")
273+
msg = (
274+
Message.from_author_and_content(
275+
Author.new(Role.TOOL, f"functions.{name}"), content
276+
)
277+
.with_channel("commentary")
278+
.with_recipient("assistant")
279+
)
271280
return [msg]
272281

273282
# Default: user/assistant/system messages with content

0 commit comments

Comments
 (0)