Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

MAF-Persisting-01-Simple

This sample demonstrates how to persist (serialize) an AgentThread to disk and later reload it to resume a conversation with the same agent type.

What it shows

  • Creating an AgentThread and running a prompt
  • Serializing the thread JSON to agent_thread.json in the application folder
  • Rehydrating the thread by deserializing the JSON and calling agent.DeserializeThread(...)
  • Continuing the conversation with the resumed thread

Setup

  1. Configure your AI provider credentials (example using dotnet user-secrets):
cd samples/MAF/MAF-Persisting-01-Simple
dotnet user-secrets set "AzureOpenAI:Endpoint" "https://<your-endpoint>.openai.azure.com/"
dotnet user-secrets set "AzureOpenAI:Deployment" "gpt-5-mini"
# az login is required (samples use AzureCliCredential)
  1. Build and run:
dotnet build
dotnet run

Notes

  • The sample relies on shared helper files (ChatClientProvider.cs, StreamConsoleHelper.cs, ResponseClientProvider.cs) that are linked into the project via csproj compile includes.
  • The saved thread file agent_thread.json will be created in the app working directory. Treat this file as sensitive — it contains conversation history.

Troubleshooting

  • If you see authentication errors, verify your user-secrets or environment variables are set correctly for your chosen provider.
  • If deserialization fails, ensure you are using the same agent type to deserialize the thread.

Related docs

License: MIT