Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Bug: LoggerFactory is never set in Agent #10110

Open
RicardoNiepel opened this issue Jan 7, 2025 · 0 comments
Open

.Net: Bug: LoggerFactory is never set in Agent #10110

RicardoNiepel opened this issue Jan 7, 2025 · 0 comments
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code triage

Comments

@RicardoNiepel
Copy link

RicardoNiepel commented Jan 7, 2025

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
@RicardoNiepel RicardoNiepel added the bug Something isn't working label Jan 7, 2025
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Jan 7, 2025
@github-actions github-actions bot changed the title Bug: LoggerFactory is never set in Agent .Net: Bug: LoggerFactory is never set in Agent Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code triage
Projects
None yet
Development

No branches or pull requests

2 participants