microsoft/semantic-kernel · error · AggregateException

Plugin creation failed for {pluginName}

Error message

Plugin creation failed for {pluginName}

What it means

The catch block wraps any failure of ImportPluginFromCopilotAgentPluginAsync in an AggregateException with the plugin name. Note: AggregateException wrapping a single inner exception is slightly misleading (AggregateException implies multiple errors); the original cause is in InnerException. The log line is written first, then the throw propagates.

Source

Thrown at dotnet/samples/Demos/CopilotAgentPlugins/CopilotAgentPluginsDemoSample/DemoCommand.cs:384

                { "https://api.nasa.gov/planetary", new OpenApiFunctionExecutionParameters(authCallback: GetApiKeyAuthProvider("DEMO_KEY", "api_key", false), enableDynamicOperationPayload: false, enablePayloadNamespacing: true)}
            },
        };

        try
        {
            KernelPlugin plugin =
            await kernel.ImportPluginFromCopilotAgentPluginAsync(
                pluginName,
                GetCopilotAgentManifestPath(pluginName),
                copilotAgentPluginParameters)
                .ConfigureAwait(false);
            AnsiConsole.MarkupLine($"[bold green] {pluginName} loaded successfully.[/]");
        }
        catch (Exception ex)
        {
            AnsiConsole.MarkupLine($"[red]Failed to load {pluginName}.[/]");
            kernel.LoggerFactory.CreateLogger("Plugin Creation").LogError(ex, "Plugin creation failed. Message: {0}", ex.Message);
            throw new AggregateException($"Plugin creation failed for {pluginName}", ex);
        }
    }
    #region MagicDoNotLookUnderTheHood
    private static readonly HashSet<string> s_fieldsToIgnore = new(
        [
            "@odata.type",
            "attachments",
            "allowNewTimeProposals",
            "bccRecipients",
            "bodyPreview",
            "calendar",
            "categories",
            "ccRecipients",
            "changeKey",
            "conversationId",
            "coordinates",
            "conversationIndex",
            "createdDateTime",

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Read ex.InnerException (and the preceding log line) for the real cause before the AggregateException.
  2. Confirm GetCopilotAgentManifestPath(pluginName) returns a reachable, valid manifest path.
  3. Validate the manifest JSON against the Copilot Agent plugin schema.
  4. Supply any required copilotAgentPluginParameters the manifest expects.

Example fix

// before
catch (Exception ex)
{
    AnsiConsole.MarkupLine($"[red]Failed to load {pluginName}.[/]");
    kernel.LoggerFactory.CreateLogger("Plugin Creation").LogError(ex, "Plugin creation failed. Message: {0}", ex.Message);
    throw new AggregateException($"Plugin creation failed for {pluginName}", ex);
}

// after (preserve true cause; only wrap when you actually aggregate)
catch (Exception ex)
{
    logger.LogError(ex, "Plugin creation failed for {Plugin}", pluginName);
    throw new InvalidOperationException($"Plugin creation failed for {pluginName}. See inner exception.", ex);
}
Defensive patterns

Strategy: try-catch

Validate before calling

var manifestPath = GetCopilotAgentManifestPath(pluginName);
if (!File.Exists(manifestPath) && !Uri.IsWellFormedUriString(manifestPath, UriKind.Absolute))
    throw new FileNotFoundException($"Plugin manifest not found: {manifestPath}", manifestPath);

Type guard

static bool ManifestReachable(string path) =>
    File.Exists(path) || Uri.IsWellFormedUriString(path, UriKind.Absolute);

Try / catch

try { await kernel.ImportPluginFromCopilotAgentPluginAsync(...); }
catch (Exception ex)
{
    logger.LogError(ex, "Plugin creation failed for {Plugin}", pluginName);
    throw new InvalidOperationException($"Plugin creation failed for {pluginName}.", ex);
}

Prevention

When it happens

Trigger: ImportPluginFromCopilotAgentPluginAsync throws — invalid manifest path, malformed Copilot Agent plugin manifest, missing parameters (copilotAgentPluginParameters), network failure fetching the manifest, or schema validation failure inside the importer.

Common situations: Plugin name doesn't map to a manifest path, the manifest JSON doesn't match the expected Copilot Agent schema, required runtime arguments were not supplied, or the manifest URL is unreachable.

Related errors


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