Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/packages/azure-ai/agent_framework_azure_ai/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions python/packages/azure-ai/tests/test_azure_ai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading