Repository navigation
Python: Fix custom client, fan-in, and executor docstring examples - #10081
Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Naveen Chatlapalli (1aifanatic)
temporarily deployed
to
github-app-auth
November 4, 2026 05:37 — with
GitHub Actions
Inactive
Naveen Chatlapalli (1aifanatic)
temporarily deployed
to
github-app-auth
November 4, 2026 05:37 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 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
ResponseStreamfor streaming and a coroutine otherwise, usingContent.from_textfor 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
Three docstring examples in core fail when run:
BaseChatClientcustom client declaresasync def _inner_get_response. The method must return an awaitable or aResponseStream, but anasync defalways returns a coroutine. So the example's ownasync for update in client.get_response(..., stream=True)raisesTypeError: 'async for' requires an object with __aiter__ method, got coroutine. Its streaming update also passes a dict as content.WorkflowBuilder.add_fan_in_edgesstarts atprod_1and never connectsprod_2, sobuild()raisesGraphConnectivityError: ... unreachable from the start executor 'prod_1': ['prod_2'].Executorhas 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
samples/02-agents/chat_client/custom_chat_client.py: a plaindefthat returns aResponseStreamwhenstreamis True, or a coroutine otherwise, withContent.from_text.Dispatcherstart executor that fans out to both producers.Executorblocks get...bodies and blank lines.I ran the fixed examples. The client returns
Hello!both with and without streaming. The fan-in workflow runs and outputsCombined: result_7, result_7. The threeExecutorblocks compile.test_docstrings.pypasses.Related Issue
N/A - trivial change: docstring examples are corrected so they run, with no behavior change.
AI Assistance
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
breaking changelabel (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