microsoft/autogen · error · ArgumentException

Missing required parameter: {parameterName}

Error message

Missing required parameter: {parameterName}

What it means

While binding the model's JSON tool-call arguments to a Semantic Kernel function parameter, the middleware found the parameter name absent from the JSON, the parameter has no default value, and IsRequired is true. Since SK cannot invoke the function without the value, it throws ArgumentException.

Source

Thrown at dotnet/src/AutoGen.SemanticKernel/Middleware/KernelPluginMiddleware.cs:60

        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);

        return result.ToString();
    }

    private Func<string, Task<string>> InvokeFunctionPartial(Kernel kernel, KernelFunction function)
    {
        return async (string args) =>
        {
            var result = await InvokeFunctionAsync(kernel, function, args);
            return result.ToString();
        };
    }
}

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Give the parameter a sensible DefaultValue or mark it optional (nullable with default) in the plugin method signature.
  2. Improve the parameter description in plugin metadata so the model knows it must always supply the value.
  3. Re-declare requiredness accurately: only mark IsRequired when the function truly cannot proceed.
  4. Catch ArgumentException in the tool-call execution loop and return an error message back to the model so it can retry the call with complete arguments.

Example fix

// before
public string GetWeather(string city, string unit) // unit required, model omits it

// after
public string GetWeather(string city, string unit = "celsius")
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check model arguments against required parameters before invoking
var missing = function.Metadata.Parameters
    .Where(p => p.IsRequired && p.DefaultValue is null)
    .Select(p => p.Name)
    .Except(jsonObject.Keys)
    .ToList();
if (missing.Count > 0)
    return $"Error: missing required parameter(s): {string.Join(", ", missing)}. Call again with complete arguments.";

Try / catch

catch (ArgumentException ex) when (ex.Message.StartsWith("Missing required parameter"))
{
    // feed the error back to the model so it re-issues the tool call correctly
    return new ToolCallResultMessage(new[] { new ToolCall(functionName, args) }, ex.Message, agent.Name);
}

Prevention

When it happens

Trigger: The LLM omits a required parameter from its function-call arguments (hallucinated/abbreviated call), or the plugin declares a parameter as required that the model was never reliably going to supply.

Common situations: Complex tool schemas where models skip rarely-used parameters; plugin signatures evolved to add required parameters after few-shot examples were written; models ignoring the JSON schema.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/82de6b437961ed00. Report an issue: GitHub.