Skip to content

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

Closed

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

Activity

  1. added
    bugSomething isn't working
    pythonPull requests for the Python Semantic Kernel
    on Nov 8, 2024
  2. changed the title [-]Python Bug: Serialized _Chat Content_ types incompatible with .NET[/-] [+].Net: Python Bug: Serialized _Chat Content_ types incompatible with .NET[/+] on Nov 9, 2024
  3. added
    kernelIssues or pull requests impacting the core kernel
    and removed
    .NETIssue or Pull requests regarding .NET code
    on Nov 9, 2024
  4. changed the title [-].Net: Python Bug: Serialized _Chat Content_ types incompatible with .NET[/-] [+]Python Bug: Serialized _Chat Content_ types incompatible with .NET[/+] on Nov 9, 2024
  5. added
    sk team issueA tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)
    on Nov 9, 2024
  6. github-actions commented on Feb 10, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open for 90 days with no activity.

  7. added
    staleIssue is stale because it has been open for a while and has no activity
    on Feb 10, 2025
  8. github-actions commented on Feb 25, 2025

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions