microsoft/semantic-kernel · error · ArgumentException
Function Invoke not found in plugin {this.Name}
Error message
Function Invoke not found in plugin {this.Name} What it means
Thrown by `LocalAgentStep.HandleMessageAsync` when the agent step's plugin does not contain a kernel function named `"Invoke"`. The step loads functions from a `KernelProcessAgentExecutorInternal` plugin at init; if that plugin exposes no `Invoke` method (e.g. the agent executor type lacks it or it was renamed/obscured), the lookup fails and every inbound message is rejected. It is an ArgumentException.
Source
Thrown at dotnet/src/Experimental/Process.LocalRuntime/LocalAgentStep.cs:61
Verify.NotNull(message, nameof(message));
// Lazy one-time initialization of the step before processing a message
await this._initializeTask.Value.ConfigureAwait(false);
string targetFunction = "Invoke";
KernelArguments arguments = new()
{
{ "message", message.TargetEventData switch
{
KernelProcessEventData proxyData => proxyData.ToObject(),
_ => message.TargetEventData
}
},
{ "writtenToThread", message.writtenToThread == this._agentThread.ThreadId }
};
if (!this._functions.TryGetValue(targetFunction, out KernelFunction? function) || function == null)
{
throw new ArgumentException($"Function Invoke not found in plugin {this.Name}");
}
object? result = null;
// Invoke the function, catching all exceptions that it may throw, and then post the appropriate event.
#pragma warning disable CA1031 // Do not catch general exception types
try
{
FunctionResult invokeResult = await this.InvokeFunction(function, this._kernel, arguments).ConfigureAwait(false);
result = invokeResult.GetValue<object>();
this.EmitEvent(
ProcessEvent.Create(
result,
this._eventNamespace,
sourceId: $"{targetFunction}.OnResult",
eventVisibility: KernelProcessEventVisibility.Public,
writtenToThread: this._agentThread.ThreadId)); // TODO: This is keeping track of the thread the message has been written to, clean it up, name it better, etc.
}View on GitHub (pinned to c028a0c7dc)
Solutions
- Ensure the agent executor type declares a public `[KernelFunction("Invoke")]` method with the expected signature (`message`, `writtenToThread`).
- Confirm the executor is the SDK's `KernelProcessAgentExecutorInternal` or a compatible subclass that retains `Invoke`.
- Disable trimming/AOT for the executor assembly, or annotate `Invoke` with dynamic-dependency attributes so it is preserved.
- Verify `this._functions` actually contains `"Invoke"` after init by logging its keys in a debug build.
Example fix
// before
internal sealed class MyAgentExecutor
{
[KernelFunction]
public Task<string> RunAsync(string message) => ...; // wrong name
}
// after
internal sealed class MyAgentExecutor
{
[KernelFunction("Invoke")]
public Task<string> InvokeAsync(string message, bool writtenToThread) => ...;
} Defensive patterns
Strategy: validation
Validate before calling
var executor = new KernelProcessAgentExecutorInternal(stepInfo, thread, psm);
var plugin = KernelPluginFactory.CreateFromObject(executor, pluginName: stepInfo.State.Name);
if (!plugin.Any(f => f.Name == "Invoke"))
throw new InvalidOperationException($"Agent '{stepInfo.State.Name}' plugin has no 'Invoke' kernel function; check the executor type and trimming settings."); Type guard
bool PluginHasInvoke(KernelPlugin plugin) => plugin.Any(f => string.Equals(f.Name, "Invoke", StringComparison.Ordinal));
Try / catch
try { await agentStep.HandleMessageAsync(message); }
catch (ArgumentException ex) when (ex.Message.Contains("Function Invoke not found"))
{ _logger.LogError(ex, "Agent plugin missing Invoke; verify executor declaration."); throw; } Prevention
- Ensure the agent executor declares a public [KernelFunction("Invoke")] method matching the expected signature.
- In trimming/AOT scenarios, root-keep the executor's Invoke method.
- Log plugin function keys at init to confirm Invoke is present.
When it happens
Trigger: Use an agent whose executor internal type does not declare a `[KernelFunction] Invoke(...)` method; reflection-based plugin creation skips `Invoke` due to visibility/signature mismatch; the executor was subclassed and `Invoke` removed; version change renamed the expected function.
Common situations: Custom agent executor implementations that omit the `Invoke` kernel function; AOT/trimming stripping the method; signature changes where `Invoke` no longer matches the expected parameters; misuse of a non-agent step where an agent step was expected.
Related errors
- Attempt to build a workflow node from step with no Id
- This method is not implemented in this test fixture.
- Failed to create process thread.
- The thread name {agentStep.ThreadName} does not have a match
- The derived DeactivateAsync method failed to complete for st
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/610b49ef5c3d9bc3.
Report an issue: GitHub.