Skip to content

Python: fix(core): forward annotations and metadata in Content.from_dict raw-data path - #8668

Closed
Sehastrajit (Sehastrajit-S) wants to merge 1 commit into
microsoft:mainfrom
Sehastrajit-S:fix-raw-data-content-metadata
Closed

Sehastrajit (Sehastrajit-S) wants to merge 1 commit into
microsoft:mainfrom
Sehastrajit-S:fix-raw-data-content-metadata

Conversation

@Sehastrajit-S

Copy link
Copy Markdown

Summary

  • Content.from_dict popped annotations, additional_properties, and raw_representation off the input mapping but never passed them through to from_data() when handling raw-data content, silently dropping them.
  • from_data() already accepts all three as keyword arguments, so this change just forwards what from_dict had already extracted.
  • Fixes Python: raw-data content mappings lose annotations and attachment metadata #8632

Test plan

  • Added test_content_from_dict_data_preserves_metadata covering both the Content.from_dict and Message(...) parsing paths from the issue repro
  • uv run poe test -P core (5642 passed)
  • uv run poe syntax -P core (format + lint clean)
  • uv run poe pyright -P core (0 errors)

…data path

Content.from_dict popped annotations, additional_properties, and
raw_representation off the input mapping but never passed them to
from_data() when handling raw-data content, silently dropping them.
from_data() already accepts all three as keyword arguments, so this
just forwards what was already extracted.

Fixes microsoft#8632

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.

Copilot review overview

🟢 Approval recommended

The focused fix has regression coverage and no unresolved issues.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes metadata loss when parsing raw-data content through Content.from_dict and Message.

Changes:

  • Forwards annotations, additional properties, and raw representations to Content.from_data.
  • Adds regression coverage for both parsing paths.
File Description
python/​packages/​core/​tests/​core/​test_types.py Tests metadata preservation across both parsing paths.
python/​packages/​core/​agent_framework/​_types.py Preserves metadata during raw-data deserialization.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot changed the title fix(core): forward annotations and metadata in Content.from_dict raw-data path Python: fix(core): forward annotations and metadata in Content.from_dict raw-data path Sep 23, 2026
@Sehastrajit-S

Copy link
Copy Markdown
Author

Closing as a duplicate: #8634 fixes the same issue (#8632) with an identical core change (forwarding annotations/additional_properties/raw_representation into from_data() in Content.from_dict), and it was opened first with all substantive CI checks passing.

This branch was previously deployed

1 inactive deployment
github-app-auth — 2348b56d Deployed Sep 23, 2026 by Sehastrajit-S via team_check #5116
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.

Python: raw-data content mappings lose annotations and attachment metadata

2 participants