chore: import upstream snapshot with attribution
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=agent-skills</c> mode.
|
||||
/// The container creates two Contoso Outdoors skills (support-style, escalation-policy) on disk
|
||||
/// and wires them into <see cref="Microsoft.Agents.AI.AgentSkillsProvider"/> so the model can
|
||||
/// discover and load skills via the progressive disclosure pattern.
|
||||
/// </summary>
|
||||
public sealed class AgentSkillsHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "agent-skills";
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using AgentConformance.IntegrationTests.Support;
|
||||
using Shared.IntegrationTests;
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=azure-search-rag</c> mode.
|
||||
/// Wires the container up with an Azure AI Search backed <see cref="Microsoft.Agents.AI.TextSearchProvider"/>
|
||||
/// adapter that retrieves Contoso Outdoors documents from a pre-provisioned search index before each
|
||||
/// model invocation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Prerequisites managed out of band:
|
||||
/// <list type="bullet">
|
||||
/// <item><description>The <c>it-azure-search-rag</c> agent's managed identity must hold
|
||||
/// <c>Search Index Data Reader</c> on the search service scope. Granted manually after
|
||||
/// the first <c>scripts/it-bootstrap-agents.ps1</c> run; see the IT README.</description></item>
|
||||
/// <item><description>The search index referenced by <c>AZURE_SEARCH_INDEX_NAME</c> must
|
||||
/// already exist with the documented schema and Contoso Outdoors content. The search
|
||||
/// service is shared with <c>python-sample-validation.yml</c>; no .NET-side provisioning
|
||||
/// script ships with this repository.</description></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public sealed class AzureSearchRagHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "azure-search-rag";
|
||||
|
||||
/// <summary>
|
||||
/// Inject the AZURE_SEARCH_* env vars onto the hosted agent definition so the test container
|
||||
/// scenario branch can construct its <c>SearchClient</c>. These names are NOT in the platform
|
||||
/// reserved <c>FOUNDRY_*</c> / <c>AGENT_*</c> namespace so they are safe to set.
|
||||
/// </summary>
|
||||
protected override void ConfigureEnvironment(IDictionary<string, string> environment)
|
||||
{
|
||||
environment[TestSettings.AzureSearchEndpoint] = TestConfiguration.GetRequiredValue(TestSettings.AzureSearchEndpoint);
|
||||
environment[TestSettings.AzureSearchIndexName] = TestConfiguration.GetRequiredValue(TestSettings.AzureSearchIndexName);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=custom-storage</c> mode.
|
||||
/// The container substitutes the default Responses storage provider with a custom in memory
|
||||
/// implementation so tests can verify that conversation history is read from and written to
|
||||
/// the custom store rather than the platform default.
|
||||
/// </summary>
|
||||
public sealed class CustomStorageHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "custom-storage";
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=happy-path</c> mode.
|
||||
/// Used by tests that exercise the basic Responses protocol round trip, multi turn behavior
|
||||
/// (via <c>previous_response_id</c> and <c>conversation_id</c>), and the <c>stored=false</c> flag.
|
||||
/// </summary>
|
||||
public sealed class HappyPathHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "happy-path";
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AgentConformance.IntegrationTests.Support;
|
||||
using Azure.AI.Extensions.OpenAI;
|
||||
using Azure.AI.Projects;
|
||||
using Azure.AI.Projects.Agents;
|
||||
using Microsoft.Agents.AI;
|
||||
using Microsoft.Extensions.AI;
|
||||
using Shared.IntegrationTests;
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Base fixture for Foundry Hosted Agent integration tests.
|
||||
///
|
||||
/// Each derived fixture represents one scenario (happy path, tool calling, toolbox, etc.) and
|
||||
/// targets a stable, scenario-keyed agent name (e.g. <c>it-happy-path</c>). The fixture creates
|
||||
/// a new <see cref="ProjectsAgentVersion"/> on each <see cref="InitializeAsync"/>, polls until
|
||||
/// active, patches the agent's endpoint to route 100% of traffic to that new version, then
|
||||
/// exposes the wrapped <see cref="AIAgent"/> for tests via <see cref="Agent"/>.
|
||||
///
|
||||
/// On <see cref="DisposeAsync"/> only the version created by this fixture is removed; the agent
|
||||
/// itself (and therefore its managed identity) is left in place. This is critical because the
|
||||
/// agent's managed identity must hold <c>Azure AI User</c> on the project scope to serve
|
||||
/// inbound inference traffic, and that role assignment is lost when the agent itself is deleted.
|
||||
///
|
||||
/// Prerequisite: each scenario agent (and its managed identity) must exist and have
|
||||
/// <c>Azure AI User</c> pre-granted on the project scope before the tests run. See
|
||||
/// <c>scripts/it-bootstrap-agents.ps1</c>.
|
||||
///
|
||||
/// The container image is the same for every scenario; the scenario itself is selected by
|
||||
/// the <c>IT_SCENARIO</c> environment variable in <see cref="HostedAgentDefinition.EnvironmentVariables"/>,
|
||||
/// configured by each derived fixture via <see cref="ScenarioName"/>.
|
||||
/// </summary>
|
||||
public abstract class HostedAgentFixture : IAsyncLifetime
|
||||
{
|
||||
private const string ScenarioEnvironmentVariable = "IT_SCENARIO";
|
||||
private const string RunIdEnvironmentVariable = "IT_RUN_ID";
|
||||
private const string ModelDeploymentEnvironmentVariable = "AZURE_AI_MODEL_DEPLOYMENT_NAME";
|
||||
private const string FoundryFeaturesHeader = "Foundry-Features";
|
||||
private const string HostedAgentsFeatureValue = "HostedAgents=V1Preview";
|
||||
private const string EnableVnextExperienceMetadataKey = "enableVnextExperience";
|
||||
|
||||
private AgentAdministrationClient _adminClient = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Scenario keyword passed to the container as <c>IT_SCENARIO</c>. Derived fixtures override.
|
||||
/// </summary>
|
||||
protected abstract string ScenarioName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// CPU request for the hosted agent container. Override per scenario if needed.
|
||||
/// </summary>
|
||||
protected virtual string Cpu => "0.25";
|
||||
|
||||
/// <summary>
|
||||
/// Memory request for the hosted agent container. Override per scenario if needed.
|
||||
/// </summary>
|
||||
protected virtual string Memory => "0.5Gi";
|
||||
|
||||
/// <summary>
|
||||
/// Maximum time to wait for <see cref="AgentVersionStatus.Active"/> after creation.
|
||||
/// </summary>
|
||||
protected virtual TimeSpan ProvisioningTimeout => TimeSpan.FromMinutes(5);
|
||||
|
||||
/// <summary>
|
||||
/// Container responses protocol version declared in <c>container_protocol_versions</c>. Defaults to
|
||||
/// <c>2.0.0</c> (the only version this image supports). The unsupported-protocol scenario overrides
|
||||
/// it to <c>1.0.0</c> to assert the container fails fast with a clear, actionable error.
|
||||
/// </summary>
|
||||
protected virtual string ResponsesProtocolVersion => "2.0.0";
|
||||
|
||||
/// <summary>
|
||||
/// The wrapped agent. Available after <see cref="InitializeAsync"/>.
|
||||
/// </summary>
|
||||
public AIAgent Agent { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The stable, scenario keyed agent name registered in Foundry (e.g. <c>it-happy-path</c>).
|
||||
/// The agent itself is provisioned out of band (see <c>scripts/it-bootstrap-agents.ps1</c>);
|
||||
/// each test run only adds and removes a version under it.
|
||||
/// </summary>
|
||||
public string AgentName { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The agent version assigned by Foundry on creation.
|
||||
/// </summary>
|
||||
public string AgentVersion { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The underlying <see cref="AIProjectClient"/>, useful for tests that need to talk
|
||||
/// to the conversations or responses APIs directly (e.g. to assert chain visibility).
|
||||
/// </summary>
|
||||
public AIProjectClient ProjectClient { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The per-agent <see cref="ProjectOpenAIClient"/> bound to this scenario's hosted agent endpoint
|
||||
/// (<c>/agents/{name}/endpoint/protocols/openai</c>). Stored hosted-agent responses are only
|
||||
/// readable through this per-agent client; the project-level responses client returns
|
||||
/// <c>session_not_accessible</c> (403). Use this to fetch a response by id.
|
||||
/// </summary>
|
||||
public ProjectOpenAIClient AgentOpenAIClient { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a server side conversation that tests can pass via <c>ChatOptions.ConversationId</c>
|
||||
/// to exercise multi turn flows backed by the Foundry conversations service.
|
||||
/// </summary>
|
||||
public async Task<string> CreateConversationAsync()
|
||||
{
|
||||
var response = await this.AgentOpenAIClient.GetProjectConversationsClient().CreateProjectConversationAsync().ConfigureAwait(false);
|
||||
return response.Value.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a previously created conversation. Used by tests in their cleanup blocks.
|
||||
/// </summary>
|
||||
public async Task DeleteConversationAsync(string conversationId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await this.AgentOpenAIClient.GetProjectConversationsClient().DeleteConversationAsync(conversationId).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Best effort cleanup mirroring DisposeAsync.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts items currently stored in a conversation. Used by tests verifying that a
|
||||
/// <c>stored=false</c> request did not append to the conversation.
|
||||
/// </summary>
|
||||
public async Task<int> CountConversationItemsAsync(string conversationId)
|
||||
{
|
||||
var count = 0;
|
||||
await foreach (var _ in this.AgentOpenAIClient.GetProjectConversationsClient().GetProjectConversationItemsAsync(conversationId, order: "asc").ConfigureAwait(false))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public async ValueTask InitializeAsync()
|
||||
{
|
||||
var endpoint = new Uri(TestConfiguration.GetRequiredValue(TestSettings.AzureAIProjectEndpoint));
|
||||
var image = TestConfiguration.GetRequiredValue(TestSettings.FoundryHostingItImage);
|
||||
|
||||
var credential = TestAzureCliCredentials.CreateAzureCliCredential();
|
||||
|
||||
var adminOptions = new AgentAdministrationClientOptions();
|
||||
adminOptions.AddPolicy(new FoundryFeaturesPolicy(HostedAgentsFeatureValue), PipelinePosition.PerCall);
|
||||
this._adminClient = new AgentAdministrationClient(endpoint, credential, adminOptions);
|
||||
this.ProjectClient = new AIProjectClient(endpoint, credential);
|
||||
|
||||
this.AgentName = $"it-{this.ScenarioName}";
|
||||
|
||||
var definition = new HostedAgentDefinition(cpu: this.Cpu, memory: this.Memory)
|
||||
{
|
||||
Image = image,
|
||||
};
|
||||
definition.Versions.Add(new ProtocolVersionRecord(ProjectsAgentProtocol.Responses, this.ResponsesProtocolVersion));
|
||||
definition.EnvironmentVariables[ScenarioEnvironmentVariable] = this.ScenarioName;
|
||||
// Forward the test-side model deployment to the container so it targets the same model the
|
||||
// tests expect. Without this the container falls back to its hard-coded default (gpt-4o),
|
||||
// which fails on projects that only deploy a different model.
|
||||
var modelDeployment = TestConfiguration.GetValue(TestSettings.AzureAIModelDeploymentName);
|
||||
if (!string.IsNullOrWhiteSpace(modelDeployment))
|
||||
{
|
||||
definition.EnvironmentVariables[ModelDeploymentEnvironmentVariable] = modelDeployment;
|
||||
}
|
||||
// Foundry deduplicates versions by content hash, so a fixture re-using the same
|
||||
// definition would just receive the bootstrap version and then delete it on dispose.
|
||||
// Adding a per-run env var forces a brand new version that the dispose can safely remove
|
||||
// without touching the bootstrap version (which keeps the agent alive across runs).
|
||||
definition.EnvironmentVariables[RunIdEnvironmentVariable] = Guid.NewGuid().ToString("N");
|
||||
|
||||
// Allow derived fixtures to layer additional environment variables before submission.
|
||||
this.ConfigureEnvironment(definition.EnvironmentVariables);
|
||||
|
||||
var creationOptions = new ProjectsAgentVersionCreationOptions(definition);
|
||||
creationOptions.Metadata[EnableVnextExperienceMetadataKey] = "true";
|
||||
|
||||
// Adds a new version under the (stable) agent name. Auto-creates the agent on first run.
|
||||
// The agent is intentionally never deleted because its managed identity must hold the
|
||||
// pre-granted role assignment for inbound inference to succeed (see class docs).
|
||||
var version = await this._adminClient.CreateAgentVersionAsync(this.AgentName, creationOptions).ConfigureAwait(false);
|
||||
var activeVersion = await WaitForActiveAsync(this._adminClient, version.Value, this.ProvisioningTimeout).ConfigureAwait(false);
|
||||
this.AgentVersion = activeVersion.Version;
|
||||
|
||||
// The agent endpoint must already be configured to route via @latest. The bootstrap
|
||||
// script (scripts/it-bootstrap-agents.ps1) does that one-time per agent. Each new
|
||||
// version we create automatically becomes the served one because @latest resolves
|
||||
// to the highest version number.
|
||||
//
|
||||
// Build a per-agent ProjectOpenAIClient (the cached projectClient.ProjectOpenAIClient is bound
|
||||
// to the project-level URL and cannot serve a hosted agent). AgentName on the options selects
|
||||
// the per-agent URL suffix `/agents/{name}/endpoint/protocols/openai`. The Foundry-Features
|
||||
// header is also required on the invocation pipeline (not just the admin one) for hosted agents.
|
||||
var openAIOptions = new ProjectOpenAIClientOptions { AgentName = this.AgentName };
|
||||
openAIOptions.AddPolicy(new FoundryFeaturesPolicy(HostedAgentsFeatureValue), PipelinePosition.PerCall);
|
||||
var openAIClient = new ProjectOpenAIClient(endpoint, credential, openAIOptions);
|
||||
this.AgentOpenAIClient = openAIClient;
|
||||
var responsesClient = openAIClient.GetProjectResponsesClient();
|
||||
|
||||
this.Agent = responsesClient.AsIChatClient().AsAIAgent(name: this.AgentName);
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
if (this._adminClient is null || this.AgentName is null || this.AgentVersion is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Delete only the version we created. The agent itself MUST stay so that its
|
||||
// managed identity (and the pre-granted Azure AI User role on it) survive across
|
||||
// test runs. If we delete the agent, Foundry mints a new MI on the next create
|
||||
// and inference fails with PermissionDenied until the role is regranted.
|
||||
await this._adminClient.DeleteAgentVersionAsync(this.AgentName, this.AgentVersion).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Best effort cleanup. Never throw from DisposeAsync because that would mask
|
||||
// the real test failure. Orphan versions accumulate harmlessly; a maintenance
|
||||
// script can prune them when needed.
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hook for derived fixtures to add scenario specific environment variables.
|
||||
/// Reserved names (anything matching <c>FOUNDRY_*</c> or <c>AGENT_*</c>) are forbidden by the platform.
|
||||
/// </summary>
|
||||
protected virtual void ConfigureEnvironment(IDictionary<string, string> environment)
|
||||
{
|
||||
}
|
||||
|
||||
private static async Task<ProjectsAgentVersion> WaitForActiveAsync(
|
||||
AgentAdministrationClient adminClient,
|
||||
ProjectsAgentVersion version,
|
||||
TimeSpan timeout)
|
||||
{
|
||||
var deadline = DateTimeOffset.UtcNow + timeout;
|
||||
while (version.Status != AgentVersionStatus.Active && version.Status != AgentVersionStatus.Failed)
|
||||
{
|
||||
if (DateTimeOffset.UtcNow > deadline)
|
||||
{
|
||||
throw new TimeoutException(
|
||||
$"Hosted agent '{version.Name}' version '{version.Version}' did not become Active within {timeout.TotalSeconds:F0}s. Last status: {version.Status}.");
|
||||
}
|
||||
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(500), CancellationToken.None).ConfigureAwait(false);
|
||||
version = (await adminClient.GetAgentVersionAsync(version.Name, version.Version).ConfigureAwait(false)).Value;
|
||||
}
|
||||
|
||||
if (version.Status != AgentVersionStatus.Active)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Hosted agent '{version.Name}' version '{version.Version}' failed to deploy. Status: {version.Status}.");
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pipeline policy that adds the Foundry feature header on every request.
|
||||
/// Required for hosted agent operations until the V1 preview flag is removed.
|
||||
/// </summary>
|
||||
private sealed class FoundryFeaturesPolicy(string features) : PipelinePolicy
|
||||
{
|
||||
public override void Process(PipelineMessage message, IReadOnlyList<PipelinePolicy> pipeline, int currentIndex)
|
||||
{
|
||||
this.SetHeader(message);
|
||||
ProcessNext(message, pipeline, currentIndex);
|
||||
}
|
||||
|
||||
public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList<PipelinePolicy> pipeline, int currentIndex)
|
||||
{
|
||||
this.SetHeader(message);
|
||||
await ProcessNextAsync(message, pipeline, currentIndex).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void SetHeader(PipelineMessage message)
|
||||
{
|
||||
// Set rather than Add to avoid duplicate headers if the pipeline reprocesses
|
||||
// the request (retries) or if multiple policies attempt to set the same key.
|
||||
message.Request.Headers.Remove(FoundryFeaturesHeader);
|
||||
message.Request.Headers.Add(FoundryFeaturesHeader, features);
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=store-config</c> mode.
|
||||
/// Used by <c>HostedResponsesStoreConfigTests</c> to exercise store/session semantics: <c>store=true</c>
|
||||
/// vs <c>store=false</c>, <c>previous_response_id</c> and <c>conversation_id</c> forks, and multi-turn
|
||||
/// recall. The container agent is a neutral assistant with no marker instruction so it never
|
||||
/// contaminates the content assertions.
|
||||
/// </summary>
|
||||
public sealed class HostedResponsesStoreConfigFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "store-config";
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=mcp-toolbox</c> mode.
|
||||
/// The container connects to a public MCP server (the Microsoft Learn MCP endpoint) so tests
|
||||
/// can verify MCP tool discovery and invocation flowing through the Foundry hosted agent.
|
||||
/// </summary>
|
||||
public sealed class McpToolboxHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "mcp-toolbox";
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=memory</c> mode.
|
||||
/// Used by tests that exercise <see cref="Microsoft.Agents.AI.Foundry.FoundryMemoryProvider"/>
|
||||
/// running inside the Foundry hosted agent. The memory store name is randomised per fixture
|
||||
/// instance so concurrent test runs do not share state.
|
||||
/// </summary>
|
||||
public sealed class MemoryHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "memory";
|
||||
|
||||
/// <summary>
|
||||
/// Memory store name passed to the test container via <c>IT_MEMORY_STORE_ID</c> so that each
|
||||
/// fixture instance gets a fresh, isolated bucket of memories.
|
||||
/// </summary>
|
||||
public string MemoryStoreId { get; } = $"it-memory-{Guid.NewGuid():N}";
|
||||
|
||||
protected override void ConfigureEnvironment(IDictionary<string, string> environment)
|
||||
{
|
||||
environment["IT_MEMORY_STORE_ID"] = this.MemoryStoreId;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=session-files</c> mode.
|
||||
/// The container exposes three local function tools (<c>GetHomeDirectory</c>, <c>ListFiles</c>,
|
||||
/// <c>ReadFile</c>) that read from the per-session <c>$HOME</c> sandbox volume — mirroring the
|
||||
/// <c>Hosted-Files</c> sample. Tests use the alpha
|
||||
/// <see cref="Azure.AI.Projects.Agents.AgentSessionFiles"/> API to upload a file into the session
|
||||
/// sandbox, then invoke the agent (pinned to the same <c>agent_session_id</c>) and assert that the
|
||||
/// agent's tools observed the uploaded file.
|
||||
/// </summary>
|
||||
public sealed class SessionFilesHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "session-files";
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=tool-calling-approval</c> mode.
|
||||
/// The container declares an AIFunction tagged <c>RequiresApproval=true</c> so tests can exercise
|
||||
/// the human in the loop approval flow (request, grant, deny).
|
||||
/// </summary>
|
||||
public sealed class ToolCallingApprovalHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "tool-calling-approval";
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=tool-calling</c> mode.
|
||||
/// The container declares one or more deterministic AIFunctions on the server side
|
||||
/// (e.g. <c>GetUtcNow</c>, <c>Multiply(int,int)</c>) so tests can verify tool invocation behavior
|
||||
/// without requiring approvals.
|
||||
/// </summary>
|
||||
public sealed class ToolCallingHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "tool-calling";
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=toolbox-oauth-consent</c>
|
||||
/// mode. The container pre-registers a Foundry toolbox (named by <c>IT_TOOLBOX_NAME</c>) whose tool
|
||||
/// source is fronted by a per-user OAuth connection. The first request that needs the tool must
|
||||
/// surface an <c>oauth_consent_request</c> instead of running it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Prerequisite (out of band, per project): a Foundry toolbox named by <see cref="ToolboxName"/> must
|
||||
/// exist in the target project and reference a tool source that returns <c>CONSENT_REQUIRED</c> for an
|
||||
/// unconsented user (for example a delegated GitHub or Microsoft Graph connection). Override the
|
||||
/// toolbox name with the <c>IT_TOOLBOX_NAME</c> environment variable. See the project README.
|
||||
/// </remarks>
|
||||
public sealed class ToolboxOAuthConsentHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
private const string ToolboxNameEnvironmentVariable = "IT_TOOLBOX_NAME";
|
||||
private const string DefaultToolboxName = "auth-paths-oauth-toolbox";
|
||||
|
||||
protected override string ScenarioName => "toolbox-oauth-consent";
|
||||
|
||||
/// <summary>
|
||||
/// The Foundry toolbox the container pre-registers. Resolved from <c>IT_TOOLBOX_NAME</c>, falling
|
||||
/// back to a default that exists in the reference project.
|
||||
/// </summary>
|
||||
public string ToolboxName { get; } =
|
||||
Environment.GetEnvironmentVariable(ToolboxNameEnvironmentVariable) ?? DefaultToolboxName;
|
||||
|
||||
protected override void ConfigureEnvironment(IDictionary<string, string> environment)
|
||||
{
|
||||
// Pass the toolbox name into the container so Program.cs wires AddFoundryToolboxes(credential, name).
|
||||
// IT_TOOLBOX_NAME is a non-reserved key (FOUNDRY_*/AGENT_* are forbidden by the platform).
|
||||
environment[ToolboxNameEnvironmentVariable] = this.ToolboxName;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
namespace Foundry.Hosting.IntegrationTests.Fixtures;
|
||||
|
||||
/// <summary>
|
||||
/// Provisions a dedicated <c>it-unsupported-protocol</c> agent under the legacy responses protocol
|
||||
/// <c>1.0.0</c> on purpose. The test container targets protocol <c>2.0.0</c> only, so a request served
|
||||
/// as <c>1.0.0</c> (no <c>x-agent-foundry-call-id</c> header) must fail fast with a clear <c>501</c>
|
||||
/// rather than an opaque 500. A dedicated agent name keeps this 1.0.0 deployment isolated from the
|
||||
/// 2.0.0 scenario agents (notably <c>it-happy-path</c>), whose <c>@latest</c> must stay 2.0.0.
|
||||
/// See <see cref="UnsupportedProtocolHostedAgentTests"/>.
|
||||
/// </summary>
|
||||
public sealed class UnsupportedProtocolHostedAgentFixture : HostedAgentFixture
|
||||
{
|
||||
protected override string ScenarioName => "unsupported-protocol";
|
||||
|
||||
protected override string ResponsesProtocolVersion => "1.0.0";
|
||||
}
|
||||
Reference in New Issue
Block a user