Difference in behaviour between playground and API - Assistants

Hi all,

I am developing a chatbot using OpenAI assistants and I want to call a function with arguments.

The function is quite simple, and could be described as: get_products(name: String) where ‘name’ is inferred from the user input.

When trying in the playground, the model correctly prompts with the function call and the correct argument.

When the code is run in my Back End though, the results are different and there are no arguments.

See a log from the API:

TOOL OUTPUTS RESPONSE: {"id"=>"run_721clb5ZhPYLgzBZUqvMF7lR", "object"=>"thread.run", "created_at"=>1714488703, "assistant_id"=>"123", "thread_id"=>"thread_d3xESBYfF9vhnuVSyBiDMEvB", "status"=>"requires_action", "started_at"=>1714488703, "expires_at"=>1714489303, "cancelled_at"=>nil, "failed_at"=>nil, "completed_at"=>nil, "required_action"=>{"type"=>"submit_tool_outputs", "submit_tool_outputs"=>{"tool_calls"=>[{"id"=>"call_xWTu9ZVS1eJuuCo1BpMtweeO", "type"=>"function", "function"=>{"name"=>"get_products", "arguments"=>"{}"}}]}}

What could be the cause? I have tried both defining the functions through the API and from the UI itself. No change in behaviour.

Thanks!

Hi all,

I have found the issue, if anybody has the same problem.

I was overriding the tools on a ‘per-run’ basis, thinking I had to pass only the name of the functions to call, as such:

[...]
tools: [
  { type: "file_search"},
  { type: "function", function: { name: "get_products" } },
  { type: "function", function: { name: "other_function" } }
],
[...]

The problem is that this overrides the original definitions in the assistant. After removing the override all works as expected.