{"record":{"id":"bda498fe736799ea","repo":"microsoft/semantic-kernel","slug":"function-description-is-required-please-provide-a","errorCode":null,"errorMessage":"Function description is required. Please provide a description for the function {this.FullyQualifiedName}.","messagePattern":"Function description is required\\. Please provide a description for the function (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.Google/Models/Gemini/GeminiFunction.cs","lineNumber":163,"sourceCode":"                properties.Add(parameter.Name, parameter.Schema ?? GetDefaultSchemaForParameter(parameter));\n                if (parameter.IsRequired)\n                {\n                    required.Add(parameter.Name);\n                }\n            }\n\n            resultParameters = new Dictionary<string, object?>\n            {\n                { \"type\", \"object\" },\n                { \"required\", required },\n                { \"properties\", properties },\n            };\n        }\n\n        return new GeminiTool.FunctionDeclaration\n        {\n            Name = this.FullyQualifiedName,\n            Description = this.Description ?? throw new InvalidOperationException(\n                $\"Function description is required. Please provide a description for the function {this.FullyQualifiedName}.\"),\n            Parameters = GeminiRequest.TransformToOpenApi3Schema(JsonSerializer.SerializeToElement(resultParameters)),\n        };\n    }\n\n    /// <summary>Gets a <see cref=\"KernelJsonSchema\"/> for a typeless parameter with the specified description, defaulting to typeof(string)</summary>\n    private static KernelJsonSchema GetDefaultSchemaForParameter(GeminiFunctionParameter parameter)\n    {\n        // If there's a description, incorporate it.\n        if (!string.IsNullOrWhiteSpace(parameter.Description))\n        {\n            return KernelJsonSchemaBuilder.Build(typeof(string), parameter.Description);\n        }\n\n        // Otherwise, we can use a cached schema for a string with no description.\n        return s_stringNoDescriptionSchema;\n    }\n}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Google/Models/Gemini/GeminiFunction.cs#L145-L181","documentation":"Thrown by GeminiFunction.ToFunctionDeclaration when this.Description is null while serializing the function for the Gemini API. Gemini's FunctionDeclaration requires a non-empty description so the model understands what the function does; the connector refuses to send a descriptionless tool. The error names the offending function via FullyQualifiedName.","triggerScenarios":"Registering a kernel function (via method attribute, delegate, or KernelFunctionFactory) that has no KernelFunctionDescription.Description; e.g. a [KernelFunction] method without a [Description] and no description passed at registration, then exposing it to Gemini via tool-call behavior or auto-function importing.","commonSituations":"Adding a plugin from a class where the [KernelFunction] method lacks a [Description] attribute; creating KernelFunction from a delegate without a description argument; version changes that tightened description requirements.","solutions":["Add a [Description(\"...\")] attribute to every [KernelFunction] method exposed to Gemini.","Provide a description string when registering functions via KernelFunctionFactory.CreateFromMethod / CreateFromPrompt.","If building GeminiFunction manually, pass a non-null description in the constructor."],"exampleFix":"// before\npublic class MyPlugin\n{\n    [KernelFunction]\n    public string GetTime() => DateTime.Now.ToString();\n}\n\n// after\npublic class MyPlugin\n{\n    [KernelFunction]\n    [Description(\"Returns the current date and time.\")]\n    public string GetTime() => DateTime.Now.ToString();\n}","handlingStrategy":"validation","validationCode":"static void EnsureDescriptions(IReadOnlyList<KernelFunctionMetadata> fns)\n{\n    foreach (var f in fns)\n        if (string.IsNullOrWhiteSpace(f.Description))\n            throw new InvalidOperationException($\"Function {f.PluginName}.{f.Name} has no description.\");\n}","typeGuard":"static bool AllFunctionsDescribed(IEnumerable<KernelFunctionMetadata> fns)\n    => fns.All(f => !string.IsNullOrWhiteSpace(f.Description));","tryCatchPattern":"try { await kernel.InvokePromptAsync(prompt, new(settings)); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Function description is required\"))\n{ logger.LogError(ex, \"Add [Description] to the offending kernel function.\"); throw; }","preventionTips":["Add a [Description] attribute to every [KernelFunction] exposed to Gemini.","Provide descriptions when registering functions via KernelFunctionFactory.","Lint plugins at startup to assert all functions have descriptions."],"tags":["gemini","tool-calling","function","description","validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}