Skip to content

Python: Fix the async ChatResponse aggregation example - #9518

Open
LI (ktz03) wants to merge 1 commit into
microsoft:mainfrom
ktz03:docs/chatresponse-async-generator-example-20261019
Open

LI (ktz03) wants to merge 1 commit into
microsoft:mainfrom
ktz03:docs/chatresponse-async-generator-example-20261019

Conversation

@ktz03

Copy link
Copy Markdown
Contributor

Motivation & Context

The ChatResponse.from_update_generator example imports a ChatClient placeholder that the package does not export and uses the legacy get_streaming_response name. Copying it currently fails at the import.

Description & Review Guide

  • What are the major changes? Replace the obsolete client placeholder with a self-contained async generator of ordinary text updates using the current public types.
  • What is the impact of these changes? Only the example docstring changes; APIs and aggregation behavior remain unchanged. The exact corrected snippet produces Hello How can I help you?, and the adjacent synchronous example still works. Current-config Ruff checks and source compilation pass. No provider/model, package build or full-suite run was performed.
  • What do you want reviewers to focus on? The async example uses the existing ChatResponseUpdate, Content.from_text and ChatResponse.from_update_generator APIs correctly.

Related Issue

N/A - trivial change. This is an obvious correction to an example that imports a non-exported client placeholder and uses a legacy streaming method. It uses existing public types and a self-contained async generator without changing any API or runtime behavior.

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: Documentation, example verification, and this PR 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.

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

The documentation-only correction uses the existing public APIs correctly and has no unresolved findings.

No open issues 🎉

What changed in this PR

Corrects the async ChatResponse aggregation example without changing APIs or runtime behavior.

Changes:

  • Replaces the obsolete client placeholder with a self-contained async generator using public types.
  • Shows the expected aggregated text output.
File Description
python/​packages/​core/​agent_framework/​_types.py Updates the from_update_generator docstring example.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — 8f1e5ab1 Deployed Oct 19, 2026 by ktz03 via team_check #7036
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