Skip to content

Python: Fix custom client, fan-in, and executor docstring examples - #10081

Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-core-client-workflow-docstrings
Draft

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-core-client-workflow-docstrings

Conversation

@1aifanatic

Copy link
Copy Markdown
Contributor

Motivation & Context

Three docstring examples in core fail when run:

  • BaseChatClient custom client declares async def _inner_get_response. The method must return an awaitable or a ResponseStream, but an async def always returns a coroutine. So the example's own async for update in client.get_response(..., stream=True) raises TypeError: 'async for' requires an object with __aiter__ method, got coroutine. Its streaming update also passes a dict as content.
  • WorkflowBuilder.add_fan_in_edges starts at prod_1 and never connects prod_2, so build() raises GraphConnectivityError: ... unreachable from the start executor 'prod_1': ['prod_2'].
  • Executor has three blocks with comment-only handler bodies, which isn't valid Python. The prose line after each block also has no blank line, so it isn't separated from the block.

Description & Review Guide

  • What are the major changes? Docstring examples only:
    • The custom client follows samples/02-agents/chat_client/custom_chat_client.py: a plain def that returns a ResponseStream when stream is True, or a coroutine otherwise, with Content.from_text.
    • The fan-in example adds a Dispatcher start executor that fans out to both producers.
    • The Executor blocks get ... bodies and blank lines.
  • What is the impact of these changes? Documentation only.
  • What do you want reviewers to focus on? Nothing in particular.

I ran the fixed examples. The client returns Hello! both with and without streaming. The fan-in workflow runs and outputs Combined: result_7, result_7. The three Executor blocks compile. test_docstrings.py passes.

Related Issue

N/A - trivial change: docstring examples are corrected so they run, with no behavior change.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Claude Code helped find the failing examples by executing docstring code blocks against a stub client, fix them, re-run them, and draft this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 05:37
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 4, 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.

🟢 Approval recommended

No active review issues are reported for the docstring example updates.

No open issues 🎉

What changed in this PR

This PR corrects Python core docstring examples for custom chat clients and workflows without changing runtime behavior.

Changes:

  • Updates the custom client example to return a ResponseStream for streaming and a coroutine otherwise, using Content.from_text for streaming content.
  • Adds a dispatcher so both producers in the fan-in example are reachable.
  • Adds valid placeholder bodies and separates following prose in three executor examples.
File Description
python/​packages/​core/​agent_framework/​_workflows/​_workflow_builder.py Connects both fan-in producers through a dispatcher.
python/​packages/​core/​agent_framework/​_workflows/​_executor.py Fixes syntax and prose spacing in handler examples.
python/​packages/​core/​agent_framework/​_clients.py Corrects custom client response handling and streaming content.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — b62623c1 Deployed Nov 4, 2026 by 1aifanatic via team_check #8670
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.

2 participants