From 9218acfac1c0d763e85ae1a63dce4c7b8d81c8c5 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 2 Dec 2025 16:53:35 +0000
Subject: [PATCH 1/5] Initial plan
From fb9ca3e29dba7d063d3f1f7e18b09ae908be6185 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 2 Dec 2025 17:05:03 +0000
Subject: [PATCH 2/5] Add vector store indexing wait helpers to fix flaky tests
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
---
.../AzureAIAgentsPersistentCreateTests.cs | 44 ++++++++++++++++++
.../OpenAIAssistantClientExtensionsTests.cs | 45 +++++++++++++++++++
2 files changed, 89 insertions(+)
diff --git a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
index e3e9969a43..e486c3310d 100644
--- a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
+++ b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
+using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using AgentConformance.IntegrationTests.Support;
@@ -104,6 +105,9 @@ You are a helpful agent that can help fetch data from files you know about.
);
var vectorStoreMetadata = await this._persistentAgentsClient.VectorStores.CreateVectorStoreAsync([uploadedAgentFile.Id], name: "WordCodeLookup_VectorStore");
+ // Wait for vector store indexing to complete before using it
+ await this.WaitForVectorStoreReadyAsync(this._persistentAgentsClient, vectorStoreMetadata.Value.Id);
+
// Act.
var agent = createMechanism switch
{
@@ -259,4 +263,44 @@ public async Task CreateAgent_CreatesAgentWithAIFunctionToolsAsync(string create
await this._persistentAgentsClient.Administration.DeleteAgentAsync(agent.Id);
}
}
+
+ ///
+ /// Waits for a vector store to complete indexing by polling its status.
+ ///
+ /// The persistent agents client.
+ /// The ID of the vector store.
+ /// Maximum time to wait in seconds (default: 30).
+ /// A task that completes when the vector store is ready or throws on timeout/failure.
+ private async Task WaitForVectorStoreReadyAsync(
+ PersistentAgentsClient client,
+ string vectorStoreId,
+ int maxWaitSeconds = 30)
+ {
+ Stopwatch sw = Stopwatch.StartNew();
+ while (sw.Elapsed.TotalSeconds < maxWaitSeconds)
+ {
+ PersistentAgentsVectorStore vectorStore = await client.VectorStores.GetVectorStoreAsync(vectorStoreId);
+ string status = vectorStore.Status.ToString();
+
+ if (status.Equals("Completed", StringComparison.OrdinalIgnoreCase))
+ {
+ // Check if any files failed during indexing
+ if (vectorStore.FileCounts.Failed > 0)
+ {
+ throw new InvalidOperationException("Vector store indexing failed for some files");
+ }
+
+ return; // ✅ Ready!
+ }
+
+ if (status.Equals("Expired", StringComparison.OrdinalIgnoreCase))
+ {
+ throw new InvalidOperationException("Vector store has expired");
+ }
+
+ await Task.Delay(1000); // Poll every second
+ }
+
+ throw new TimeoutException($"Vector store did not complete indexing within {maxWaitSeconds}s");
+ }
}
diff --git a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
index 0bd084951d..151608a49b 100644
--- a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
+++ b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
+using System.ClientModel;
+using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using AgentConformance.IntegrationTests.Support;
@@ -153,6 +155,9 @@ You are a helpful agent that can help fetch data from files you know about.
});
string vectorStoreId = vectorStoreCreate.Value.Id;
+ // Wait for vector store indexing to complete before using it
+ await WaitForVectorStoreReadyAsync(vectorStoreClient, vectorStoreId);
+
var fileSearchTool = new HostedFileSearchTool() { Inputs = [new HostedVectorStoreContent(vectorStoreId)] };
var agent = createMechanism switch
@@ -189,4 +194,44 @@ You are a helpful agent that can help fetch data from files you know about.
File.Delete(searchFilePath);
}
}
+
+ ///
+ /// Waits for a vector store to complete indexing by polling its status.
+ ///
+ /// The vector store client.
+ /// The ID of the vector store.
+ /// Maximum time to wait in seconds (default: 30).
+ /// A task that completes when the vector store is ready or throws on timeout/failure.
+ private static async Task WaitForVectorStoreReadyAsync(
+ VectorStoreClient client,
+ string vectorStoreId,
+ int maxWaitSeconds = 30)
+ {
+ Stopwatch sw = Stopwatch.StartNew();
+ while (sw.Elapsed.TotalSeconds < maxWaitSeconds)
+ {
+ VectorStore vectorStore = await client.GetVectorStoreAsync(vectorStoreId);
+ VectorStoreStatus status = vectorStore.Status;
+
+ if (status == VectorStoreStatus.Completed)
+ {
+ // Check if any files failed during indexing
+ if (vectorStore.FileCounts.Failed > 0)
+ {
+ throw new InvalidOperationException("Vector store indexing failed for some files");
+ }
+
+ return; // ✅ Ready!
+ }
+
+ if (status == VectorStoreStatus.Expired)
+ {
+ throw new InvalidOperationException("Vector store has expired");
+ }
+
+ await Task.Delay(1000); // Poll every second
+ }
+
+ throw new TimeoutException($"Vector store did not complete indexing within {maxWaitSeconds}s");
+ }
}
From cee714607ed111ced5098dfc19cac2125f222130 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 2 Dec 2025 17:08:20 +0000
Subject: [PATCH 3/5] Use proper VectorStoreStatus struct comparison in Azure
tests
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
---
.../AzureAIAgentsPersistentCreateTests.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
index e486c3310d..0803f48d98 100644
--- a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
+++ b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
@@ -280,9 +280,9 @@ private async Task WaitForVectorStoreReadyAsync(
while (sw.Elapsed.TotalSeconds < maxWaitSeconds)
{
PersistentAgentsVectorStore vectorStore = await client.VectorStores.GetVectorStoreAsync(vectorStoreId);
- string status = vectorStore.Status.ToString();
+ VectorStoreStatus status = vectorStore.Status;
- if (status.Equals("Completed", StringComparison.OrdinalIgnoreCase))
+ if (status == VectorStoreStatus.Completed)
{
// Check if any files failed during indexing
if (vectorStore.FileCounts.Failed > 0)
@@ -293,7 +293,7 @@ private async Task WaitForVectorStoreReadyAsync(
return; // ✅ Ready!
}
- if (status.Equals("Expired", StringComparison.OrdinalIgnoreCase))
+ if (status == VectorStoreStatus.Expired)
{
throw new InvalidOperationException("Vector store has expired");
}
From f255011378a84f949afbd7c860cc154c44575d36 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 2 Dec 2025 17:09:45 +0000
Subject: [PATCH 4/5] Remove unused System.ClientModel import
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
---
.../OpenAIAssistantClientExtensionsTests.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
index 151608a49b..a342a2a70e 100644
--- a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
+++ b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
-using System.ClientModel;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
From 45501c35a2746d35bfb8acfe25d778a2c9e2c67d Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 3 Dec 2025 13:12:13 +0000
Subject: [PATCH 5/5] Remove excessive comments and unnecessary status variable
per code review
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
---
.../AzureAIAgentsPersistentCreateTests.cs | 10 ++++------
.../OpenAIAssistantClientExtensionsTests.cs | 5 ++---
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
index 0803f48d98..a61062e411 100644
--- a/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
+++ b/dotnet/tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistentCreateTests.cs
@@ -280,25 +280,23 @@ private async Task WaitForVectorStoreReadyAsync(
while (sw.Elapsed.TotalSeconds < maxWaitSeconds)
{
PersistentAgentsVectorStore vectorStore = await client.VectorStores.GetVectorStoreAsync(vectorStoreId);
- VectorStoreStatus status = vectorStore.Status;
- if (status == VectorStoreStatus.Completed)
+ if (vectorStore.Status == VectorStoreStatus.Completed)
{
- // Check if any files failed during indexing
if (vectorStore.FileCounts.Failed > 0)
{
throw new InvalidOperationException("Vector store indexing failed for some files");
}
- return; // ✅ Ready!
+ return;
}
- if (status == VectorStoreStatus.Expired)
+ if (vectorStore.Status == VectorStoreStatus.Expired)
{
throw new InvalidOperationException("Vector store has expired");
}
- await Task.Delay(1000); // Poll every second
+ await Task.Delay(1000);
}
throw new TimeoutException($"Vector store did not complete indexing within {maxWaitSeconds}s");
diff --git a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
index a342a2a70e..74eb2a11d5 100644
--- a/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
+++ b/dotnet/tests/OpenAIAssistant.IntegrationTests/OpenAIAssistantClientExtensionsTests.cs
@@ -214,13 +214,12 @@ private static async Task WaitForVectorStoreReadyAsync(
if (status == VectorStoreStatus.Completed)
{
- // Check if any files failed during indexing
if (vectorStore.FileCounts.Failed > 0)
{
throw new InvalidOperationException("Vector store indexing failed for some files");
}
- return; // ✅ Ready!
+ return;
}
if (status == VectorStoreStatus.Expired)
@@ -228,7 +227,7 @@ private static async Task WaitForVectorStoreReadyAsync(
throw new InvalidOperationException("Vector store has expired");
}
- await Task.Delay(1000); // Poll every second
+ await Task.Delay(1000);
}
throw new TimeoutException($"Vector store did not complete indexing within {maxWaitSeconds}s");