Repository navigation
Python: Preserve metadata in raw-data content mappings - #8634
Yufei (Yufei-Z) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation correctly addresses the reported metadata loss with appropriate regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes #8632 by preserving metadata when raw-data mappings are converted into Content.
Changes:
- Forwards annotations, additional properties, and raw representation through
Content.from_data. - Adds regression coverage for direct and
Message-based parsing.
| File | Description |
|---|---|
python/packages/core/agent_framework/_types.py |
Preserves metadata during raw-data mapping conversion. |
python/packages/core/tests/core/test_types.py |
Tests metadata retention and input immutability. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
@microsoft-github-policy-service agree |
|
Yufei (@Yufei-Z) This branch currently conflicts with |
|
Yufei (@Yufei-Z) Thanks for the contribution. The branch is still conflicted with |
Motivation & Context
Raw-data mappings passed to
Content.from_dictorMessagelose annotations and additional properties such as attachment filenames, even though equivalentContent.from_datacalls preserve them.Description & Review Guide
annotations,additional_properties, andraw_representationto the existingfrom_dataconstructor when parsing raw-data mappings.Message.Local verification: both regression cases fail before the fix; all 331 type tests and 42 serialization tests pass afterward. The core wheel builds, Ruff passes, strict source Pyright reports no errors, and all five configured test type checkers pass for the changed test file. The full unit and integration suites are left to CI.
Related Issue
Fixes #8632
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.