microsoft/autogen · error · ArgumentException
Missing parameter type for {parameterName}
Error message
Missing parameter type for {parameterName} What it means
KernelPluginMiddleware.InvokeFunctionAsync deserializes the LLM's JSON arguments and converts each value using KernelParameterMetadata.ParameterType. If the plugin function's parameter metadata carries no .NET type (ParameterType == null), conversion is impossible and this ArgumentException is thrown.
Source
Thrown at dotnet/src/AutoGen.SemanticKernel/Middleware/KernelPluginMiddleware.cs:47
_functionCallMiddleware = new FunctionCallMiddleware(functionContracts, functionMap, Name);
}
public Task<IMessage> InvokeAsync(MiddlewareContext context, IAgent agent, CancellationToken cancellationToken = default)
{
return _functionCallMiddleware.InvokeAsync(context, agent, cancellationToken);
}
private async Task<string> InvokeFunctionAsync(Kernel kernel, KernelFunction function, string arguments)
{
var kernelArguments = new KernelArguments();
var parameters = function.Metadata.Parameters;
var jsonObject = JsonSerializer.Deserialize<JsonObject>(arguments) ?? new JsonObject();
foreach (var parameter in parameters)
{
var parameterName = parameter.Name;
if (jsonObject.ContainsKey(parameterName))
{
var parameterType = parameter.ParameterType ?? throw new ArgumentException($"Missing parameter type for {parameterName}");
var parameterValue = jsonObject[parameterName];
var parameterObject = parameterValue.Deserialize(parameterType);
kernelArguments.Add(parameterName, parameterObject);
}
else
{
if (parameter.DefaultValue != null)
{
kernelArguments.Add(parameterName, parameter.DefaultValue);
}
else if (parameter.IsRequired)
{
throw new ArgumentException($"Missing required parameter: {parameterName}");
}
}
}
var result = await function.InvokeAsync(kernel, kernelArguments);
View on GitHub (pinned to 027ecf0a37)
Solutions
- Define plugin methods as concrete public C# methods so KernelFunctionFactory.FromMethod captures ParameterType via reflection.
- If constructing KernelFunctionMetadata manually, always populate ParameterType for each KernelParameterMetadata.
- Check for null ParameterType at plugin registration time and fail fast with a clear message naming the function.
- Avoid dynamic/AOT trimming for assemblies containing plugins, or use source-generated plugin metadata.
Example fix
// before
var metadata = new KernelFunctionMetadata("get_weather")
{
Parameters = [new KernelParameterMetadata("city")] // no ParameterType
};
// after
var metadata = new KernelFunctionMetadata("get_weather")
{
Parameters = [new KernelParameterMetadata("city") { ParameterType = typeof(string) }]
}; Defensive patterns
Strategy: validation
Validate before calling
// Fail fast at plugin registration
foreach (var p in function.Metadata.Parameters)
{
if (p.ParameterType is null)
throw new InvalidOperationException($"Plugin '{function.Metadata.Name}': parameter '{p.Name}' has no ParameterType.");
} Try / catch
catch (ArgumentException ex) when (ex.Message.StartsWith("Missing parameter type"))
{
logger.LogError(ex, "Plugin metadata incomplete; register plugins from strongly-typed methods");
throw;
} Prevention
- Register plugins from concrete public methods (KernelFunctionFactory.FromMethodWithType) so reflection supplies types.
- Smoke-test every plugin registration at startup, verifying ParameterType is non-null.
- Avoid dynamic metadata construction without explicit ParameterType assignments.
When it happens
Trigger: Registering a KernelFunction whose parameter metadata lacks a resolved type — typically dynamically constructed functions (e.g. from PromptFunctions with untyped arguments) or KernelFunctionFactory overloads that do not carry reflection info — and the model then supplies that parameter in its arguments JSON.
Common situations: Building KernelPlugins from delegates defined via method-info-less factories; AOT/trimming scenarios stripping metadata; plugins authored with object/dynamic parameters.
Related errors
- Missing required parameter: {parameterName}
- Unsupported content type
- Only one choice is supported in streaming response
- The method or operation is not implemented.
- unsupported message type, only support TextMessage, ImageMes
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/febcd770e6381f32.
Report an issue: GitHub.