Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net Agents - AgentChat Serialization #7457

Merged
merged 71 commits into from
Nov 8, 2024
Merged

Conversation

crickman
Copy link
Contributor

@crickman crickman commented Jul 25, 2024

Motivation and Context

Support ability to capture and restore AgentChat history:

https://github.com/microsoft/semantic-kernel/blob/main/docs/decisions/0048-agent-chat-serialization.md

Description

Introduces AgentChatSerializer that supports serialization and deserialization of entire conversation state.

{
  "Participants": [
    {
      "Id": "asst_YaLY1TRmxsIReVa0BiuhEDAj",
      "Name": "agent-1",
      "Type": "Microsoft.SemanticKernel.Agents.OpenAI.OpenAIAssistantAgent"
    },
    {
      "Id": "1e884890-c344-4bc0-9367-068c482a499d",
      "Name": "agent-2",
      "Type": "Microsoft.SemanticKernel.Agents.ChatCompletionAgent"
    }
  ],
  "History": [{"Role":{"Label":"user"},"Items":[{"$type":"TextContent","Text":"..."}],"ModelId":"gpt-35-turbo-16k"},{"Role":{"Label":"assistant"},"Items":[{"$type":"TextContent","Text":"..."}],"ModelId":"gpt-35-turbo-16k"}],
  "Channels": [
    {
      "ChannelKey": "4kjDzpCpeOLUNbsSUisHd9cphSzEAb6Hxdnmr\u002Bem1Jw=",
      "ChannelType": "Microsoft.SemanticKernel.Agents.OpenAI.OpenAIAssistantChannel",
      "ChannelState": "thread_ZSF1ovTVzyYy8cg9GEwmDWgy"
    },
    {
      "ChannelKey": "Vdx37EnWT9BS\u002BkkCkEgFCg9uHvHNw1\u002BhXMA4sgNMKs4=",
      "ChannelType": "Microsoft.SemanticKernel.Agents.ChatHistoryChannel",
      "ChannelState": [{"Role":{"Label":"user"},"Items":[{"$type":"TextContent","Text":"..."}],"ModelId":"gpt-35-turbo-16k"},{"Role":{"Label":"assistant"},"Items":[{"$type":"TextContent","Text":"..."}],"ModelId":"gpt-35-turbo-16k"}]
    }
  ]
}

Includes sample showing serialization and deserialization with ChatCompletionAgent and OpenAIAssistantAgent partipating on the same chat, as well as a chat that includes ChatCompletionAgent that calls a plug-in.

Contribution Checklist

@crickman crickman added .NET Issue or Pull requests regarding .NET code experimental Associated with an experimental feature enhancement agents labels Jul 25, 2024
@crickman crickman self-assigned this Jul 25, 2024
@crickman crickman linked an issue Jul 25, 2024 that may be closed by this pull request
@crickman crickman added this pull request to the merge queue Nov 8, 2024
Merged via the queue into main with commit b67eb84 Nov 8, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents enhancement experimental Associated with an experimental feature Ignite .NET Issue or Pull requests regarding .NET code
Projects
Status: Sprint: Done
Development

Successfully merging this pull request may close these issues.

.Net Agents: AgentChat Serialization
5 participants