microsoft/semantic-kernel · error · KernelException

Failed to process edge type.

Error message

Failed to process edge type.

What it means

Thrown in LocalProcess.EnqueueEdgesAsync when an edge's OutputTarget is not one of the recognized types: KernelProcessStateTarget, KernelProcessEmitTarget, KernelProcessFunctionTarget, or KernelProcessAgentInvokeTarget. This is a catch-all for unsupported edge target types, indicating either a new target type that the framework does not yet handle or a malformed/null OutputTarget on an edge.

Source

Thrown at dotnet/src/Experimental/Process.LocalRuntime/LocalProcess.cs:445

                })).ConfigureAwait(false);
            }
            else if (edge.OutputTarget is KernelProcessEmitTarget emitTarget)
            {
                // Emit target from process
            }
            else if (edge.OutputTarget is KernelProcessFunctionTarget functionTarget)
            {
                ProcessMessage message = ProcessMessageFactory.CreateFromEdge(edge, processEvent.SourceId, processEvent.Data);
                messageChannel.Enqueue(message);
            }
            else if (edge.OutputTarget is KernelProcessAgentInvokeTarget agentInvokeTarget)
            {
                ProcessMessage message = ProcessMessageFactory.CreateFromEdge(edge, processEvent.SourceId, processEvent.Data);
                messageChannel.Enqueue(message);
            }
            else
            {
                throw new KernelException("Failed to process edge type.");
            }

            foundEdge = true;
        }

        // If no edges were found for the event, check if there are any default conditioned edges to process.
        if (!foundEdge && defaultConditionedEdges.Count > 0)
        {
            foreach (KernelProcessEdge edge in defaultConditionedEdges)
            {
                ProcessMessage message = ProcessMessageFactory.CreateFromEdge(edge, this._process.State.Id!, null, null);
                messageChannel.Enqueue(message);

                // TODO: Handle state here as well
            }
        }

        // Error event was raised with no edge to handle it, send it to an edge defined as the global error target.

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Inspect the edge's OutputTarget type and ensure it is one of the four supported types.
  2. If using a newer target type, upgrade the Process.LocalRuntime package to a version that handles it.
  3. Avoid custom KernelProcessEdgeTarget subclasses unless the framework is forked to handle them.
  4. Check that edges are fully constructed (no null OutputTarget) before adding them to the process.

Example fix

// before - edge with null or unsupported target
process.Edges["evt"] = [new KernelProcessEdge { OutputTarget = null }];
// after - use a supported target type
process.Edges["evt"] = [new KernelProcessEdge { OutputTarget = new KernelProcessFunctionTarget { StepId = "MyStep", FunctionName = "DoWork" } }];
Defensive patterns

Strategy: validation

Validate before calling

// Validate all edge targets are of supported types before starting
var supportedTypes = new HashSet<Type>
{
    typeof(KernelProcessStateTarget), typeof(KernelProcessEmitTarget),
    typeof(KernelProcessFunctionTarget), typeof(KernelProcessAgentInvokeTarget)
};
foreach (var edgeList in process.Edges.Values)
{
    foreach (var edge in edgeList)
    {
        if (edge.OutputTarget is null || !supportedTypes.Contains(edge.OutputTarget.GetType()))
        {
            throw new InvalidOperationException($"Edge has unsupported or null OutputTarget: {edge.OutputTarget?.GetType().Name ?? "null"}");
        }
    }
}

Prevention

When it happens

Trigger: An edge in the process has an OutputTarget that is null, or is an instance of a KernelProcessEdgeTarget subclass not covered by the if/else chain. The fallthrough else block throws.

Common situations: Upgrading to a framework version that introduced a new edge target type not yet handled in this code path; custom edge target subclasses; edges with a null OutputTarget due to incomplete construction; serialization/deserialization producing an unrecognized target type.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/cca891a0b3d6ed27. Report an issue: GitHub.