Describe the bug
LoggerFactory is never set in Agent class and thus is always using NullLoggerFactory, which results in no logs at all.
https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/Agents/Abstractions/Agent.cs#L43
To Reproduce
IKernelBuilder builder = Kernel.CreateBuilder();
builder.Services.AddSingleton(loggerFactory);
Kernel kernel = builder.Build();
var agent = await OpenAIAssistantAgent.CreateAsync(
clientProvider: OpenAIClientProvider.ForAzureOpenAI(new AzureCliCredential(), oaiEndpoint),
definition: new OpenAIAssistantDefinition("chat")
{
Name = "Bot",
Instructions = "Please answer the following question."
},
kernel: kernel);
Expected behavior
The LoggerFactory from the Kernel should be used.
Workaround
var loggerFactoryProperty = typeof(OpenAIAssistantAgent).GetProperty("LoggerFactory", BindingFlags.Public | BindingFlags.Instance);
if (loggerFactoryProperty != null)
{
loggerFactoryProperty.SetValue(agent, kernel.LoggerFactory);
}
Platform
- Microsoft.SemanticKernel, 1.32.0
- Microsoft.SemanticKernel.Agents.OpenAI, 1.32.0-alpha
Describe the bug
LoggerFactoryis never set inAgentclass and thus is always usingNullLoggerFactory, which results in no logs at all.https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/Agents/Abstractions/Agent.cs#L43
To Reproduce
Expected behavior
The LoggerFactory from the
Kernelshould be used.Workaround
Platform