Added additional arguments for Azure AI agent (#2922)

This commit is contained in:
Dmytro Struk
2025-12-17 00:08:01 -08:00
committed by GitHub
Unverified
parent c7ddb8aa14
commit 3cd805f0bf
2 changed files with 29 additions and 1 deletions
@@ -335,6 +335,10 @@ class AzureAIClient(OpenAIBaseResponsesClient):
if "tools" in run_options:
args["tools"] = run_options["tools"]
if "temperature" in run_options:
args["temperature"] = run_options["temperature"]
if "top_p" in run_options:
args["top_p"] = run_options["top_p"]
if "response_format" in run_options:
response_format = run_options["response_format"]
@@ -413,7 +417,7 @@ class AzureAIClient(OpenAIBaseResponsesClient):
# Remove properties that are not supported on request level
# but were configured on agent level
exclude = ["model", "tools", "response_format"]
exclude = ["model", "tools", "response_format", "temperature", "top_p"]
for property in exclude:
run_options.pop(property, None)
@@ -477,6 +477,30 @@ async def test_azure_ai_client_agent_creation_with_instructions(
assert call_args[1]["definition"].instructions == "Message instructions. Option instructions. "
async def test_azure_ai_client_agent_creation_with_additional_args(
mock_project_client: MagicMock,
) -> None:
"""Test agent creation with additional arguments."""
client = create_test_azure_ai_client(mock_project_client, agent_name="test-agent")
# Mock agent creation response
mock_agent = MagicMock()
mock_agent.name = "test-agent"
mock_agent.version = "1.0"
mock_project_client.agents.create_version = AsyncMock(return_value=mock_agent)
run_options = {"model": "test-model", "temperature": 0.9, "top_p": 0.8}
messages_instructions = "Message instructions. "
await client._get_agent_reference_or_create(run_options, messages_instructions) # type: ignore
# Verify agent was created with provided arguments
call_args = mock_project_client.agents.create_version.call_args
definition = call_args[1]["definition"]
assert definition.temperature == 0.9
assert definition.top_p == 0.8
async def test_azure_ai_client_agent_creation_with_tools(
mock_project_client: MagicMock,
) -> None: