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: Updated agent logs to include agent name #10330

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Small fix
dmytrostruk committed Jan 28, 2025
commit 14f1f317ded16e19bae351a0eb9fa4c42c5c295b
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ internal static partial class AgentChatLogMessages
/// <summary>
/// Logs retrieval of <see cref="AgentChat"/> messages.
/// </summary>
private static readonly Action<ILogger, string, string, string, string, Exception?> s_logAgentChatGetChatMessages =
LoggerMessage.Define<string, string, string, string>(
private static readonly Action<ILogger, string, string, string, string?, Exception?> s_logAgentChatGetChatMessages =
LoggerMessage.Define<string, string, string, string?>(
logLevel: LogLevel.Debug,
eventId: 0,
"[{MethodName}] Source: {MessageSourceType}/{MessageSourceId}/{MessageSourceName}.");
@@ -37,7 +37,7 @@ public static void LogAgentChatGetChatMessages(
{
if (agent is null)
{
s_logAgentChatGetChatMessages(logger, methodName, "primary", "primary", AgentExtensions.DefaultAgentDisplayName, null);
s_logAgentChatGetChatMessages(logger, methodName, "primary", "primary", null, null);
}
else
{
Original file line number Diff line number Diff line change
@@ -10,14 +10,6 @@ namespace Microsoft.SemanticKernel.Agents.Extensions;
[ExcludeFromCodeCoverage]
internal static class AgentExtensions
{
/// <summary>
/// Default display name of the agent.
/// </summary>
/// <remarks>
/// Currently, it's intended for telemetry purposes only.
/// </remarks>
public static string DefaultAgentDisplayName = "UnnamedAgent";

/// <summary>
/// Provides a name for the agent, even if it's the identifier.
/// (since <see cref="Agent.Name"/> allows null)
@@ -33,5 +25,5 @@ internal static class AgentExtensions
/// <remarks>
/// Currently, it's intended for telemetry purposes only.
/// </remarks>
public static string GetDisplayName(this Agent agent) => agent.Name ?? DefaultAgentDisplayName;
public static string GetDisplayName(this Agent agent) => agent.Name ?? "UnnamedAgent";
}