Repository navigation
.NET: [Bug]: Hosted agents exposed via the Responses API ignore tools defined in the request body #6416
Description
Description
An agent mapped to a Responses API endpoint with app.MapOpenAIResponses(agent) never produces a function call for tools defined in the request body, even when the request includes those tools and sets tool_choice: "required".
Minimal reproduction
Register and map an agent:
// Program.cs
builder.AddOpenAIResponses();
IChatClient chatClient = new OpenAIClient(apiKey).GetChatClient(modelId).AsIChatClient();
var agent = builder.AddAIAgent("openai-agent-from-chat-client", instructions: null, chatClient: chatClient);
var app = builder.Build();
app.MapOpenAIResponses(agent);Call the Responses endpoint with a tool and tool_choice: "required":
curl --location 'https://localhost:7205/openai-agent-from-chat-client/v1/responses' \
--header 'Content-Type: application/json' \
--data '{
"stream": false,
"input": [
{ "role": "user", "content": "What'\''s the current weather in Valencia? Use celsius and the get_weather tool" }
],
"tools": [
{
"type": "function",
"name": "get_weather",
"description": "Retrieves current weather for the given location.",
"parameters": {
"type": "object",
"properties": {
"location": { "type": "string", "description": "City and country e.g. Bogotá, Colombia" },
"units": { "type": "string", "enum": ["celsius", "fahrenheit"], "description": "Units the temperature will be returned in." }
},
"required": ["location", "units"],
"additionalProperties": false
},
"strict": true
}
],
"tool_choice": "required"
}'Expected behavior
The agent requests the get_weather function call (the response contains a function call item).
Actual behavior
No function call is ever emitted. The response is a plain text answer and the tools / tool_choice from the request appear to be ignored.
E.g:
"output": [
{
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Calling weather tool for Valencia, Celsius.\nI'm unable to call the weather tool in this environment right now.\n\nIf you'd like, I can:\n- show you how to check Valencia weather in Celsius quickly, or\n- help interpret a weather report if you paste it here.",
"annotations": [],
"logprobs": []
}
],
"type": "message",
"status": "completed",
"id": "msg_U3lQzbV6GbpqKgnwoCZEst4H9qwPv6PQEZdZBn8e19GoRHM3"
}
],Environment
- OS: Windows 11 (x64)
- .NET 10
Reproduce using the following versions in 2 separate tests:
| Package | Test A | Test B |
|---|---|---|
Microsoft.Agents.AI |
1.9.0 | 1.6.1 |
Microsoft.Agents.AI.OpenAI |
1.9.0 | 1.6.1 |
Microsoft.Agents.AI.Hosting.OpenAI |
1.9.0-alpha.260603.1 | 1.7.0-alpha.260526.1 |
Code Sample
Error Messages / Stack Traces
Package Versions
Microsoft.Agents.AI: 1.9.0, Microsoft.Agents.AI.OpenAI: 1.9.0, Microsoft.Agents.AI.Hosting.OpenAI: 1.9.0-alpha.260603.1
.NET Version
.NET 10
Additional Context
The same request body sent directly to OpenAI (https://api.openai.com/v1/responses) does return a function_call:
"output": [
{
"id": "fc_0a6aa1d6b09e8366006a28014c4e6c8191bd92c7a54b751d16",
"type": "function_call",
"status": "completed",
"arguments": "{\"location\":\"Valencia, Spain\",\"units\":\"celsius\"}",
"call_id": "call_sPjLPnyYIgwhyl6fXZRROIGH",
"name": "get_weather"
}
]Also, I tried this using the same agent mapped to a Chat Completions endpoint with app.MapOpenAIChatCompletions(agent) and it does use tools defined in the request body (using an equivalent request adapted for chat completions).
I also observed that the AIAgentResponseExecutor (
agent-framework/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/AIAgentResponseExecutor.cs
Line 38 in 96d242f
| var chatOptions = new ChatOptions |
ChatOptions object that's later used to run the agent. Not sure if that's the only thing causing this issue, but I'd be happy to try and send a PR!
Reference repo with the full reproduction: https://github.com/pawap90/AgentFramework.Hosting.OpenAI.Tests
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
XiongHaoTrigger commentedon Jun 10, 2026
Paula Santamaría (@pawap90)
There is no mapping of "Tools" and "ToolChoice" in the file
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/AIAgentResponseExecutor.csanddotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/HostedAgentResponseExecutor.csI also attempted to fix these two areas.
In
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/AIAgentResponseExecutor.csIn
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/HostedAgentResponseExecutor.csThe new extension method
alliscode commentedon Jun 15, 2026
Hi Paula Santamaría (@pawap90), Hao Xiong (@XiongHaoTrigger) thank you for filing this.
Can you help me understand the scenario that you have where you want to enable client-side tools?
In general, a deployed Hosted Agent is a black box to clients, they don't know what model or even what provider the Hosted Agent is using internally. I can think of many cases in which passing through things like
model-id,temperature.tool-definitionsetc. from the client would not be desired or even functional. It would be helpful to understand the end-to-end scenario you are trying to solve for.XiongHaoTrigger commentedon Jun 16, 2026
Ben Thomas (@alliscode) Currently, my codebase does not actually have this business requirement. I just happened to come across this issue and checked the source code, and it seems that this value is not being passed through at the moment.
However, I am currently building an agent-centric testing framework, where the agent will invoke tools that control external hardware devices. In this scenario, I believe it is necessary for the client to be able to restrict tool invocation through configuration, such as
tool_choice.That said, I have not implemented this part yet. Alternatively, to follow the current framework design principles, I may need to keep tool invocation restrictions inside the hosting implementation.
pawap90 commentedon Jun 16, 2026
Ben Thomas (@alliscode)
Thanks for following up! Happy to give you the full picture.
Our platform allows users to configure their own AI agents through a low-code approach, and invoke them via our API. We support a set of server-side tools for the Agents. However, that set is necessarily limited and isolated from the client systems, so clients often ask to plug in client-side tools so their agents can interact with their own systems (website, database, internal APIs).
The hosted agents in Agent Framework were one of our top reasons for migrating over from Semantic Kernel. We're working on wrapping our agents into MAF AIAgents so we can expose them as Hosted Agents through OpenAI-compatible endpoints and AG-UI.
For clients who aren't looking to adopt AG-UI, this feature would be a great alternative. It lets them supply tools that are already integrated with their own systems, while the OpenAI-compatible endpoints are well known and easy to integrate into what they already have.
It seems like AIAgents (both MAF's hosted agents and ours) could let the client choose to enable client-side tools, so they stay in control.