Skip to content

[Bug] Missing tool name in answer #4700

@rstanislav

Description

@rstanislav

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
  • 5. Please use English, otherwise it will be closed.

Describe the bug

Hello, i have found a strange BUG, i'm trying to use sglang with n8n and noticed that function calls not working, i have written a simple proxy app and noticed that in sglang answer with function call at final chunk function name in missing, and that is strange because in first chunks its present, and final answer becomes invalid as result, here is example:
Request:

2025-03-23 18:15:35,962 - DEBUG - Remote request body for 2ad4de47 to /v1/chat/completions:
{
"model": "casperhansen/llama-3.3-70b-instruct-awq",
"temperature": 1,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"n": 1,
"stream": true,
"tools": [
{
"type": "function",
"function": {
"name": "vector_store",
"description": "Tool retrives user names that are already in database",
"parameters": {
"type": "object",
"properties": {
"input": {
"type": "string"
}
},
"required": [
"input"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
}
],
"stream_options": {
"include_usage": true
},
"messages": [
{
"role": "system",
"content": "You are a helpful assistant, extract user name from chat message, tell if its found if its already preset in vector store\ntools & when to use them:\n\n1 - Vector store\ncontains db of user name already in system\n\nExample workflow:\nWhen chat message arrives\nMessage: hi, my name is boss\nActions taken:\n1) username 'boss' extracted and checked in vector store\n2) if user with extracted username ('boss') is not found, answer user that its not found\n3) if username found: answer user that user with name "boss" is found."
},
{
"role": "user",
"content": "hi my name is stanislav"
}
]
}

Response:

INFO: 192.168.100.29:57726 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-03-23 18:15:36,126 - DEBUG - Stream chunk for request 2ad4de47:
14c
data: {"id":"7874fe5978be41a1ad2daf0e67658490","object":"chat.completion.chunk","created":17427
2025-03-23 18:15:36,127 - DEBUG - Stream chunk for request 2ad4de47:
42934,"model":"casperhansen/llama-3.3-70b-instruct-awq","choices":[{"index":0,"delta":{"role":"assis
2025-03-23 18:15:36,127 - DEBUG - Stream chunk for request 2ad4de47:
tant","content":"","reasoning_content":null,"tool_calls":null},"logprobs":null,"finish_reason":null,
2025-03-23 18:15:36,226 - DEBUG - Stream chunk for request 2ad4de47:
"matched_stop":null}],"usage":null}

1a1
data: {"id":"7874fe5978be41a1ad2daf0e67658490","object":
2025-03-23 18:15:36,227 - DEBUG - Stream chunk for request 2ad4de47:
"chat.completion.chunk","created":1742742934,"model":"casperhansen/llama-3.3-70b-instruct-awq","choi
2025-03-23 18:15:36,227 - DEBUG - Stream chunk for request 2ad4de47:
ces":[{"index":0,"delta":{"role":"assistant","content":null,"reasoning_content":null,"tool_calls":[{
2025-03-23 18:15:36,227 - DEBUG - Stream chunk for request 2ad4de47:
"id":"0","type":"function","function":{"name":"vector_store","arguments":""}}]},"logprobs":null,"fin
2025-03-23 18:15:36,383 - DEBUG - Stream chunk for request 2ad4de47:
ish_reason":"tool_call","matched_stop":null}],"usage":null}

1a3
data: {"id":"7874fe5978be41a1ad2
2025-03-23 18:15:36,383 - DEBUG - Stream chunk for request 2ad4de47:
daf0e67658490","object":"chat.completion.chunk","created":1742742934,"model":"casperhansen/llama-3.3
2025-03-23 18:15:36,384 - DEBUG - Stream chunk for request 2ad4de47:
-70b-instruct-awq","choices":[{"index":0,"delta":{"role":"assistant","content":null,"reasoning_conte
2025-03-23 18:15:36,384 - DEBUG - Stream chunk for request 2ad4de47:
nt":null,"tool_calls":[{"id":"0","type":"function","function":{"name":"","arguments":"{"input": "
2025-03-23 18:15:36,403 - DEBUG - Stream chunk for request 2ad4de47:
"}}]},"logprobs":null,"finish_reason":"tool_call","matched_stop":null}],"usage":null}

199
data:
2025-03-23 18:15:36,403 - DEBUG - Stream chunk for request 2ad4de47:
{"id":"7874fe5978be41a1ad2daf0e67658490","object":"chat.completion.chunk","created":1742742935,"mode
2025-03-23 18:15:36,404 - DEBUG - Stream chunk for request 2ad4de47:
l":"casperhansen/llama-3.3-70b-instruct-awq","choices":[{"index":0,"delta":{"role":"assistant","cont
2025-03-23 18:15:36,404 - DEBUG - Stream chunk for request 2ad4de47:
ent":null,"reasoning_content":null,"tool_calls":[{"id":"0","type":"function","function":{"name":"","
2025-03-23 18:15:36,405 - DEBUG - Stream chunk for request 2ad4de47:
arguments":"stan"}}]},"logprobs":null,"finish_reason":"tool_call","matched_stop":null}],"usage":null
2025-03-23 18:15:36,423 - DEBUG - Stream chunk for request 2ad4de47:
}

19d
data: {"id":"7874fe5978be41a1ad2daf0e67658490","object":"chat.completion.chunk","created":
2025-03-23 18:15:36,424 - DEBUG - Stream chunk for request 2ad4de47:
1742742935,"model":"casperhansen/llama-3.3-70b-instruct-awq","choices":[{"index":0,"delta":{"role":"
2025-03-23 18:15:36,424 - DEBUG - Stream chunk for request 2ad4de47:
assistant","content":null,"reasoning_content":null,"tool_calls":[{"id":"0","type":"function","functi
2025-03-23 18:15:36,425 - DEBUG - Stream chunk for request 2ad4de47:
on":{"name":"","arguments":"islav"}"}}]},"logprobs":null,"finish_reason":"tool_call","matched_stop"
2025-03-23 18:15:36,461 - DEBUG - Stream chunk for request 2ad4de47:
:null}],"usage":null}

ee
data: {"id":"7874fe5978be41a1ad2daf0e67658490","object":"chat.completio
2025-03-23 18:15:36,462 - DEBUG - Stream chunk for request 2ad4de47:
n.chunk","created":1742742935,"model":"casperhansen/llama-3.3-70b-instruct-awq","choices":[],"usage"
2025-03-23 18:15:36,463 - DEBUG - Final stream chunk for request 2ad4de47:
:{"prompt_tokens":311,"total_tokens":329,"completion_tokens":18}}

e
data: [DONE]

As you can see in 1a1 chunk there is tool name, and starting from next chunk - 1a3 its missing

Reproduction

--

Environment

Latest version.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions