Skip to content

Bug: NotImplementedException on SK Logging #13681

@dersia

Description

@dersia

Describe the bug
We are using SK together with some MCP Servers that we have running using ModelContextProtocol.AspNet. We use HttpTransport and the AsKernelFunction ExtensionMethod to add the Tools as plugins to SK. Since I have turned on the logging for SK we are seeing the following Errors in the Logs:

Function SomePlugin-SomeTool result: Failed to log function result value
System.NotSupportedException: JsonTypeInfo metadata for type 'Microsoft.Extensions.AI.TextContent' was not provided by TypeInfoResolver of type 'Microsoft.SemanticKernel.AbstractionsJsonContext'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically.
          at System.Text.Json.ThrowHelper.ThrowNotSupportedException_NoMetadataForType(Type type, IJsonTypeInfoResolver resolver)
          at System.Text.Json.JsonSerializerOptions.GetTypeInfoForRootType(Type type, Boolean fallBackToNearestAncestorType)
          at System.Text.Json.JsonSerializerOptions.TryGetPolymorphicTypeInfoForRootType(Object rootValue, JsonTypeInfo& polymorphicTypeInfo)
          at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter writer, T& rootValue, Object rootValueBoxed)
          at System.Text.Json.JsonSerializer.WriteString[TValue](TValue& value, JsonTypeInfo`1 jsonTypeInfo)
          at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonTypeInfo`1 jsonTypeInfo)
          at Microsoft.SemanticKernel.KernelFunctionLogMessages.LogFunctionResultValueInternal(ILogger logger, String pluginName, String functionName, FunctionResult resultValue, JsonSerializerOptions jsonSerializerOptions)

Since this is only on the logging side and has no effect on the execution, this isn't that bad, but I though it's a good idea to report it here.

To Reproduce
Steps to reproduce the behavior:

  1. Setup SK, use ModelContextProtocol package
  2. use McpClient.ListToolsAsync() to get the tools
  3. on each tool use .AsKernelFunction()
  4. add them to a plugin
  5. add the plugin to the kernel
  6. Turn of SK logging in the appsettings
  7. use the llm to make calls to the tool

Expected behavior
Serialization and logging works

Platform

  • Language: c#
  • Source: 1.73.0
  • AI model: Azure OpenAI, GPT 5.2
  • IDE: Any / running from Docker
  • OS: Linux (Containered Version)

Additional Info
ModelContextProtocol(.AspNetCore)-Nuget Version: 1.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions