Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ FunctionResultContent CreateFunctionResultContent(FunctionInvocationResult resul

/// <summary>Gets a value indicating whether <see cref="Activity.Current"/> represents an "invoke_agent" span.</summary>
private static bool CurrentActivityIsInvokeAgent =>
Activity.Current?.DisplayName == OpenTelemetryConsts.GenAI.InvokeAgentName;
Activity.Current?.DisplayName?.StartsWith(OpenTelemetryConsts.GenAI.InvokeAgentName, StringComparison.Ordinal) is true;
Comment thread
stephentoub marked this conversation as resolved.
Outdated

/// <summary>Invokes the function asynchronously.</summary>
/// <param name="context">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,12 @@ public async Task ClonesChatOptionsAndResetContinuationTokenForBackgroundRespons
Assert.Null(actualChatOptions!.ContinuationToken);
}

[Fact]
public async Task DoesNotCreateOrchestrateToolsSpanWhenInvokeAgentIsParent()
[Theory]
Comment thread
stephentoub marked this conversation as resolved.
[InlineData("invoke_agent")]
[InlineData("invoke_agent my_agent")]
[InlineData("invoke_agent_extra")]
Comment thread
stephentoub marked this conversation as resolved.
Outdated
[InlineData("invoke_agent ")]
public async Task DoesNotCreateOrchestrateToolsSpanWhenInvokeAgentIsParent(string displayName)
{
string agentSourceName = Guid.NewGuid().ToString();
string clientSourceName = Guid.NewGuid().ToString();
Expand Down Expand Up @@ -1264,7 +1268,7 @@ public async Task DoesNotCreateOrchestrateToolsSpanWhenInvokeAgentIsParent()
.Build();

using (var agentSource = new ActivitySource(agentSourceName))
using (var invokeAgentActivity = agentSource.StartActivity("invoke_agent"))
using (var invokeAgentActivity = agentSource.StartActivity(displayName))
{
Assert.NotNull(invokeAgentActivity);
await InvokeAndAssertAsync(options, plan, configurePipeline: configure);
Expand All @@ -1274,7 +1278,7 @@ public async Task DoesNotCreateOrchestrateToolsSpanWhenInvokeAgentIsParent()
Assert.Contains(activities, a => a.DisplayName == "chat");
Assert.Contains(activities, a => a.DisplayName == "execute_tool Func1");

var invokeAgent = Assert.Single(activities, a => a.DisplayName == "invoke_agent");
var invokeAgent = Assert.Single(activities, a => a.DisplayName == displayName);
var childActivities = activities.Where(a => a != invokeAgent).ToList();
Assert.All(childActivities, activity => Assert.Same(invokeAgent, activity.Parent));
}
Comment thread
stephentoub marked this conversation as resolved.
Expand Down
Loading