-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Description
When using GetAIAgentAsync without providing the tools list, the tools are being map in tool map using AsAITool, which instead of getting the real function anem and description OpenAIResponsesChatClient.ResponseToolAITool(tool), which uses Name => Tool.GetType().Name this means that the tool will always have the worng name in the map and will never be invocated. The reason I need this is beacause I am trying to resolve the function calls my self, but function invocation never reaches the FunctionInvoker as toolMap.TryGetValue is always false. The correct information remain inside AITool.Tool
The main problem is that there is no way to manually resolve the tool calls without always providing their method in tools array, so even manually handlem is not an options as middleware also does not get it
Code Sample
IChatClient GetChatClient(IChatClient chatClient)
{
var functionClient = new FunctionInvokingChatClient(chatClient);
functionClient.FunctionInvoker = FunctionInvoker;
functionClient.TerminateOnUnknownCalls = false;
return functionClient;
}
ValueTask<object?> FunctionInvoker(FunctionInvocationContext context, CancellationToken token)
{
if (context.Function.Name == "GetWeather")
{
return new ValueTask<object?>(
$"The weather in {context.Arguments.GetValueOrDefault("location")} is cloudy with a high of 15°C.");
}
return new ValueTask<object?>(DateTimeOffset.UtcNow);
}
var modifiedAgent =
await aiProjectClient.GetAIAgentAsync("TestKS", clientFactory: GetChatClient);Error Messages / Stack Traces
Error: Requested function "GetWeather" not found.Package Versions
Azure.AI.Projects 1.2.0-beta.5; Microsoft.Agents.AI.AzureAI 1.0.0-preview.260205.1
.NET Version
.NET10.0
Additional Context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status