Python: name changes executed (#607)

* name changes executed

* updated adr to accepted

* renamed openai base config

* renamed openai config to mixin

* added renames in user docs

* reverted mcperror

* fix tests

* remove sse from tests
This commit is contained in:
Eduard van Valkenburg
2025-09-04 15:00:38 +00:00
committed by GitHub
parent 6310ca5be0
commit 40ab6e9d67
100 changed files with 1223 additions and 1100 deletions
@@ -9,8 +9,8 @@ from agent_framework import (
AgentRunResponse,
AgentRunResponseUpdate,
AgentThread,
ChatClient,
ChatClientAgent,
ChatAgent,
ChatClientProtocol,
ChatMessage,
ChatResponse,
ChatResponseUpdate,
@@ -93,7 +93,7 @@ def test_azure_assistants_client_init_with_client(mock_async_azure_openai: Magic
assert chat_client.assistant_id == "existing-assistant-id"
assert chat_client.thread_id == "test-thread-id"
assert not chat_client._should_delete_assistant # type: ignore
assert isinstance(chat_client, ChatClient)
assert isinstance(chat_client, ChatClientProtocol)
def test_azure_assistants_client_init_auto_create_client(
@@ -147,7 +147,7 @@ def test_azure_assistants_client_init_with_default_headers(azure_openai_unit_tes
)
assert chat_client.ai_model_id == "test_chat_deployment"
assert isinstance(chat_client, ChatClient)
assert isinstance(chat_client, ChatClientProtocol)
# Assert that the default header we added is present in the client's default headers
for key, value in default_headers.items():
@@ -267,7 +267,7 @@ def get_weather(
async def test_azure_assistants_client_get_response() -> None:
"""Test Azure Assistants Client response."""
async with AzureAssistantsClient(credential=AzureCliCredential()) as azure_assistants_client:
assert isinstance(azure_assistants_client, ChatClient)
assert isinstance(azure_assistants_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(
@@ -291,7 +291,7 @@ async def test_azure_assistants_client_get_response() -> None:
async def test_azure_assistants_client_get_response_tools() -> None:
"""Test Azure Assistants Client response with tools."""
async with AzureAssistantsClient(credential=AzureCliCredential()) as azure_assistants_client:
assert isinstance(azure_assistants_client, ChatClient)
assert isinstance(azure_assistants_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(ChatMessage(role="user", text="What's the weather like in Seattle?"))
@@ -312,7 +312,7 @@ async def test_azure_assistants_client_get_response_tools() -> None:
async def test_azure_assistants_client_streaming() -> None:
"""Test Azure Assistants Client streaming response."""
async with AzureAssistantsClient(credential=AzureCliCredential()) as azure_assistants_client:
assert isinstance(azure_assistants_client, ChatClient)
assert isinstance(azure_assistants_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(
@@ -342,7 +342,7 @@ async def test_azure_assistants_client_streaming() -> None:
async def test_azure_assistants_client_streaming_tools() -> None:
"""Test Azure Assistants Client streaming response with tools."""
async with AzureAssistantsClient(credential=AzureCliCredential()) as azure_assistants_client:
assert isinstance(azure_assistants_client, ChatClient)
assert isinstance(azure_assistants_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(ChatMessage(role="user", text="What's the weather like in Seattle?"))
@@ -378,7 +378,7 @@ async def test_azure_assistants_client_with_existing_assistant() -> None:
async with AzureAssistantsClient(
assistant_id=assistant_id, credential=AzureCliCredential()
) as azure_assistants_client:
assert isinstance(azure_assistants_client, ChatClient)
assert isinstance(azure_assistants_client, ChatClientProtocol)
assert azure_assistants_client.assistant_id == assistant_id
messages = [ChatMessage(role="user", text="What can you do?")]
@@ -393,8 +393,8 @@ async def test_azure_assistants_client_with_existing_assistant() -> None:
@skip_if_azure_integration_tests_disabled
async def test_azure_assistants_agent_basic_run():
"""Test ChatClientAgent basic run functionality with AzureAssistantsClient."""
async with ChatClientAgent(
"""Test ChatAgent basic run functionality with AzureAssistantsClient."""
async with ChatAgent(
chat_client=AzureAssistantsClient(credential=AzureCliCredential()),
) as agent:
# Run a simple query
@@ -409,13 +409,13 @@ async def test_azure_assistants_agent_basic_run():
@skip_if_azure_integration_tests_disabled
async def test_azure_assistants_agent_basic_run_streaming():
"""Test ChatClientAgent basic streaming functionality with AzureAssistantsClient."""
async with ChatClientAgent(
"""Test ChatAgent basic streaming functionality with AzureAssistantsClient."""
async with ChatAgent(
chat_client=AzureAssistantsClient(credential=AzureCliCredential()),
) as agent:
# Run streaming query
full_message: str = ""
async for chunk in agent.run_streaming("Please respond with exactly: 'This is a streaming response test.'"):
async for chunk in agent.run_stream("Please respond with exactly: 'This is a streaming response test.'"):
assert chunk is not None
assert isinstance(chunk, AgentRunResponseUpdate)
if chunk.text:
@@ -428,8 +428,8 @@ async def test_azure_assistants_agent_basic_run_streaming():
@skip_if_azure_integration_tests_disabled
async def test_azure_assistants_agent_thread_persistence():
"""Test ChatClientAgent thread persistence across runs with AzureAssistantsClient."""
async with ChatClientAgent(
"""Test ChatAgent thread persistence across runs with AzureAssistantsClient."""
async with ChatAgent(
chat_client=AzureAssistantsClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant with good memory.",
) as agent:
@@ -456,11 +456,11 @@ async def test_azure_assistants_agent_thread_persistence():
@skip_if_azure_integration_tests_disabled
async def test_azure_assistants_agent_existing_thread_id():
"""Test ChatClientAgent with existing thread ID to continue conversations across agent instances."""
"""Test ChatAgent with existing thread ID to continue conversations across agent instances."""
# First, create a conversation and capture the thread ID
existing_thread_id = None
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureAssistantsClient(credential=AzureCliCredential()),
instructions="You are a helpful weather agent.",
tools=[get_weather],
@@ -480,7 +480,7 @@ async def test_azure_assistants_agent_existing_thread_id():
# Now continue with the same thread ID in a new agent instance
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureAssistantsClient(thread_id=existing_thread_id, credential=AzureCliCredential()),
instructions="You are a helpful weather agent.",
tools=[get_weather],
@@ -500,9 +500,9 @@ async def test_azure_assistants_agent_existing_thread_id():
@skip_if_azure_integration_tests_disabled
async def test_azure_assistants_agent_code_interpreter():
"""Test ChatClientAgent with code interpreter through AzureAssistantsClient."""
"""Test ChatAgent with code interpreter through AzureAssistantsClient."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureAssistantsClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant that can write and execute Python code.",
tools=[HostedCodeInterpreterTool()],
@@ -521,7 +521,7 @@ async def test_azure_assistants_agent_code_interpreter():
async def test_azure_assistants_client_agent_level_tool_persistence():
"""Test that agent-level tools persist across multiple runs with Azure Assistants Client."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureAssistantsClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant that uses available tools.",
tools=[get_weather], # Agent-level tool
@@ -556,7 +556,7 @@ async def test_azure_assistants_client_run_level_tool_isolation():
call_count += 1
return f"The weather in {location} is sunny and 72°F."
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureAssistantsClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant.",
) as agent:
@@ -10,9 +10,9 @@ import pytest
from agent_framework import (
AgentRunResponse,
AgentRunResponseUpdate,
ChatClient,
ChatClientAgent,
ChatClientBase,
BaseChatClient,
ChatAgent,
ChatClientProtocol,
ChatMessage,
ChatResponse,
ChatResponseUpdate,
@@ -55,7 +55,7 @@ def test_init(azure_openai_unit_test_env: dict[str, str]) -> None:
assert azure_chat_client.client is not None
assert isinstance(azure_chat_client.client, AsyncAzureOpenAI)
assert azure_chat_client.ai_model_id == azure_openai_unit_test_env["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]
assert isinstance(azure_chat_client, ChatClientBase)
assert isinstance(azure_chat_client, BaseChatClient)
def test_init_client(azure_openai_unit_test_env: dict[str, str]) -> None:
@@ -78,7 +78,7 @@ def test_init_base_url(azure_openai_unit_test_env: dict[str, str]) -> None:
assert azure_chat_client.client is not None
assert isinstance(azure_chat_client.client, AsyncAzureOpenAI)
assert azure_chat_client.ai_model_id == azure_openai_unit_test_env["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]
assert isinstance(azure_chat_client, ChatClientBase)
assert isinstance(azure_chat_client, BaseChatClient)
for key, value in default_headers.items():
assert key in azure_chat_client.client.default_headers
assert azure_chat_client.client.default_headers[key] == value
@@ -91,7 +91,7 @@ def test_init_endpoint(azure_openai_unit_test_env: dict[str, str]) -> None:
assert azure_chat_client.client is not None
assert isinstance(azure_chat_client.client, AsyncAzureOpenAI)
assert azure_chat_client.ai_model_id == azure_openai_unit_test_env["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]
assert isinstance(azure_chat_client, ChatClientBase)
assert isinstance(azure_chat_client, BaseChatClient)
@pytest.mark.parametrize("exclude_list", [["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"]], indirect=True)
@@ -614,7 +614,7 @@ def get_weather(location: str) -> str:
async def test_azure_openai_chat_client_response() -> None:
"""Test Azure OpenAI chat completion responses."""
azure_chat_client = AzureChatClient(credential=AzureCliCredential())
assert isinstance(azure_chat_client, ChatClient)
assert isinstance(azure_chat_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(
@@ -643,7 +643,7 @@ async def test_azure_openai_chat_client_response() -> None:
async def test_azure_openai_chat_client_response_tools() -> None:
"""Test AzureOpenAI chat completion responses."""
azure_chat_client = AzureChatClient(credential=AzureCliCredential())
assert isinstance(azure_chat_client, ChatClient)
assert isinstance(azure_chat_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(ChatMessage(role="user", text="who are Emily and David?"))
@@ -664,7 +664,7 @@ async def test_azure_openai_chat_client_response_tools() -> None:
async def test_azure_openai_chat_client_streaming() -> None:
"""Test Azure OpenAI chat completion responses."""
azure_chat_client = AzureChatClient(credential=AzureCliCredential())
assert isinstance(azure_chat_client, ChatClient)
assert isinstance(azure_chat_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(
@@ -698,7 +698,7 @@ async def test_azure_openai_chat_client_streaming() -> None:
async def test_azure_openai_chat_client_streaming_tools() -> None:
"""Test AzureOpenAI chat completion responses."""
azure_chat_client = AzureChatClient(credential=AzureCliCredential())
assert isinstance(azure_chat_client, ChatClient)
assert isinstance(azure_chat_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(ChatMessage(role="user", text="who are Emily and David?"))
@@ -723,7 +723,7 @@ async def test_azure_openai_chat_client_streaming_tools() -> None:
@skip_if_azure_integration_tests_disabled
async def test_azure_openai_chat_client_agent_basic_run():
"""Test Azure OpenAI chat client agent basic run functionality with AzureChatClient."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureChatClient(credential=AzureCliCredential()),
) as agent:
# Test basic run
@@ -738,12 +738,12 @@ async def test_azure_openai_chat_client_agent_basic_run():
@skip_if_azure_integration_tests_disabled
async def test_azure_openai_chat_client_agent_basic_run_streaming():
"""Test Azure OpenAI chat client agent basic streaming functionality with AzureChatClient."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureChatClient(credential=AzureCliCredential()),
) as agent:
# Test streaming run
full_text = ""
async for chunk in agent.run_streaming("Please respond with exactly: 'This is a streaming response test.'"):
async for chunk in agent.run_stream("Please respond with exactly: 'This is a streaming response test.'"):
assert isinstance(chunk, AgentRunResponseUpdate)
if chunk.text:
full_text += chunk.text
@@ -755,7 +755,7 @@ async def test_azure_openai_chat_client_agent_basic_run_streaming():
@skip_if_azure_integration_tests_disabled
async def test_azure_openai_chat_client_agent_thread_persistence():
"""Test Azure OpenAI chat client agent thread persistence across runs with AzureChatClient."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant with good memory.",
) as agent:
@@ -782,7 +782,7 @@ async def test_azure_openai_chat_client_agent_existing_thread():
# First conversation - capture the thread
preserved_thread = None
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant with good memory.",
) as first_agent:
@@ -798,7 +798,7 @@ async def test_azure_openai_chat_client_agent_existing_thread():
# Second conversation - reuse the thread in a new agent instance
if preserved_thread:
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant with good memory.",
) as second_agent:
@@ -814,7 +814,7 @@ async def test_azure_openai_chat_client_agent_existing_thread():
async def test_azure_chat_client_agent_level_tool_persistence():
"""Test that agent-level tools persist across multiple runs with Azure Chat Client."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant that uses available tools.",
tools=[get_weather], # Agent-level tool
@@ -849,7 +849,7 @@ async def test_azure_chat_client_run_level_tool_isolation():
call_count += 1
return f"The weather in {location} is sunny and 72°F."
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant.",
) as agent:
@@ -8,8 +8,8 @@ from agent_framework import (
AgentRunResponse,
AgentRunResponseUpdate,
AgentThread,
ChatClient,
ChatClientAgent,
ChatAgent,
ChatClientProtocol,
ChatMessage,
ChatResponse,
ChatResponseUpdate,
@@ -50,7 +50,7 @@ def test_init(azure_openai_unit_test_env: dict[str, str]) -> None:
azure_responses_client = AzureResponsesClient()
assert azure_responses_client.ai_model_id == azure_openai_unit_test_env["AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"]
assert isinstance(azure_responses_client, ChatClient)
assert isinstance(azure_responses_client, ChatClientProtocol)
def test_init_validation_fail() -> None:
@@ -65,7 +65,7 @@ def test_init_ai_model_id_constructor(azure_openai_unit_test_env: dict[str, str]
azure_responses_client = AzureResponsesClient(deployment_name=ai_model_id)
assert azure_responses_client.ai_model_id == ai_model_id
assert isinstance(azure_responses_client, ChatClient)
assert isinstance(azure_responses_client, ChatClientProtocol)
def test_init_with_default_header(azure_openai_unit_test_env: dict[str, str]) -> None:
@@ -77,7 +77,7 @@ def test_init_with_default_header(azure_openai_unit_test_env: dict[str, str]) ->
)
assert azure_responses_client.ai_model_id == azure_openai_unit_test_env["AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"]
assert isinstance(azure_responses_client, ChatClient)
assert isinstance(azure_responses_client, ChatClientProtocol)
# Assert that the default header we added is present in the client's default headers
for key, value in default_headers.items():
@@ -119,7 +119,7 @@ async def test_azure_responses_client_response() -> None:
"""Test azure responses client responses."""
azure_responses_client = AzureResponsesClient(credential=AzureCliCredential())
assert isinstance(azure_responses_client, ChatClient)
assert isinstance(azure_responses_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(
@@ -162,7 +162,7 @@ async def test_azure_responses_client_response_tools() -> None:
"""Test azure responses client tools."""
azure_responses_client = AzureResponsesClient(credential=AzureCliCredential())
assert isinstance(azure_responses_client, ChatClient)
assert isinstance(azure_responses_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(ChatMessage(role="user", text="What is the weather in New York?"))
@@ -201,7 +201,7 @@ async def test_azure_responses_client_streaming() -> None:
"""Test Azure azure responses client streaming responses."""
azure_responses_client = AzureResponsesClient(credential=AzureCliCredential())
assert isinstance(azure_responses_client, ChatClient)
assert isinstance(azure_responses_client, ChatClientProtocol)
messages: list[ChatMessage] = []
messages.append(
@@ -251,7 +251,7 @@ async def test_azure_responses_client_streaming_tools() -> None:
"""Test azure responses client streaming tools."""
azure_responses_client = AzureResponsesClient(credential=AzureCliCredential())
assert isinstance(azure_responses_client, ChatClient)
assert isinstance(azure_responses_client, ChatClientProtocol)
messages: list[ChatMessage] = [ChatMessage(role="user", text="What is the weather in Seattle?")]
@@ -312,12 +312,12 @@ async def test_azure_responses_client_agent_basic_run():
@skip_if_azure_integration_tests_disabled
async def test_azure_responses_client_agent_basic_run_streaming():
"""Test Azure Responses Client agent basic streaming functionality with AzureResponsesClient."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
) as agent:
# Test streaming run
full_text = ""
async for chunk in agent.run_streaming("Please respond with exactly: 'This is a streaming response test.'"):
async for chunk in agent.run_stream("Please respond with exactly: 'This is a streaming response test.'"):
assert isinstance(chunk, AgentRunResponseUpdate)
if chunk.text:
full_text += chunk.text
@@ -329,7 +329,7 @@ async def test_azure_responses_client_agent_basic_run_streaming():
@skip_if_azure_integration_tests_disabled
async def test_azure_responses_client_agent_thread_persistence():
"""Test Azure Responses Client agent thread persistence across runs with AzureResponsesClient."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant with good memory.",
) as agent:
@@ -352,7 +352,7 @@ async def test_azure_responses_client_agent_thread_persistence():
@skip_if_azure_integration_tests_disabled
async def test_azure_responses_client_agent_thread_storage_with_store_true():
"""Test Azure Responses Client agent with store=True to verify service_thread_id is returned."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant.",
) as agent:
@@ -386,7 +386,7 @@ async def test_azure_responses_client_agent_existing_thread():
# First conversation - capture the thread
preserved_thread = None
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant with good memory.",
) as first_agent:
@@ -402,7 +402,7 @@ async def test_azure_responses_client_agent_existing_thread():
# Second conversation - reuse the thread in a new agent instance
if preserved_thread:
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant with good memory.",
) as second_agent:
@@ -417,7 +417,7 @@ async def test_azure_responses_client_agent_existing_thread():
@skip_if_azure_integration_tests_disabled
async def test_azure_responses_client_agent_hosted_code_interpreter_tool():
"""Test Azure Responses Client agent with HostedCodeInterpreterTool through AzureResponsesClient."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant that can execute Python code.",
tools=[HostedCodeInterpreterTool()],
@@ -439,7 +439,7 @@ async def test_azure_responses_client_agent_hosted_code_interpreter_tool():
async def test_azure_responses_client_agent_level_tool_persistence():
"""Test that agent-level tools persist across multiple runs with Azure Responses Client."""
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant that uses available tools.",
tools=[get_weather], # Agent-level tool
@@ -474,7 +474,7 @@ async def test_azure_responses_client_run_level_tool_isolation():
call_count += 1
return f"The weather in {location} is sunny and 72°F."
async with ChatClientAgent(
async with ChatAgent(
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
instructions="You are a helpful assistant.",
) as agent: