Python: [Breaking] Simplified Content types to a single class with classmethod constructors.#3252
Merged
eavanvalkenburg merged 7 commits intomicrosoft:mainfrom Jan 20, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the Content model in the Python Agent Framework, replacing the old inheritance-based Content types (derived from BaseContent) with a single Content class that uses classmethods to create specific content types. This is a significant architectural change that modernizes the content type system.
Changes:
- Replaced multiple Content classes (TextContent, DataContent, FunctionCallContent, etc.) with a single
Contentclass with factory methods (from_text, from_data, from_function_call, etc.) - Updated all code references from the old class-based approach to the new classmethod-based approach
- Changed attribute name from
detailstousage_detailsin UsageContent - Updated dependency versions in uv.lock (anthropic, azure-core, huggingface-hub, identify, langfuse, librt, litellm, mem0ai, openai-agents, openai-chatkit, plotly, polars, py2docfx, regex, ruff, uv)
- Updated TypeScript types to match the new Content structure
- Fixed observability settings usage in lightning package
Reviewed changes
Copilot reviewed 121 out of 123 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/uv.lock | Updated package dependency versions |
| python/samples (multiple files) | Updated from old Content classes to new Content.from_* factory methods |
| python/packages (multiple test files) | Updated test assertions and imports to use new Content model |
| python/packages/ollama | Updated OllamaChatClient to use new Content type checking |
| python/packages/devui | Updated TypeScript types and Python mapper to use new Content structure |
| python/packages/declarative | Updated loader to use new Content factory methods |
| python/packages/lab/lightning | Fixed observability settings API usage |
4cb5c39 to
dcf83e0
Compare
Member
4ddd0d9 to
a42a3e5
Compare
moonbox3
approved these changes
Jan 20, 2026
5254138 to
fb03609
Compare
giles17
approved these changes
Jan 20, 2026
giles17
approved these changes
Jan 20, 2026
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…assmethod constructors. (microsoft#3252) * ported Content to a new model * fixed linting * fixes * fixed data format handling * fix for 3.10 mypy * fix * fix int test
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 and Context
Replaced all old Content types (derived from BaseContent) to a single Content
with classmethods to create specific ones.
This gives chat client builders the option* to create custom types without having that abstracted. They can put in some other value for the type and drop any other fields into additional_propertiers.
*: this will not work for all clients, since those won't know what to do with them, but they can internally create and parse them.
Description
Contribution Checklist