Skip to content

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

Open

Description

@Yufei-Z

Description

Passing a raw-data content mapping to Content.from_dict or Message silently drops annotations, additional_properties, and raw_representation. The equivalent Content.from_data call preserves all three.

This loses useful file metadata such as additional_properties["filename"], which file adapters and Content Understanding use to identify attachments.

Code Sample

from agent_framework import Content, Message

raw = object()
data = {
    "type": "data",
    "data": b"test data",
    "media_type": "text/plain",
    "annotations": [{"type": "citation", "title": "Source document", "file_id": "file-123"}],
    "additional_properties": {"filename": "document.txt"},
    "raw_representation": raw,
}

for content in (Content.from_dict(data), Message("user", [data]).contents[0]):
    print(content.annotations, content.additional_properties, content.raw_representation is raw)

Expected: the supplied annotations, {"filename": "document.txt"}, and True.

Actual: None {} False for both parsing paths. The binary payload itself is correctly encoded.

Error Messages / Stack Traces

No exception is raised; the metadata is silently discarded.

Package Versions

agent-framework-core 1.19.0, reproduced from main at 98a982a.

Python Version

Python 3.12.13, macOS arm64.

Additional Context

The raw-data branch in Content.from_dict delegates to cls.from_data without forwarding the three metadata fields it has already extracted. I am preparing a small fix with regression coverage for both direct parsing and Message inputs. Passing a Content.from_data(...) instance directly is a workaround.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 22, 2026
  2. feiiiiii5 commented on Sep 24, 2026

    @feiiiiii5
    Contributor

    I’d like to take this. I’ll verify both Content.from_dict() and Message parsing on the current main, add regression coverage for the three dropped fields, and make the smallest change that preserves the existing from_data() behavior. I’ll keep this separate from unrelated content-mapping work.

  3. feiiiiii5 commented on Sep 24, 2026

    @feiiiiii5
    Contributor

    Thanks for the reports. I checked the current timeline before publishing and found that #8634 already covers this exact change; #8701 has since merged the same fix. I’m withdrawing my planned implementation to avoid a duplicate, and no PR from me is needed for this issue.

  4. github-actions commented on Sep 29, 2026

    @github-actions
    Contributor

    👋 Hi Yufei (@Yufei-Z) — thanks for the report!

    Your report identifies revision 98a982a, which predates merged fix 91fd470 by three days. On current source, your exact sample preserves all three metadata fields through both parsing paths. Because the package metadata still says 1.19.0, use a build containing that fix rather than relying on the version number alone.

    • You reported using: 1.19.0
    • Latest version: 1.19.0
    • Likely fix: 91fd47035684

    If upgrading to the latest release doesn't fix it, please reopen and we'll take another look. 🙏

  5. removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

likely-fixedpythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions