From 324b326b69d4f15e4c4d5fee26003c410c1c73c7 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 4 Apr 2025 21:50:11 -0400 Subject: [PATCH] Propagate fix from AIFunctionFactory to TemporaryAIFunctionFactory --- 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 25bffe5e..17a09813 100644 --- a/src/ModelContextProtocol/Server/TemporaryAIFunctionFactory.cs +++ b/src/ModelContextProtocol/Server/TemporaryAIFunctionFactory.cs @@ -568,9 +568,7 @@ static bool IsAsyncMethod(MethodInfo method) 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 @@ static bool IsAsyncMethod(MethodInfo method) } // 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.