{"record":{"id":"82de6b437961ed00","repo":"microsoft/autogen","slug":"missing-required-parameter-parametername","errorCode":null,"errorMessage":"Missing required parameter: {parameterName}","messagePattern":"Missing required parameter: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.SemanticKernel/Middleware/KernelPluginMiddleware.cs","lineNumber":60,"sourceCode":"        foreach (var parameter in parameters)\n        {\n            var parameterName = parameter.Name;\n            if (jsonObject.ContainsKey(parameterName))\n            {\n                var parameterType = parameter.ParameterType ?? throw new ArgumentException($\"Missing parameter type for {parameterName}\");\n                var parameterValue = jsonObject[parameterName];\n                var parameterObject = parameterValue.Deserialize(parameterType);\n                kernelArguments.Add(parameterName, parameterObject);\n            }\n            else\n            {\n                if (parameter.DefaultValue != null)\n                {\n                    kernelArguments.Add(parameterName, parameter.DefaultValue);\n                }\n                else if (parameter.IsRequired)\n                {\n                    throw new ArgumentException($\"Missing required parameter: {parameterName}\");\n                }\n            }\n        }\n        var result = await function.InvokeAsync(kernel, kernelArguments);\n\n        return result.ToString();\n    }\n\n    private Func<string, Task<string>> InvokeFunctionPartial(Kernel kernel, KernelFunction function)\n    {\n        return async (string args) =>\n        {\n            var result = await InvokeFunctionAsync(kernel, function, args);\n            return result.ToString();\n        };\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.SemanticKernel/Middleware/KernelPluginMiddleware.cs#L42-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Give the parameter a sensible DefaultValue or mark it optional (nullable with default) in the plugin method signature.","Improve the parameter description in plugin metadata so the model knows it must always supply the value.","Re-declare requiredness accurately: only mark IsRequired when the function truly cannot proceed.","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."],"exampleFix":"// before\npublic string GetWeather(string city, string unit) // unit required, model omits it\n\n// after\npublic string GetWeather(string city, string unit = \"celsius\")","handlingStrategy":"try-catch","validationCode":"// Pre-check model arguments against required parameters before invoking\nvar missing = function.Metadata.Parameters\n    .Where(p => p.IsRequired && p.DefaultValue is null)\n    .Select(p => p.Name)\n    .Except(jsonObject.Keys)\n    .ToList();\nif (missing.Count > 0)\n    return $\"Error: missing required parameter(s): {string.Join(\", \", missing)}. Call again with complete arguments.\";","typeGuard":null,"tryCatchPattern":"catch (ArgumentException ex) when (ex.Message.StartsWith(\"Missing required parameter\"))\n{\n    // feed the error back to the model so it re-issues the tool call correctly\n    return new ToolCallResultMessage(new[] { new ToolCall(functionName, args) }, ex.Message, agent.Name);\n}","preventionTips":["Give required parameters defaults where semantically possible.","Write precise parameter descriptions; models omit parameters they do not understand.","Always return tool-call errors to the model instead of crashing the agent loop."],"tags":["semantic-kernel","tool-calls","function-invocation","autogen","csharp"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}