Repeated tool declaration
#6
by
longlian
- opened
In https://huggingface.co/spaces/huggingfacejs/chat-template-playground (with the tool calling example with Qwen/Qwen3-235B-A22B), the rendered output seems to have two repeated tool declarations:
<|im_start|>system
You are a helpful assistant that can use tools to get information for the user.
# Tools
You may call one or more functions to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{"name": "get_weather", "description": "Get current weather information for a location", "parameters": {"type": "object", "properties": {"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"], "description": "The unit of temperature to use"}}, "required": ["location"]}}
</tools>
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags.
# Tools
You may call one or more functions to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{"name": "get_weather", "description": "Get current weather information for a location", "parameters": {"type": "object", "properties": {"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"], "description": "The unit of temperature to use"}}, "required": ["location"]}}
</tools>
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call><|im_end|>
<|im_start|>user
What's the weather like in New York?<|im_end|>
<|im_start|>assistant
I'll check the current weather in New York for you.
<tool_call>
{"name": "get_weather", "arguments": {"location": "New York", "unit": "celsius"}}
</tool_call><|im_end|>
<|im_start|>user
<tool_response>
{"temperature": 22, "condition": "Sunny", "humidity": 45, "wind_speed": 10}
</tool_response><|im_end|>
<|im_start|>assistant
The weather in New York is currently sunny with a temperature of 22°C. The humidity is at 45% with a wind speed of 10 km/h. It's a great day to be outside!<|im_end|>
<|im_start|>user
Thanks! What about Boston?<|im_end|>
<|im_start|>assistant
I believe this is because we pass in the tool declaration in messages, and provide tools so that the chat template renders it again. The tool declaration should be removed from messages for Qwen3-235B-A22B since chat template automatically adds such a message.