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
Assignees
Labels
agents bug Something isn't working experimental Associated with an experimental feature .NET Issue or Pull requests regarding .NET code

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
@sphenry sphenry removed the triage label Jan 13, 2025
@crickman crickman added agents experimental Associated with an experimental feature labels Jan 13, 2025
@crickman crickman moved this to Sprint: In Progress in Semantic Kernel Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents bug Something isn't working experimental Associated with an experimental feature .NET Issue or Pull requests regarding .NET code
Projects
Status: Sprint: In Progress
Development

No branches or pull requests

4 participants