Skip to content
Open
Changes from all 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 @@ -110,6 +110,49 @@
Assert.Equal("conv_12345", chatClientSession.ConversationId);
}

/// <summary>
/// Verify that a newly created Azure AI session exposes a durable Foundry conversation ID rather than a response-chain ID after the first run.
/// </summary>
[Fact]
public async Task ChatClient_UsesFoundryConversationId_ForNewSessionsAsync()
{
// Arrange
var requestTriggered = false;
using var httpHandler = new HttpHandlerAssert(async (request) =>
{
if (request.Method == HttpMethod.Post && request.RequestUri!.PathAndQuery.Contains("/responses"))
{
requestTriggered = true;
return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(TestDataUtil.GetOpenAIDefaultResponseJson(), Encoding.UTF8, "application/json") };
}

return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(TestDataUtil.GetAgentResponseJson(), Encoding.UTF8, "application/json") };
});

#pragma warning disable CA5399
using var httpClient = new HttpClient(httpHandler);
#pragma warning restore CA5399

var client = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });

var agent = await client.GetAIAgentAsync(
new ChatClientAgentOptions
{
Name = "test-agent",
ChatOptions = new() { Instructions = "Test instructions" },
});

// Act
var session = await agent.CreateSessionAsync();
await agent.RunAsync("Hello", session);

// Assert
Assert.True(requestTriggered);
var chatClientSession = Assert.IsType<ChatClientAgentSession>(session);
var conversationId = Assert.NotNull(chatClientSession.ConversationId);

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net472, windows-latest, Release, true, integration)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net472, windows-latest, Release, true, integration)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net10.0, ubuntu-latest, Release, true, integration)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-test (net10.0, ubuntu-latest, Release, true, integration)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net472, windows-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net10.0, ubuntu-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net8.0, ubuntu-latest, Release)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

Cannot assign void to an implicitly-typed variable

Check failure on line 152 in dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs

View workflow job for this annotation

GitHub Actions / dotnet-build (net9.0, windows-latest, Debug)

Cannot assign void to an implicitly-typed variable
Assert.StartsWith("conv_", conversationId);
}

/// <summary>
/// Verify that even when the chat client has a default conversation id, the chat client will prioritize the per-request conversation id provided in HTTP requests.
/// </summary>
Expand Down
Loading