Skip to content

Python: Preserve metadata in raw-data content mappings - #8634

Closed
Yufei (Yufei-Z) wants to merge 1 commit into
microsoft:mainfrom
Yufei-Z:codex/fix-data-content-metadata
Closed

Yufei (Yufei-Z) wants to merge 1 commit into
microsoft:mainfrom
Yufei-Z:codex/fix-data-content-metadata

Conversation

@Yufei-Z

Copy link
Copy Markdown

Motivation & Context

Raw-data mappings passed to Content.from_dict or Message lose annotations and additional properties such as attachment filenames, even though equivalent Content.from_data calls preserve them.

Description & Review Guide

  • What are the major changes? Forward annotations, additional_properties, and raw_representation to the existing from_data constructor when parsing raw-data mappings.
  • What is the impact of these changes? Raw-data mappings retain their supplied metadata while preserving the existing base64 encoding and subclass construction behavior.
  • What do you want reviewers to focus on? The metadata forwarding and regression coverage for both direct content parsing and dictionary contents passed to 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

  • 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 is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • 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 balanced review requested due to automatic review settings September 22, 2026 08:43
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 22, 2026

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 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.

@Yufei-Z

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@eavanvalkenburg

Copy link
Copy Markdown
Member

Yufei (@Yufei-Z) This branch currently conflicts with main. Please merge or rebase current main and resolve the conflicts before requesting another review.

@eavanvalkenburg

Copy link
Copy Markdown
Member

Yufei (@Yufei-Z) Thanks for the contribution. The branch is still conflicted with main, with no update since the September 28 request. I’m closing this for now; please reopen once the conflicts are resolved and the branch is ready for review.

This branch was previously deployed

1 inactive deployment
github-app-auth — 6f192f90 Deployed Sep 22, 2026 by Yufei-Z via limit_open_prs #1473
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

3 participants