diff --git a/python/packages/azure-ai/agent_framework_azure_ai/_client.py b/python/packages/azure-ai/agent_framework_azure_ai/_client.py index a11981390c..f4d5328f03 100644 --- a/python/packages/azure-ai/agent_framework_azure_ai/_client.py +++ b/python/packages/azure-ai/agent_framework_azure_ai/_client.py @@ -335,6 +335,10 @@ async def _get_agent_reference_or_create( 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 @@ async def prepare_options( # 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) diff --git a/python/packages/azure-ai/tests/test_azure_ai_client.py b/python/packages/azure-ai/tests/test_azure_ai_client.py index 2167c1340a..079b93d8c8 100644 --- a/python/packages/azure-ai/tests/test_azure_ai_client.py +++ b/python/packages/azure-ai/tests/test_azure_ai_client.py @@ -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: