Skip to content

.NET: OpenAI-compatible extra body field thinking is not forwarded when using Microsoft.Agents.AI.OpenAI #5708

@ssccinng

Description

@ssccinng

Summary

When using Microsoft.Agents.AI.OpenAI with an OpenAI-compatible backend (ARK), provider-specific body field thinking is not forwarded to the final outgoing payload.

Expected outgoing request should be:

curl https://ark.cn-beijing.volces.com/api/v3/responses \
  -H "Authorization: Bearer $ARK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "model": "doubao-seed-2-0-lite-260215",
      "input": "常见的十字花科植物有哪些?",
      "thinking":{"type": "enabled"},
      "stream": true
  }'

Minimal repro code

using System;
using System.ClientModel;
using System.Text.Json;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
using OpenAI;

var client = new OpenAIClient(
    new ApiKeyCredential(Environment.GetEnvironmentVariable("ARK_API_KEY")!),
    new OpenAIClientOptions { Endpoint = new Uri("http://127.0.0.1:24424") }); // local proxy

var chatClient = client.GetChatClient("doubao-seed-2-0-lite-260215");
var thinkingConfig = JsonDocument.Parse("{\"type\":\"enabled\"}").RootElement.Clone();

var chatOptions = new ChatOptions
{
    Instructions = "You are a helpful assistant",
    AdditionalProperties = new AdditionalPropertiesDictionary { ["thinking"] = thinkingConfig }
};

var agent = chatClient.AsAIAgent(new ChatClientAgentOptions { ChatOptions = chatOptions });

var runOptions = new AgentRunOptions
{
    AdditionalProperties = new AdditionalPropertiesDictionary { ["thinking"] = thinkingConfig }
};

var session = await agent.CreateSessionAsync();
await agent.RunAsync("常见的十字花科植物有哪些?", options: runOptions, session: session);

Actual

Intercepted outgoing JSON (via local proxy) contains standard fields (messages/model/temperature/reasoning_effort), but does not include thinking.

Expected

A supported way to pass through provider-specific extra body fields for OpenAI-compatible endpoints (for example an ExtraBody map or documented passthrough mechanism).

Question

Is this behavior by design, or a bug/feature gap?
If by design, what is the recommended way to send provider-specific request fields such as thinking?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions