Skip to content

Python: docs: fix removed ChatAgent references in _clients.py docstrings#6924

Open
sumesh-ramasamy wants to merge 3 commits into
microsoft:mainfrom
sumesh-ramasamy:fix/clients-chatagent-docstrings
Open

Python: docs: fix removed ChatAgent references in _clients.py docstrings#6924
sumesh-ramasamy wants to merge 3 commits into
microsoft:mainfrom
sumesh-ramasamy:fix/clients-chatagent-docstrings

Conversation

@sumesh-ramasamy

Copy link
Copy Markdown

What

ChatAgent was renamed to Agent (#3747) with no back-compat alias, but the tool-support
protocol docstrings in python/packages/core/agent_framework/_clients.py still reference
ChatAgent. Copy-pasting the examples raises NameError.

This renames the 12 stale references to Agent across 6 protocol classes
(SupportsCodeInterpreterTool, SupportsWebSearchTool, SupportsImageGenerationTool,
SupportsMCPTool, SupportsFileSearchTool, SupportsShellTool). Also fixes three
"a Agent" -> "an Agent" grammar slips in the adjacent as_agent docstring.

Docstring-only; no code behavior changes.

Verify

from agent_framework import ChatAgent raises ImportErrorAgent is the exported name.

Copilot AI review requested due to automatic review settings July 5, 2026 20:00
@giles17 giles17 added the python Usage: [Issues, PRs], Target: Python label Jul 5, 2026
@github-actions github-actions Bot changed the title docs: fix removed ChatAgent references in _clients.py docstrings Python: docs: fix removed ChatAgent references in _clients.py docstrings Jul 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Python core docstrings in agent_framework/_clients.py to reflect the breaking rename from ChatAgent to Agent, keeping the tool-support protocol examples and as_agent docs aligned with the current public API.

Changes:

  • Replaced stale ChatAgent references with Agent across multiple tool-support protocol docstrings.
  • Fixed nearby grammar in the as_agent docstring (“a Agent” → “an Agent”).
  • Kept changes docstring-only (no runtime behavior changes intended).

Comment on lines +674 to +678
@@ -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])
Comment on lines +704 to +708
@@ -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])
Comment on lines +734 to +738
@@ -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])
Comment on lines +764 to +768
@@ -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])
Comment on lines +795 to +799
@@ -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])
Comment on lines +825 to +829
@@ -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])
@sumesh-ramasamy

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@moonbox3

moonbox3 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@sumesh-ramasamy Thank you for the contribution. Please have a look at Copilot's PR feedback.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _clients.py140695%322, 373, 536–539
TOTAL43375518788% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
8543 33 💤 0 ❌ 0 🔥 2m 13s ⏱️

Sumesh Bharathi Ramasamy and others added 2 commits July 5, 2026 21:37
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 microsoft#6924.

Co-authored-by: Cursor <cursoragent@cursor.com>
`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 <cursoragent@cursor.com>
@sumesh-ramasamy

Copy link
Copy Markdown
Author

Thanks @moonbox3, and thanks to Copilot for the review. I've pushed two follow-up commits addressing the feedback:

  • Added Agent to the import line in all six tool-support protocol examples (SupportsCodeInterpreterTool, SupportsWebSearchTool, SupportsImageGenerationTool, SupportsMCPTool, SupportsFileSearchTool, SupportsShellTool) so the snippets no longer raise NameError on copy/paste.
  • For the SupportsShellTool example, I also defined the shell executor with LocalShellTool (from agent-framework-tools, matching the existing samples) and wrapped it in an async def, since async with isn't valid at module scope.

I verified locally by extracting each docstring code-block and executing it verbatim against a protocol-conforming client — all six now import, run, and construct an Agent successfully.

Happy to make any further adjustments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants