From f297747ad22e02e98a4d853c2d35f235181e2eef Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Wed, 5 Nov 2025 10:21:20 -0300 Subject: [PATCH] Use the specified JSON options when adding tools --- src/Agents/ConfigurableAgentsExtensions.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Agents/ConfigurableAgentsExtensions.cs b/src/Agents/ConfigurableAgentsExtensions.cs index 0ab7c00..c46e110 100644 --- a/src/Agents/ConfigurableAgentsExtensions.cs +++ b/src/Agents/ConfigurableAgentsExtensions.cs @@ -52,10 +52,16 @@ public static class ConfigurableAgentsExtensions if (toolMethod.GetCustomAttribute() is { } toolAttribute) { var function = toolMethod.IsStatic - ? AIFunctionFactory.Create(toolMethod, null, toolAttribute.Name ?? ToolJsonOptions.Default.PropertyNamingPolicy!.ConvertName(toolMethod.Name)) + ? AIFunctionFactory.Create(toolMethod, null, + toolAttribute.Name ?? ToolJsonOptions.Default.PropertyNamingPolicy!.ConvertName(toolMethod.Name), + serializerOptions: serializerOptions) : AIFunctionFactory.Create(toolMethod, args => args.Services?.GetRequiredService(typeof(TToolType)) ?? throw new InvalidOperationException("Could not determine target instance for tool."), - new AIFunctionFactoryOptions { Name = toolAttribute.Name ?? ToolJsonOptions.Default.PropertyNamingPolicy!.ConvertName(toolMethod.Name) }); + new AIFunctionFactoryOptions + { + Name = toolAttribute.Name ?? ToolJsonOptions.Default.PropertyNamingPolicy!.ConvertName(toolMethod.Name), + SerializerOptions = serializerOptions + }); builder.Services.TryAdd(ServiceDescriptor.DescribeKeyed( typeof(AIFunction), function.Name,