From 907dbef002ed316f8b5db9dad4e8cb3e0a5df501 Mon Sep 17 00:00:00 2001 From: Sumesh Bharathi Date: Sun, 5 Jul 2026 15:57:30 -0400 Subject: [PATCH 1/3] docs: fix removed ChatAgent references in _clients.py docstrings --- .../packages/core/agent_framework/_clients.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/python/packages/core/agent_framework/_clients.py b/python/packages/core/agent_framework/_clients.py index fb1d0ab3662..7af6ffffeeb 100644 --- a/python/packages/core/agent_framework/_clients.py +++ b/python/packages/core/agent_framework/_clients.py @@ -581,9 +581,9 @@ def as_agent( tokenizer: TokenizerProtocol | None = None, additional_properties: Mapping[str, Any] | None = None, ) -> Agent[OptionsCoT]: - """Create a Agent with this client. + """Create an Agent with this client. - This is a convenience method that creates a Agent instance with this + This is a convenience method that creates an Agent instance with this chat client already configured. Keyword Args: @@ -614,7 +614,7 @@ def as_agent( additional_properties: Additional properties stored on the created agent. Returns: - A Agent instance configured with this chat client. + An Agent instance configured with this chat client. Examples: .. code-block:: python @@ -675,7 +675,7 @@ class SupportsCodeInterpreterTool(Protocol): if isinstance(client, SupportsCodeInterpreterTool): tool = client.get_code_interpreter_tool() - agent = ChatAgent(client, tools=[tool]) + agent = Agent(client, tools=[tool]) """ @staticmethod @@ -686,7 +686,7 @@ def get_code_interpreter_tool(**kwargs: Any) -> Any: **kwargs: Provider-specific configuration options. Returns: - A tool configuration ready to pass to ChatAgent. + A tool configuration ready to pass to Agent. """ ... @@ -705,7 +705,7 @@ class SupportsWebSearchTool(Protocol): if isinstance(client, SupportsWebSearchTool): tool = client.get_web_search_tool() - agent = ChatAgent(client, tools=[tool]) + agent = Agent(client, tools=[tool]) """ @staticmethod @@ -716,7 +716,7 @@ def get_web_search_tool(**kwargs: Any) -> Any: **kwargs: Provider-specific configuration options. Returns: - A tool configuration ready to pass to ChatAgent. + A tool configuration ready to pass to Agent. """ ... @@ -735,7 +735,7 @@ class SupportsImageGenerationTool(Protocol): if isinstance(client, SupportsImageGenerationTool): tool = client.get_image_generation_tool() - agent = ChatAgent(client, tools=[tool]) + agent = Agent(client, tools=[tool]) """ @staticmethod @@ -746,7 +746,7 @@ def get_image_generation_tool(**kwargs: Any) -> Any: **kwargs: Provider-specific configuration options. Returns: - A tool configuration ready to pass to ChatAgent. + A tool configuration ready to pass to Agent. """ ... @@ -765,7 +765,7 @@ class SupportsMCPTool(Protocol): if isinstance(client, SupportsMCPTool): tool = client.get_mcp_tool(name="my_mcp", url="https://...") - agent = ChatAgent(client, tools=[tool]) + agent = Agent(client, tools=[tool]) """ @staticmethod @@ -777,7 +777,7 @@ def get_mcp_tool(**kwargs: Any) -> Any: name and url for the MCP server. Returns: - A tool configuration ready to pass to ChatAgent. + A tool configuration ready to pass to Agent. """ ... @@ -796,7 +796,7 @@ class SupportsFileSearchTool(Protocol): if isinstance(client, SupportsFileSearchTool): tool = client.get_file_search_tool(vector_store_ids=["vs_123"]) - agent = ChatAgent(client, tools=[tool]) + agent = Agent(client, tools=[tool]) """ @staticmethod @@ -807,7 +807,7 @@ def get_file_search_tool(**kwargs: Any) -> Any: **kwargs: Provider-specific configuration options. Returns: - A tool configuration ready to pass to ChatAgent. + A tool configuration ready to pass to Agent. """ ... @@ -826,7 +826,7 @@ class SupportsShellTool(Protocol): if isinstance(client, SupportsShellTool): tool = client.get_shell_tool(func=shell.as_function()) - agent = ChatAgent(client, tools=[tool]) + agent = Agent(client, tools=[tool]) """ @staticmethod @@ -837,7 +837,7 @@ def get_shell_tool(**kwargs: Any) -> Any: **kwargs: Provider-specific configuration options. Returns: - A tool configuration ready to pass to ChatAgent. + A tool configuration ready to pass to Agent. """ ... From 48cda3b9be77e4aacef9188d8b2f0ccf2efe5122 Mon Sep 17 00:00:00 2001 From: Sumesh Bharathi Ramasamy Date: Sun, 5 Jul 2026 21:37:36 -0400 Subject: [PATCH 2/3] docs: make _clients.py tool-support examples copy/paste-safe Import Agent in each tool-support protocol docstring example so copy/pasting no longer raises NameError, and define the shell executor (LocalShellTool) in the SupportsShellTool example. Addresses Copilot review feedback on #6924. Co-authored-by: Cursor --- .../packages/core/agent_framework/_clients.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/python/packages/core/agent_framework/_clients.py b/python/packages/core/agent_framework/_clients.py index 7af6ffffeeb..de7e26f10a3 100644 --- a/python/packages/core/agent_framework/_clients.py +++ b/python/packages/core/agent_framework/_clients.py @@ -671,7 +671,7 @@ class SupportsCodeInterpreterTool(Protocol): Examples: .. code-block:: python - from agent_framework import SupportsCodeInterpreterTool + from agent_framework import Agent, SupportsCodeInterpreterTool if isinstance(client, SupportsCodeInterpreterTool): tool = client.get_code_interpreter_tool() @@ -701,7 +701,7 @@ class SupportsWebSearchTool(Protocol): Examples: .. code-block:: python - from agent_framework import SupportsWebSearchTool + from agent_framework import Agent, SupportsWebSearchTool if isinstance(client, SupportsWebSearchTool): tool = client.get_web_search_tool() @@ -731,7 +731,7 @@ class SupportsImageGenerationTool(Protocol): Examples: .. code-block:: python - from agent_framework import SupportsImageGenerationTool + from agent_framework import Agent, SupportsImageGenerationTool if isinstance(client, SupportsImageGenerationTool): tool = client.get_image_generation_tool() @@ -761,7 +761,7 @@ class SupportsMCPTool(Protocol): Examples: .. code-block:: python - from agent_framework import SupportsMCPTool + from agent_framework import Agent, SupportsMCPTool if isinstance(client, SupportsMCPTool): tool = client.get_mcp_tool(name="my_mcp", url="https://...") @@ -792,7 +792,7 @@ class SupportsFileSearchTool(Protocol): Examples: .. code-block:: python - from agent_framework import SupportsFileSearchTool + from agent_framework import Agent, SupportsFileSearchTool if isinstance(client, SupportsFileSearchTool): tool = client.get_file_search_tool(vector_store_ids=["vs_123"]) @@ -822,11 +822,13 @@ class SupportsShellTool(Protocol): Examples: .. code-block:: python - from agent_framework import SupportsShellTool + from agent_framework import Agent, SupportsShellTool + from agent_framework_tools.shell import LocalShellTool if isinstance(client, SupportsShellTool): - tool = client.get_shell_tool(func=shell.as_function()) - agent = Agent(client, tools=[tool]) + async with LocalShellTool() as shell: + tool = client.get_shell_tool(func=shell.as_function()) + agent = Agent(client, tools=[tool]) """ @staticmethod From d5eddffe627d91a65181ecfe8b705f8847718de9 Mon Sep 17 00:00:00 2001 From: Sumesh Bharathi Ramasamy Date: Sun, 5 Jul 2026 21:39:05 -0400 Subject: [PATCH 3/3] docs: wrap SupportsShellTool example in async function `async with LocalShellTool()` is a SyntaxError at module level, so the copy/pasted snippet must live inside an async function to be valid. Co-authored-by: Cursor --- python/packages/core/agent_framework/_clients.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/packages/core/agent_framework/_clients.py b/python/packages/core/agent_framework/_clients.py index de7e26f10a3..5e659dc6e22 100644 --- a/python/packages/core/agent_framework/_clients.py +++ b/python/packages/core/agent_framework/_clients.py @@ -825,10 +825,12 @@ class SupportsShellTool(Protocol): from agent_framework import Agent, SupportsShellTool from agent_framework_tools.shell import LocalShellTool - if isinstance(client, SupportsShellTool): - async with LocalShellTool() as shell: - tool = client.get_shell_tool(func=shell.as_function()) - agent = Agent(client, tools=[tool]) + + async def build_agent(client): + if isinstance(client, SupportsShellTool): + async with LocalShellTool() as shell: + tool = client.get_shell_tool(func=shell.as_function()) + return Agent(client, tools=[tool]) """ @staticmethod