Skip to content

Commit ac4e858

Browse files
committed
Use the specified JSON options when adding tools
1 parent bededac commit ac4e858

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Agents/ConfigurableAgentsExtensions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,16 @@ public static class ConfigurableAgentsExtensions
5252
if (toolMethod.GetCustomAttribute<McpServerToolAttribute>() is { } toolAttribute)
5353
{
5454
var function = toolMethod.IsStatic
55-
? AIFunctionFactory.Create(toolMethod, null, toolAttribute.Name ?? ToolJsonOptions.Default.PropertyNamingPolicy!.ConvertName(toolMethod.Name))
55+
? AIFunctionFactory.Create(toolMethod, null,
56+
toolAttribute.Name ?? ToolJsonOptions.Default.PropertyNamingPolicy!.ConvertName(toolMethod.Name),
57+
serializerOptions: serializerOptions)
5658
: AIFunctionFactory.Create(toolMethod, args => args.Services?.GetRequiredService(typeof(TToolType)) ??
5759
throw new InvalidOperationException("Could not determine target instance for tool."),
58-
new AIFunctionFactoryOptions { Name = toolAttribute.Name ?? ToolJsonOptions.Default.PropertyNamingPolicy!.ConvertName(toolMethod.Name) });
60+
new AIFunctionFactoryOptions
61+
{
62+
Name = toolAttribute.Name ?? ToolJsonOptions.Default.PropertyNamingPolicy!.ConvertName(toolMethod.Name),
63+
SerializerOptions = serializerOptions
64+
});
5965

6066
builder.Services.TryAdd(ServiceDescriptor.DescribeKeyed(
6167
typeof(AIFunction), function.Name,

0 commit comments

Comments
 (0)