{"record":{"id":"58601a804ff068fc","repo":"microsoft/semantic-kernel","slug":"function-targetfunction-not-found-in-plugin-thi","errorCode":null,"errorMessage":"Function {targetFunction} not found in plugin {this.Name}","messagePattern":"Function (.+?) not found in plugin (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.LocalRuntime/LocalStep.cs","lineNumber":233,"sourceCode":"\n        if (invocableFunctions.Count == 0)\n        {\n            string missingKeysLog() => string.Join(\", \", missingKeys.Select(k => $\"{k.Key}: {string.Join(\", \", k.Value?.Where(v => v.Value == null).Select(v => v.Key) ?? [])}\"));\n            this._logger.LogDebug(\"No invocable functions, missing keys: {MissingKeys}\", missingKeysLog());\n            return;\n        }\n\n        // A message can only target one function and should not result in a different function being invoked.\n        var targetFunction = invocableFunctions.FirstOrDefault((name) => name == message.FunctionName) ??\n            throw new InvalidOperationException($\"A message targeting function '{message.FunctionName}' has resulted in a function named '{invocableFunctions.First()}' becoming invocable. Are the function names configured correctly?\");\n\n        this._logger.LogDebug(\"Step with Id `{StepId}` received all required input for function [{TargetFunction}] and is executing.\", this.Name, targetFunction);\n\n        // Concat all the inputs and run the function\n        KernelArguments arguments = new(this._inputs[targetFunction]!);\n        if (!this._functions.TryGetValue(targetFunction, out KernelFunction? function) || function == null)\n        {\n            throw new ArgumentException($\"Function {targetFunction} not found in plugin {this.Name}\");\n        }\n\n        // Invoke the function, catching all exceptions that it may throw, and then post the appropriate event.\n#pragma warning disable CA1031 // Do not catch general exception types\n        try\n        {\n            // TODO: Process edges for the OnStepEnter event: This feels like a good use for filters in the non-declarative version\n\n            FunctionResult invokeResult = await this.InvokeFunction(function, this._kernel, arguments).ConfigureAwait(false);\n            this.EmitEvent(\n                ProcessEvent.Create(\n                    invokeResult.GetValue<object>(),\n                    this._eventNamespace,\n                    sourceId: $\"{targetFunction}.OnResult\",\n                    eventVisibility: KernelProcessEventVisibility.Public));\n\n            // TODO: Process edges for the OnStepExit event: This feels like a good use for filters in the non-declarative version\n        }","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.LocalRuntime/LocalStep.cs#L215-L251","documentation":"Thrown as ArgumentException by LocalStep.HandleMessageAsync when the targetFunction (determined to be invocable) is not found in the _functions dictionary. The _functions dictionary is populated from the step's KernelPlugin during InitializeStepAsync; the function being invocable (its input channels are satisfied) but absent from _functions means the input channel mapping references a function that the plugin does not expose.","triggerScenarios":"The step's input channels (built from FindInputChannels) recognize a function name, but KernelPluginFactory.CreateFromObject did not register that function name. The invocableFunctions list derives from _inputs keys, while _functions derives from the plugin; a mismatch between the two causes the lookup to fail.","commonSituations":"The step type has input channel attributes referencing a method that is not annotated with [KernelFunction]; the method is private or static so the plugin factory skips it; a version mismatch where input channel discovery and plugin discovery use different rules.","solutions":["Ensure every method referenced by input channels is annotated with [KernelFunction] and is public instance.","Verify the step type is correctly instantiated and that KernelPluginFactory.CreateFromObject discovers all expected functions.","Check for method overloads that may confuse plugin discovery; ensure the method signature matches what input channels expect."],"exampleFix":"// before - method lacks [KernelFunction]\npublic void DoWork(string input) { }\n// after - annotate with [KernelFunction]\n[KernelFunction]\npublic void DoWork(string input) { }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Verify the step type has KernelFunction methods matching expected function names\nvar pluginFunctions = KernelPluginFactory.CreateFromObject(stepInstance)\n    .Select(f => f.Name).ToHashSet();\nforeach (var expectedFn in expectedFunctionNames)\n{\n    if (!pluginFunctions.Contains(expectedFn)) { /* warn: function not found in plugin */ }\n}","tryCatchPattern":null,"preventionTips":["Annotate every callable method on step classes with [KernelFunction].","Ensure methods are public instance (not static or private) so KernelPluginFactory discovers them.","Validate at startup that all expected functions exist in the generated plugin."],"tags":["process-framework","step","kernel-function","plugin","configuration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}