Skip to content

Commit dc2a757

Browse files
Rename Bare*Client to Raw*Client and BaseChatClient
- Renamed BareChatClient to BaseChatClient (abstract base class) - Renamed BareOpenAIChatClient to RawOpenAIChatClient - Renamed BareOpenAIResponsesClient to RawOpenAIResponsesClient - Renamed BareAzureAIClient to RawAzureAIClient - Added warning docstrings to Raw* classes about layer ordering - Updated README in samples/getting_started/agents/custom with layer docs - Added test for span ordering with function calling
1 parent 21a95c0 commit dc2a757

File tree

31 files changed

+280
-99
lines changed

31 files changed

+280
-99
lines changed

docs/decisions/0012-python-typeddict-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ response = await client.get_response(
126126

127127
Chosen option: **"Option 2: TypedDict with Generic Type Parameters"**, because it provides full type safety, excellent IDE support with autocompletion, and allows users to extend provider-specific options for their use cases. Extended this Generic to ChatAgents in order to also properly type the options used in agent construction and run methods.
128128

129-
See [typed_options.py](../../python/samples/getting_started/chat_client/typed_options.py) for a complete example demonstrating the usage of typed options with custom extensions.
129+
See [typed_options.py](../../python/samples/concepts/typed_options.py) for a complete example demonstrating the usage of typed options with custom extensions.

python/packages/ag-ui/agent_framework_ag_ui/_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import httpx
1414
from agent_framework import (
15-
BareChatClient,
15+
BaseChatClient,
1616
ChatMessage,
1717
ChatResponse,
1818
ChatResponseUpdate,
@@ -57,7 +57,7 @@ def _unwrap_server_function_call_contents(contents: MutableSequence[Content | di
5757
contents[idx] = content.function_call # type: ignore[assignment, union-attr]
5858

5959

60-
TBareChatClient = TypeVar("TBareChatClient", bound=type[BareChatClient[Any]])
60+
TBaseChatClient = TypeVar("TBaseChatClient", bound=type[BaseChatClient[Any]])
6161

6262
TAGUIChatOptions = TypeVar(
6363
"TAGUIChatOptions",
@@ -67,7 +67,7 @@ def _unwrap_server_function_call_contents(contents: MutableSequence[Content | di
6767
)
6868

6969

70-
def _apply_server_function_call_unwrap(chat_client: TBareChatClient) -> TBareChatClient:
70+
def _apply_server_function_call_unwrap(chat_client: TBaseChatClient) -> TBaseChatClient:
7171
"""Class decorator that unwraps server-side function calls after tool handling."""
7272

7373
original_get_response = chat_client.get_response
@@ -112,12 +112,12 @@ class AGUIChatClient(
112112
ChatMiddlewareLayer[TAGUIChatOptions],
113113
ChatTelemetryLayer[TAGUIChatOptions],
114114
FunctionInvocationLayer[TAGUIChatOptions],
115-
BareChatClient[TAGUIChatOptions],
115+
BaseChatClient[TAGUIChatOptions],
116116
Generic[TAGUIChatOptions],
117117
):
118118
"""Chat client for communicating with AG-UI compliant servers.
119119
120-
This client implements the BareChatClient interface and automatically handles:
120+
This client implements the BaseChatClient interface and automatically handles:
121121
- Thread ID management for conversation continuity
122122
- State synchronization between client and server
123123
- Server-Sent Events (SSE) streaming
@@ -229,7 +229,7 @@ def __init__(
229229
additional_properties: Additional properties to store
230230
middleware: Optional middleware to apply to the client.
231231
function_invocation_configuration: Optional function invocation configuration override.
232-
**kwargs: Additional arguments passed to BareChatClient
232+
**kwargs: Additional arguments passed to BaseChatClient
233233
"""
234234
super().__init__(
235235
additional_properties=additional_properties,

python/packages/ag-ui/agent_framework_ag_ui/_orchestration/_tooling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
from typing import TYPE_CHECKING, Any
77

8-
from agent_framework import BareChatClient
8+
from agent_framework import BaseChatClient
99

1010
if TYPE_CHECKING:
1111
from agent_framework import AgentProtocol
@@ -79,7 +79,7 @@ def register_additional_client_tools(agent: "AgentProtocol", client_tools: list[
7979
if chat_client is None:
8080
return
8181

82-
if isinstance(chat_client, BareChatClient) and chat_client.function_invocation_configuration is not None: # type: ignore[attr-defined]
82+
if isinstance(chat_client, BaseChatClient) and chat_client.function_invocation_configuration is not None: # type: ignore[attr-defined]
8383
chat_client.function_invocation_configuration["additional_tools"] = client_tools # type: ignore[attr-defined]
8484
logger.debug(f"[TOOLS] Registered {len(client_tools)} client tools as additional_tools (declaration-only)")
8585

python/packages/ag-ui/getting_started/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ if __name__ == "__main__":
350350

351351
### Key Concepts
352352

353-
- **`AGUIChatClient`**: Built-in client that implements the Agent Framework's `BareChatClient` interface
353+
- **`AGUIChatClient`**: Built-in client that implements the Agent Framework's `BaseChatClient` interface
354354
- **Automatic Event Handling**: The client automatically converts AG-UI events to Agent Framework types
355355
- **Thread Management**: Pass `thread_id` in metadata to maintain conversation context across requests
356356
- **Streaming Responses**: Use `get_streaming_response()` for real-time streaming or `get_response()` for non-streaming

python/packages/ag-ui/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
AgentResponse,
1313
AgentResponseUpdate,
1414
AgentThread,
15-
BareChatClient,
15+
BaseChatClient,
1616
ChatMessage,
1717
ChatResponse,
1818
ChatResponseUpdate,
@@ -37,7 +37,7 @@ class StreamingChatClientStub(
3737
ChatMiddlewareLayer[TOptions_co],
3838
ChatTelemetryLayer[TOptions_co],
3939
FunctionInvocationLayer[TOptions_co],
40-
BareChatClient[TOptions_co],
40+
BaseChatClient[TOptions_co],
4141
Generic[TOptions_co],
4242
):
4343
"""Typed streaming stub that satisfies ChatClientProtocol."""

python/packages/ag-ui/tests/test_tooling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def test_merge_tools_filters_duplicates() -> None:
5454

5555
def test_register_additional_client_tools_assigns_when_configured() -> None:
5656
"""register_additional_client_tools should set additional_tools on the chat client."""
57-
from agent_framework import BareChatClient, normalize_function_invocation_configuration
57+
from agent_framework import BaseChatClient, normalize_function_invocation_configuration
5858

59-
mock_chat_client = MagicMock(spec=BareChatClient)
59+
mock_chat_client = MagicMock(spec=BaseChatClient)
6060
mock_chat_client.function_invocation_configuration = normalize_function_invocation_configuration(None)
6161

6262
agent = ChatAgent(chat_client=mock_chat_client)

python/packages/anthropic/agent_framework_anthropic/_chat_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from agent_framework import (
88
AGENT_FRAMEWORK_USER_AGENT,
99
Annotation,
10-
BareChatClient,
10+
BaseChatClient,
1111
ChatLevelMiddleware,
1212
ChatMessage,
1313
ChatMiddlewareLayer,
@@ -233,7 +233,7 @@ class AnthropicClient(
233233
ChatMiddlewareLayer[TAnthropicOptions],
234234
ChatTelemetryLayer[TAnthropicOptions],
235235
FunctionInvocationLayer[TAnthropicOptions],
236-
BareChatClient[TAnthropicOptions],
236+
BaseChatClient[TAnthropicOptions],
237237
Generic[TAnthropicOptions],
238238
):
239239
"""Anthropic Chat client with middleware, telemetry, and function invocation support."""

python/packages/azure-ai/agent_framework_azure_ai/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from ._agent_provider import AzureAIAgentsProvider
66
from ._chat_client import AzureAIAgentClient, AzureAIAgentOptions
7-
from ._client import AzureAIClient, AzureAIProjectAgentOptions, BareAzureAIClient
7+
from ._client import AzureAIClient, AzureAIProjectAgentOptions, RawAzureAIClient
88
from ._project_provider import AzureAIProjectAgentProvider
99
from ._shared import AzureAISettings
1010

@@ -21,6 +21,6 @@
2121
"AzureAIProjectAgentOptions",
2222
"AzureAIProjectAgentProvider",
2323
"AzureAISettings",
24-
"BareAzureAIClient",
24+
"RawAzureAIClient",
2525
"__version__",
2626
]

python/packages/azure-ai/agent_framework_azure_ai/_chat_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from agent_framework import (
1212
AGENT_FRAMEWORK_USER_AGENT,
1313
Annotation,
14-
BareChatClient,
14+
BaseChatClient,
1515
ChatAgent,
1616
ChatLevelMiddleware,
1717
ChatMessage,
@@ -206,7 +206,7 @@ class AzureAIAgentClient(
206206
ChatMiddlewareLayer[TAzureAIAgentOptions],
207207
ChatTelemetryLayer[TAzureAIAgentOptions],
208208
FunctionInvocationLayer[TAzureAIAgentOptions],
209-
BareChatClient[TAzureAIAgentOptions],
209+
BaseChatClient[TAzureAIAgentOptions],
210210
Generic[TAzureAIAgentOptions],
211211
):
212212
"""Azure AI Agent Chat client with middleware, telemetry, and function invocation support."""

python/packages/azure-ai/agent_framework_azure_ai/_client.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from agent_framework.exceptions import ServiceInitializationError
2323
from agent_framework.observability import ChatTelemetryLayer
2424
from agent_framework.openai import OpenAIResponsesOptions
25-
from agent_framework.openai._responses_client import BareOpenAIResponsesClient
25+
from agent_framework.openai._responses_client import RawOpenAIResponsesClient
2626
from azure.ai.projects.aio import AIProjectClient
2727
from azure.ai.projects.models import MCPTool, PromptAgentDefinition, PromptAgentDefinitionText, RaiConfig, Reasoning
2828
from azure.core.credentials_async import AsyncTokenCredential
@@ -66,11 +66,20 @@ class AzureAIProjectAgentOptions(OpenAIResponsesOptions, total=False):
6666
)
6767

6868

69-
class BareAzureAIClient(BareOpenAIResponsesClient[TAzureAIClientOptions], Generic[TAzureAIClientOptions]):
70-
"""Bare Azure AI client without middleware, telemetry, or function invocation layers.
69+
class RawAzureAIClient(RawOpenAIResponsesClient[TAzureAIClientOptions], Generic[TAzureAIClientOptions]):
70+
"""Raw Azure AI client without middleware, telemetry, or function invocation layers.
7171
72-
This class provides the core Azure AI functionality. For most use cases,
73-
prefer :class:`AzureAIClient` which includes all standard layers.
72+
Warning:
73+
**This class should not normally be used directly.** It does not include middleware,
74+
telemetry, or function invocation support that you most likely need. If you do use it,
75+
you should consider which additional layers to apply. There is a defined ordering that
76+
you should follow:
77+
78+
1. **ChatMiddlewareLayer** - Should be applied first as it also prepares function middleware
79+
2. **ChatTelemetryLayer** - Telemetry will not be correct if applied outside the function calling loop
80+
3. **FunctionInvocationLayer** - Handles tool/function calling
81+
82+
Use ``AzureAIClient`` instead for a fully-featured client with all layers applied.
7483
"""
7584

7685
OTEL_PROVIDER_NAME: ClassVar[str] = "azure.ai" # type: ignore[reportIncompatibleVariableOverride, misc]
@@ -603,7 +612,7 @@ class AzureAIClient(
603612
ChatMiddlewareLayer[TAzureAIClientOptions],
604613
ChatTelemetryLayer[TAzureAIClientOptions],
605614
FunctionInvocationLayer[TAzureAIClientOptions],
606-
BareAzureAIClient[TAzureAIClientOptions],
615+
RawAzureAIClient[TAzureAIClientOptions],
607616
Generic[TAzureAIClientOptions],
608617
):
609618
"""Azure AI client with middleware, telemetry, and function invocation support.
@@ -613,7 +622,7 @@ class AzureAIClient(
613622
- OpenTelemetry-based telemetry for observability
614623
- Automatic function/tool invocation handling
615624
616-
For a minimal implementation without these features, use :class:`BareAzureAIClient`.
625+
For a minimal implementation without these features, use :class:`RawAzureAIClient`.
617626
"""
618627

619628
def __init__(

0 commit comments

Comments
 (0)