microsoft/semantic-kernel · error · KernelException
The edge target is not a function target: {e.OutputTarget}
Error message
The edge target is not a function target: {e.OutputTarget} What it means
Thrown by `BuildNode` while mapping a step's edges to `ThenAction`s: an edge's `OutputTarget` is not a `KernelProcessFunctionTarget`. The declarative workflow only supports edges that target a kernel function, so any other target type is rejected. It is a KernelException raised inside the edge-projection lambda.
Source
Thrown at dotnet/src/Experimental/Process.Core/Workflow/WorkflowBuilder.cs:454
From = step.State.Id,
Event = edge.Key,
Condition = edge.Value.FirstOrDefault()?.Condition.DeclarativeDefinition
},
Then = [.. edge.Value.Select(e =>
{
if (e.OutputTarget is KernelProcessFunctionTarget functionTarget)
{
return new ThenAction()
{
Node = functionTarget.StepId switch
{
ProcessConstants.EndStepName => "End",
string s => s
}
};
}
throw new KernelException($"The edge target is not a function target: {e.OutputTarget}");
})]
};
orchestrationSteps.Add(orchestrationStep);
}
return node;
}
private static Node BuildAgentNode(KernelProcessAgentStep agentStep, List<OrchestrationStep> orchestrationSteps)
{
Verify.NotNull(agentStep);
if (agentStep.AgentDefinition is null || string.IsNullOrWhiteSpace(agentStep.State?.Id) || string.IsNullOrWhiteSpace(agentStep.AgentDefinition.Type))
{
throw new InvalidOperationException("Attempt to build a workflow node from step with no Id");
}
View on GitHub (pinned to c028a0c7dc)
Solutions
- Ensure every edge is created with a `KernelProcessFunctionTarget` as its `OutputTarget` (use the standard `.SendEventTo(...)` / target-builder APIs).
- If you have custom target types, convert them to `KernelProcessFunctionTarget` before calling `BuildWorkflow`.
- Audit edge construction to confirm no null or non-function targets exist.
Example fix
// before
edge.OutputTarget = new MyCustomTarget();
// after
edge.OutputTarget = new KernelProcessFunctionTarget { StepId = "NextStep", FunctionName = "Run" }; Defensive patterns
Strategy: validation
Validate before calling
foreach (var step in process.Steps)
{
foreach (var edge in step.Edges.SelectMany(e => e.Value))
{
if (edge.OutputTarget is not KernelProcessFunctionTarget)
throw new InvalidOperationException($"Edge on step '{step.State?.Id}' has a non-function output target ({edge.OutputTarget?.GetType().Name}).");
}
} Type guard
bool HasFunctionTargets(KernelProcessStepInfo step) =>
step.Edges.SelectMany(e => e.Value).All(e => e.OutputTarget is KernelProcessFunctionTarget); Try / catch
try { await WorkflowBuilder.BuildWorkflow(process); }
catch (KernelException ex) when (ex.Message.Contains("not a function target"))
{ _logger.LogError(ex, "An edge target is not a KernelProcessFunctionTarget."); throw; } Prevention
- Build edges only through the official target-builder APIs so OutputTarget is always KernelProcessFunctionTarget.
- Do not subclass the target type for custom routing without converting back before BuildWorkflow.
When it happens
Trigger: Construct a process edge whose `OutputTarget` is null or an unsupported subtype of the target base; programmatically build edges with a custom target type instead of `KernelProcessFunctionTarget`; deserialize a process whose edge targets lost their concrete type.
Common situations: Custom edge-target subclasses introduced without updating the builder; serialization polymorphism dropping the concrete function-target type; mixing runtimes that emit different target shapes.
Related errors
- The process must have an Id set
- Unsupported target type
- An orchestration is referencing a node with Id `{listenCondi
- A complete then action is required for orchestration steps.
- An orchestration is referencing a node with Id `{action.Node
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/3aa1b8464df71b96.
Report an issue: GitHub.