From 1b7ce068b6671a82266762b0168d514334084cd5 Mon Sep 17 00:00:00 2001
From: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
Date: Fri, 25 Sep 2026 18:53:18 +0100
Subject: [PATCH] Temporarily skip OpenAI integration tests while the CI API
key is invalid
The CI OpenAI API key secrets are currently rejected (invalid_api_key,
no_organization, insufficient_quota), failing every scheduled and merge
queue run that exercises OpenAI.
Add a single skip-reason constant per language so the tests can be
re-enabled by setting it to null/None:
- .NET: TestSkipReasons.OpenAIIntegrationTests, applied to the OpenAI
chat completion and responses fixtures and the OpenAI hosting live tests.
- Python: OPENAI_INTEGRATION_TESTS_SKIP_REASON with an autouse fixture in
the OpenAI package tests conftest, skipping non-Azure integration tests.
---
.../IntegrationTests/TestSkipReasons.cs | 15 ++++++++++++++
...AIResponsesClientFunctionToolsLiveTests.cs | 2 +-
.../OpenAIResponsesHostingLiveTests.cs | 4 ++--
.../OpenAIChatCompletionFixture.cs | 7 ++++++-
.../OpenAIResponseFixture.cs | 3 +++
.../packages/openai/tests/openai/conftest.py | 20 ++++++++++++++++++-
6 files changed, 46 insertions(+), 5 deletions(-)
create mode 100644 dotnet/src/Shared/IntegrationTests/TestSkipReasons.cs
diff --git a/dotnet/src/Shared/IntegrationTests/TestSkipReasons.cs b/dotnet/src/Shared/IntegrationTests/TestSkipReasons.cs
new file mode 100644
index 00000000000..43f35458747
--- /dev/null
+++ b/dotnet/src/Shared/IntegrationTests/TestSkipReasons.cs
@@ -0,0 +1,15 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+namespace Shared.IntegrationTests;
+
+///
+/// Skip reasons used to temporarily disable integration tests whose backing service is unavailable in CI.
+///
+internal static class TestSkipReasons
+{
+ ///
+ /// Skips every OpenAI integration test while the CI OpenAI API key is rejected.
+ /// Set to to run the OpenAI integration tests again.
+ ///
+ public const string? OpenAIIntegrationTests = "OpenAI integration tests are temporarily disabled: the CI OpenAI API key is invalid.";
+}
diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.IntegrationTests/OpenAIResponsesClientFunctionToolsLiveTests.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.IntegrationTests/OpenAIResponsesClientFunctionToolsLiveTests.cs
index f948a7d85c6..6a9a38da960 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.IntegrationTests/OpenAIResponsesClientFunctionToolsLiveTests.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.IntegrationTests/OpenAIResponsesClientFunctionToolsLiveTests.cs
@@ -42,7 +42,7 @@ public sealed class OpenAIResponsesClientFunctionToolsLiveTests
private static string ModelName =>
Environment.GetEnvironmentVariable(TestSettings.OpenAIChatModelName) ?? "gpt-4o-mini";
- [Fact]
+ [Fact(Skip = TestSkipReasons.OpenAIIntegrationTests)]
public async Task AllowedClientFunction_ReturnsFunctionCallAsync()
{
// Arrange
diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.IntegrationTests/OpenAIResponsesHostingLiveTests.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.IntegrationTests/OpenAIResponsesHostingLiveTests.cs
index 8452802ae93..fbc9db2a04f 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.IntegrationTests/OpenAIResponsesHostingLiveTests.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.IntegrationTests/OpenAIResponsesHostingLiveTests.cs
@@ -26,7 +26,7 @@ public sealed class OpenAIResponsesHostingLiveTests
private static string? ApiKey => Environment.GetEnvironmentVariable(TestSettings.OpenAIApiKey);
private static string ModelName => Environment.GetEnvironmentVariable(TestSettings.OpenAIChatModelName) ?? "gpt-4o-mini";
- [Fact]
+ [Fact(Skip = TestSkipReasons.OpenAIIntegrationTests)]
public async Task NonStreamingRun_RendersResponsesShapedPayloadAsync()
{
// Arrange
@@ -49,7 +49,7 @@ public async Task NonStreamingRun_RendersResponsesShapedPayloadAsync()
Assert.Contains("output", payload.EnumerateObject().Select(p => p.Name));
}
- [Fact]
+ [Fact(Skip = TestSkipReasons.OpenAIIntegrationTests)]
public async Task MultiTurn_ContinuesSessionAcrossTurnsAsync()
{
// Arrange
diff --git a/dotnet/tests/OpenAIChatCompletion.IntegrationTests/OpenAIChatCompletionFixture.cs b/dotnet/tests/OpenAIChatCompletion.IntegrationTests/OpenAIChatCompletionFixture.cs
index 4e3bd7e3b0d..add955b414d 100644
--- a/dotnet/tests/OpenAIChatCompletion.IntegrationTests/OpenAIChatCompletionFixture.cs
+++ b/dotnet/tests/OpenAIChatCompletion.IntegrationTests/OpenAIChatCompletionFixture.cs
@@ -64,8 +64,13 @@ public Task DeleteSessionAsync(AgentSession session) =>
// Chat Completion does not require/support deleting threads, so this is a no-op.
Task.CompletedTask;
- public async ValueTask InitializeAsync() =>
+ public async ValueTask InitializeAsync()
+ {
+ // Skipping here covers every conformance test in this project, because each test initializes this fixture first.
+ Assert.SkipWhen(!string.IsNullOrEmpty(TestSkipReasons.OpenAIIntegrationTests), TestSkipReasons.OpenAIIntegrationTests ?? string.Empty);
+
this._agent = await this.CreateChatClientAgentAsync();
+ }
public ValueTask DisposeAsync()
{
diff --git a/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponseFixture.cs b/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponseFixture.cs
index 20f79d0ad1a..695a8707886 100644
--- a/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponseFixture.cs
+++ b/dotnet/tests/OpenAIResponse.IntegrationTests/OpenAIResponseFixture.cs
@@ -97,6 +97,9 @@ public Task DeleteSessionAsync(AgentSession session) =>
public async ValueTask InitializeAsync()
{
+ // Skipping here covers every conformance test in this project, because each test initializes this fixture first.
+ Assert.SkipWhen(!string.IsNullOrEmpty(TestSkipReasons.OpenAIIntegrationTests), TestSkipReasons.OpenAIIntegrationTests ?? string.Empty);
+
this._modelName = TestConfiguration.GetRequiredValue(TestSettings.OpenAIChatModelName);
this._openAIResponseClient = new OpenAIClient(TestConfiguration.GetRequiredValue(TestSettings.OpenAIApiKey))
.GetResponsesClient();
diff --git a/python/packages/openai/tests/openai/conftest.py b/python/packages/openai/tests/openai/conftest.py
index dc95fa9e5b5..8f97be47c38 100644
--- a/python/packages/openai/tests/openai/conftest.py
+++ b/python/packages/openai/tests/openai/conftest.py
@@ -6,7 +6,25 @@
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, SpanExporter
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
-from pytest import fixture
+from pytest import FixtureRequest, fixture, skip
+
+# Temporarily skips every OpenAI integration test while the CI OpenAI API key is rejected.
+# Set to None to run the OpenAI integration tests again.
+OPENAI_INTEGRATION_TESTS_SKIP_REASON: str | None = (
+ "OpenAI integration tests are temporarily disabled: the CI OpenAI API key is invalid."
+)
+
+
+@fixture(autouse=True)
+def _skip_openai_integration_tests(request: FixtureRequest) -> None:
+ """Skip OpenAI integration tests while OPENAI_INTEGRATION_TESTS_SKIP_REASON is set."""
+ # Azure-marked tests use Azure OpenAI credentials, not the broken OpenAI key, and have their own skip switch.
+ if (
+ OPENAI_INTEGRATION_TESTS_SKIP_REASON
+ and request.node.get_closest_marker("integration") is not None
+ and request.node.get_closest_marker("azure") is None
+ ):
+ skip(OPENAI_INTEGRATION_TESTS_SKIP_REASON)
def _reset_env(monkeypatch, env_names: list[str]) -> None: # type: ignore