mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cc5ff771b | ||
|
|
0269529ccf | ||
|
|
e514fc8837 | ||
|
|
049e823177 | ||
|
|
c4f9d0d4cf | ||
|
|
1929f73959 | ||
|
|
1b0fbb808e | ||
|
|
c799c61ff1 | ||
|
|
158ecb7b40 | ||
|
|
3c8fdb6f49 | ||
|
|
5ec3bcf390 | ||
|
|
9ce21a2a2f | ||
|
|
2a55b35176 | ||
|
|
08dcf74cf4 |
@@ -163,22 +163,10 @@ app.MapA2AHttpJson(knightsKnavesAgentBuilder, path: "/a2a/knights-and-knaves");
|
||||
app.MapDevUI();
|
||||
|
||||
app.MapOpenAIResponses();
|
||||
app.MapOpenAIResponses(pirateAgentBuilder);
|
||||
app.MapOpenAIResponses(knightsKnavesAgentBuilder);
|
||||
app.MapOpenAIResponses(chemistryAgent);
|
||||
app.MapOpenAIResponses(mathsAgent);
|
||||
app.MapOpenAIResponses(literatureAgent);
|
||||
app.MapOpenAIResponses(scienceSequentialWorkflow);
|
||||
app.MapOpenAIResponses(scienceConcurrentWorkflow);
|
||||
app.MapOpenAIConversations();
|
||||
|
||||
app.MapOpenAIChatCompletions(pirateAgentBuilder);
|
||||
app.MapOpenAIChatCompletions(knightsKnavesAgentBuilder);
|
||||
app.MapOpenAIChatCompletions(chemistryAgent);
|
||||
app.MapOpenAIChatCompletions(mathsAgent);
|
||||
app.MapOpenAIChatCompletions(literatureAgent);
|
||||
app.MapOpenAIChatCompletions(scienceSequentialWorkflow);
|
||||
app.MapOpenAIChatCompletions(scienceConcurrentWorkflow);
|
||||
|
||||
// Map the agents HTTP endpoints
|
||||
app.MapAgentDiscovery("/agents");
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ internal sealed class OpenAIChatCompletionsAgentClient(HttpClient httpClient) :
|
||||
{
|
||||
OpenAIClientOptions options = new()
|
||||
{
|
||||
Endpoint = new Uri(httpClient.BaseAddress!, $"/{Uri.EscapeDataString(agentName)}/v1/"),
|
||||
Endpoint = new Uri(httpClient.BaseAddress!, $"/{agentName}/v1/"),
|
||||
Transport = new HttpClientPipelineTransport(httpClient)
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ internal sealed class OpenAIResponsesAgentClient(HttpClient httpClient) : AgentC
|
||||
{
|
||||
OpenAIClientOptions options = new()
|
||||
{
|
||||
Endpoint = new Uri(httpClient.BaseAddress!, $"/{Uri.EscapeDataString(agentName)}/v1/"),
|
||||
Endpoint = new Uri(httpClient.BaseAddress!, "/v1/"),
|
||||
Transport = new HttpClientPipelineTransport(httpClient)
|
||||
};
|
||||
|
||||
|
||||
@@ -47,10 +47,7 @@ internal sealed class DevUIAuthFilter : IEndpointFilter
|
||||
{
|
||||
var httpContext = context.HttpContext;
|
||||
var remoteIp = httpContext.Connection.RemoteIpAddress;
|
||||
|
||||
// A null RemoteIpAddress means the connection is in-process (e.g., an ASP.NET Core
|
||||
// TestServer created via UseTestServer()), so treat it as loopback.
|
||||
var isLoopback = remoteIp is null || IPAddress.IsLoopback(remoteIp);
|
||||
var isLoopback = remoteIp is not null && IPAddress.IsLoopback(remoteIp);
|
||||
|
||||
if (!isLoopback && !this._options.AllowRemoteAccess)
|
||||
{
|
||||
|
||||
+1
-37
@@ -267,43 +267,7 @@ public sealed class OpenAIResponsesAgentResolutionIntegrationTests : IAsyncDispo
|
||||
Assert.Equal(System.Net.HttpStatusCode.BadRequest, httpResponse.StatusCode);
|
||||
|
||||
string responseJson = await httpResponse.Content.ReadAsStringAsync();
|
||||
using JsonDocument errorDoc1 = JsonDocument.Parse(responseJson);
|
||||
string? errorCode = errorDoc1.RootElement.GetProperty("error").GetProperty("code").GetString();
|
||||
Assert.Equal("missing_required_parameter", errorCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the model field alone is not used for agent resolution.
|
||||
/// The multi-agent endpoint requires agent.name or metadata.entity_id; setting only model returns 400.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task CreateResponse_WithModelOnly_ReturnsBadRequestAsync()
|
||||
{
|
||||
// Arrange
|
||||
const string AgentName = "test-agent";
|
||||
|
||||
this._httpClient = await this.CreateTestServerWithAgentResolutionAsync(
|
||||
(AgentName, "Instructions", "Response"));
|
||||
|
||||
// Act - Send request with model=agentName but no agent.name or metadata.entity_id
|
||||
using StringContent requestContent = new(JsonSerializer.Serialize(new
|
||||
{
|
||||
model = AgentName,
|
||||
input = new[]
|
||||
{
|
||||
new { type = "message", role = "user", content = "Test message" }
|
||||
}
|
||||
}), Encoding.UTF8, "application/json");
|
||||
|
||||
using HttpResponseMessage httpResponse = await this._httpClient!.PostAsync(new Uri("/v1/responses", UriKind.Relative), requestContent);
|
||||
|
||||
// Assert - model is not used for agent resolution
|
||||
Assert.Equal(System.Net.HttpStatusCode.BadRequest, httpResponse.StatusCode);
|
||||
|
||||
string responseJson = await httpResponse.Content.ReadAsStringAsync();
|
||||
using JsonDocument errorDoc2 = JsonDocument.Parse(responseJson);
|
||||
string? errorCode = errorDoc2.RootElement.GetProperty("error").GetProperty("code").GetString();
|
||||
Assert.Equal("missing_required_parameter", errorCode);
|
||||
Assert.Contains("agent.name", responseJson, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user