Python: add(azure-ai): support reasoning config for AzureAIClient (#3403)

* add(azure-ai): support reasoning config for AzureAIClient

* Update sample

* Merge main

* improvements

* improve sample
This commit is contained in:
Evan Mattson
2026-01-23 09:37:23 +00:00
committed by GitHub
parent a97bc322ac
commit 7b8777d1fc
5 changed files with 152 additions and 7 deletions
@@ -22,12 +22,7 @@ from agent_framework.observability import use_instrumentation
from agent_framework.openai import OpenAIResponsesOptions
from agent_framework.openai._responses_client import OpenAIBaseResponsesClient
from azure.ai.projects.aio import AIProjectClient
from azure.ai.projects.models import (
MCPTool,
PromptAgentDefinition,
PromptAgentDefinitionText,
RaiConfig,
)
from azure.ai.projects.models import MCPTool, PromptAgentDefinition, PromptAgentDefinitionText, RaiConfig, Reasoning
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.exceptions import ResourceNotFoundError
from pydantic import ValidationError
@@ -51,12 +46,15 @@ else:
logger = get_logger("agent_framework.azure")
class AzureAIProjectAgentOptions(OpenAIResponsesOptions):
class AzureAIProjectAgentOptions(OpenAIResponsesOptions, total=False):
"""Azure AI Project Agent options."""
rai_config: RaiConfig
"""Configuration for Responsible AI (RAI) content filtering and safety features."""
reasoning: Reasoning # type: ignore[misc]
"""Configuration for enabling reasoning capabilities (requires azure.ai.projects.models.Reasoning)."""
TAzureAIClientOptions = TypeVar(
"TAzureAIClientOptions",
@@ -343,6 +341,10 @@ class AzureAIClient(OpenAIBaseResponsesClient[TAzureAIClientOptions], Generic[TA
args["temperature"] = run_options["temperature"]
if "top_p" in run_options:
args["top_p"] = run_options["top_p"]
if "reasoning" in run_options:
args["reasoning"] = run_options["reasoning"]
if "rai_config" in run_options:
args["rai_config"] = run_options["rai_config"]
# response_format is accessed from chat_options or additional_properties
# since the base class excludes it from run_options
@@ -408,6 +410,7 @@ class AzureAIClient(OpenAIBaseResponsesClient[TAzureAIClientOptions], Generic[TA
"top_p",
"text",
"text_format",
"reasoning",
]
for property in exclude:
@@ -195,6 +195,7 @@ class AzureAIProjectAgentProvider(Generic[TOptions_co]):
opts = dict(default_options) if default_options else {}
response_format = opts.get("response_format")
rai_config = opts.get("rai_config")
reasoning = opts.get("reasoning")
args: dict[str, Any] = {"model": resolved_model}
@@ -206,6 +207,8 @@ class AzureAIProjectAgentProvider(Generic[TOptions_co]):
)
if rai_config:
args["rai_config"] = rai_config
if reasoning:
args["reasoning"] = reasoning
# Normalize tools and separate MCP tools from other tools
normalized_tools = normalize_tools(tools)