From f135355bf985297d03ce6084dd131a31f231672f Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 4 Apr 2025 21:55:33 -0400 Subject: [PATCH] Propagate fix from AIFunctionFactory to TemporaryAIFunctionFactory (#215) --- src/ModelContextProtocol/Server/TemporaryAIFunctionFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ModelContextProtocol/Server/TemporaryAIFunctionFactory.cs b/src/ModelContextProtocol/Server/TemporaryAIFunctionFactory.cs index 25bffe5..17a0981 100644 --- a/src/ModelContextProtocol/Server/TemporaryAIFunctionFactory.cs +++ b/src/ModelContextProtocol/Server/TemporaryAIFunctionFactory.cs @@ -568,9 +568,7 @@ internal static partial class TemporaryAIFunctionFactory throw new ArgumentException("Parameter is missing a name.", nameof(parameter)); } - // Resolve the contract used to marshal the value from JSON -- can throw if not supported or not found. Type parameterType = parameter.ParameterType; - JsonTypeInfo typeInfo = serializerOptions.GetTypeInfo(parameterType); // For CancellationToken parameters, we always bind to the token passed directly to InvokeAsync. if (parameterType == typeof(CancellationToken)) @@ -606,6 +604,8 @@ internal static partial class TemporaryAIFunctionFactory } // For all other parameters, create a marshaller that tries to extract the value from the arguments dictionary. + // Resolve the contract used to marshal the value from JSON -- can throw if not supported or not found. + JsonTypeInfo typeInfo = serializerOptions.GetTypeInfo(parameterType); return (arguments, _) => { // If the parameter has an argument specified in the dictionary, return that argument.