Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions python/sglang/srt/entrypoints/openai/serving_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,15 @@ async def _process_tool_call_stream(

# Yield tool calls
for call_item in calls:
# Fix tool call ID handling for streaming
tool_call_id = f"call_{uuid.uuid4().hex[:24]}"
# Tool call ID should be generated only once per tool call
Comment thread
JustinTong0323 marked this conversation as resolved.
if call_item.name:
# First chunk: include ID and function name
tool_call_id = f"call_{uuid.uuid4().hex[:24]}"
function_name = call_item.name
else:
# Subsequent chunks: null ID and name for argument deltas
tool_call_id = None
function_name = None

if finish_reason_type == "stop":
# Handle remaining arguments
Expand All @@ -844,7 +851,7 @@ async def _process_tool_call_stream(
id=tool_call_id,
index=call_item.tool_index,
function=FunctionResponse(
name=call_item.name,
name=function_name,
arguments=call_item.parameters,
),
)
Expand Down
Loading