Skip to content

Python: ChatResponse.from_updates documentation example omits Content import #9200

Description

@BlueRaddish

Description

Copying the public ChatResponse.from_updates documentation example into a clean Python namespace raises NameError: name 'Content' is not defined. The example constructs Content.from_text(...) twice but imports only ChatResponse and ChatResponseUpdate.

Minimal reproduction

from agent_framework import ChatResponse, ChatResponseUpdate

updates = [
    ChatResponseUpdate(contents=[Content.from_text(text="Hello")], role="assistant"),
    ChatResponseUpdate(contents=[Content.from_text(text=" How can I help you?")]),
]
response = ChatResponse.from_updates(updates)
print(response.text)

This is the example in python/packages/core/agent_framework/_types.py, in the ChatResponse.from_updates docstring.

Expected behavior and proposed correction

Import Content in the example's existing import statement so the copied block prints Hello How can I help you?. This is a one-line documentation correction with no runtime or public API changes; the desired import is already determined by the example's existing expressions.

Verification and AI assistance

Reproduced against current main commit 91ab44faa4824a30247d00c341f3498ba46b1ca3 on Python 3.13.16. The actual source docstring code block was extracted and executed in an empty namespace. It raises NameError before the import correction and prints the documented output after it. No model calls, credentials, or services were used.

Related open PRs, including the work-in-progress comment corrections in #8985, were checked by their actual changed files and patches; none includes this import correction. OpenAI Codex assisted with analysis, the correction, verification, and this report. I am preparing the focused documentation contribution.

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: Python

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions