Skip to content

Python Bug: Serialized _Chat Content_ types incompatible with .NET #9627

@crickman

Description

@crickman

Describe the bug
Python and .NET content types are not cross compatible when serialized to JSON.

Repro #1

  1. Serialize python history as JSON
  2. Deserialize JSON in .NET

Repro #2

  1. Serialize .NET history as JSON
  2. Deserialize JSON in .python

Expected behavior
Content types are compatible across platforms

Screenshots

Image

Content Type Compatibility.xlsx
dotnet-history.json
python-history.json

The yellow highlighted items are ones that might be easily addressed with case (upper/lower/snake) conversion (for example, using an ignore case option on deserialization) and also not writing null/empty values.

The pink highlighted items are more structural. Some might be easily addressed (don't write inner_content); while others may challenging to unwind

In addition:

  • .NET utilizes HTML encoding for text content.
  • Meta-data keys differ across platform based on the OpenAI SDK

Additional context
This has compatibility has long been identified as desired, but not directly analyzed or addressed. Performed analysis for critical types as part of agent framework serialization feature and capturing here:

  • KernelContent
  • ChatMessageContent
  • TextContent
  • FunctionCallContent
  • FunctionResultContent

Other content types include:

  • AnnotationContent
  • AudioContent
  • BinaryContent
  • FileReferenceContent
  • ImageContent

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchat historykernelIssues or pull requests impacting the core kernelkernel.corepythonPull requests for the Python Semantic Kernelsk team issueA tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)staleIssue is stale because it has been open for a while and has no activity

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions