-
Notifications
You must be signed in to change notification settings - Fork 840
Description
Description
OpenAI Assistants has a peculiar behavior that it doesn't allow Tools override when tools are provided at the Agent/Assistant creation.
i.e:
The code below attempts to create a OpenAI Assistant with Function Tool Definition.
var assistantOptions = new AssistantCreationOptions();
// Converts and AIFunction and add as a Tool Definition
assistantOptions.Tools.Add(ToOpenAIAssistantsFunctionToolDefinition(aiFunction));
// Create Hosted Assistant Agent
var assistantCreateResult = await client.CreateAssistantAsync(model, assistantOptions).ConfigureAwait(false);After creating an agent like above, attempting to use chatClient passing any of the AIFunction tools provided above in the chatOptions.Tools will throw the redundancy error below:
Unhandled exception. System.ClientModel.ClientResultException: HTTP 400 (invalid_request_error: )
Parameter: tools[3]
Function tools must have unique names.
Reproduction Steps
Create an Assistant Agent with tools and attempt to pass the same tools in a chatClient.GetResponseAsync call.
Expected behavior
Ideally AsIChatClient() should provide an extra set of Agent/Assistant level tools: [] parameters, so those tools can be used in GetResponseAsync or GetStreamingResponseAsync to check and remove redundancy.
Actual behavior
Creating an Assistant Agent with tools and attempt to pass the same tools in a chatClient.GetResponseAsync call gives back a 400 Bad Request with tool redudancy error
Known Workarounds
- Don't use hosted function calling.
- The caller must have to track on his side whenever he assigned tools to the agent creation, capture manually the
FunctionInvokingChatClientand add those tools asAdditionalTools(for hosted function calling to work) and avoid in any further calls to the chat client to provide those tools in thechatOptions.