Skip to content

Commit 39d6e8e

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 <eluban4532@gmail.com>
1 parent 4e5affe commit 39d6e8e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vllm/entrypoints/harmony_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ def parse_chat_input(chat_msg) -> list[Message]:
213213
tool_calls = chat_msg.get("tool_calls")
214214
if role == "assistant" and tool_calls:
215215
msgs: list[Message] = []
216+
content = chat_msg.get("content") or ""
217+
analysis_msg = Message.from_role_and_content(Role.ASSISTANT, content)
218+
analysis_msg = analysis_msg.with_channel("analysis")
219+
msgs.append(analysis_msg)
220+
216221
for call in tool_calls:
217222
func = call.get("function", {})
218223
name = func.get("name", "")
@@ -230,7 +235,7 @@ def parse_chat_input(chat_msg) -> list[Message]:
230235
content = chat_msg.get("content", "") or ""
231236
msg = Message.from_author_and_content(
232237
Author.new(Role.TOOL, f"functions.{name}"),
233-
content).with_channel("commentary")
238+
content).with_channel("commentary").with_recipient("assistant")
234239
return [msg]
235240

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

0 commit comments

Comments
 (0)