I'm having trouble getting multiple function calls to work reliably.
Problem Description
When I ask the model to perform multiple tasks that should each trigger a separate function call, it only calls one function instead of both. For example, with this user message:
What's the weather like in London today and can you send that information to weather@example.com?
I expect the model to:
- Call
get_weatherto get the weather in London - Call
send_emailto send that information to the email address
However, the model only calls the get_weather function and then returns None as the final response, instead of incorporating the weather information into an email or explicitly calling the email function.
What I've Tried
- Setting
tool_choice="required"to force function calls - Setting
parallel_tool_calls=Trueto explicitly enable multiple function calls - Using different model versions
- Adding detailed function descriptions
- Rewriting the user query to be more explicit
Nothing seems to work consistently. The model either calls just one function or occasionally returns a text response without any function calls.
Minimal Reproducible Example
I've attached a simple script that demonstrates the issue. It's a minimal version that defines two functions (weather and email) and tries to get the model to use both in sequence.
Questions
- Is there something wrong with my implementation of function calling?
- Should I be using a different approach entirely for multi-step tasks like this?
I'm missing something fundamental so any help/pointers would be greatly appreciated!
Code to reproduce is attached. Feel free to correct it or add comments.