Files
agent-framework/python/samples/getting_started/threads
Ren Finlayson 539852f81c
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
Python - Merge - Tests / paths-filter (push) Has been cancelled
Python - Merge - Tests / Python Tests - Core (integration, ubuntu-latest, 3.10) (push) Has been cancelled
Python - Merge - Tests / Python Tests - Azure AI (integration, ubuntu-latest, 3.10) (push) Has been cancelled
Python - Merge - Tests / python-integration-tests-check (push) Has been cancelled
Python - Lab Tests / paths-filter (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.10) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.11) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.12) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.13) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (ubuntu-latest, 3.14) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.10) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.11) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.12) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.13) (push) Has been cancelled
Python - Lab Tests / Python Lab Tests (windows-latest, 3.14) (push) Has been cancelled
Check .md links / markdown-link-check (push) Has been cancelled
test
2026-01-24 03:05:12 +11:00
..
2026-01-24 03:05:12 +11:00
2026-01-24 03:05:12 +11:00
2026-01-24 03:05:12 +11:00
2026-01-24 03:05:12 +11:00

Thread Management Examples

This folder contains examples demonstrating different ways to manage conversation threads and chat message stores with the Agent Framework.

Examples

File Description
custom_chat_message_store_thread.py Demonstrates how to implement a custom ChatMessageStore for persisting conversation history. Shows how to create a custom store with serialization/deserialization capabilities and integrate it with agents for thread management across multiple sessions.
redis_chat_message_store_thread.py Comprehensive examples of using the Redis-backed RedisChatMessageStore for persistent conversation storage. Covers basic usage, user session management, conversation persistence across app restarts, thread serialization, and automatic message trimming. Requires Redis server and demonstrates production-ready patterns for scalable chat applications.
suspend_resume_thread.py Shows how to suspend and resume conversation threads, comparing service-managed threads (Azure AI) with in-memory threads (OpenAI). Demonstrates saving conversation state and continuing it later, useful for long-running conversations or persisting state across application restarts.

Environment Variables

Make sure to set the following environment variables before running the examples:

  • OPENAI_API_KEY: Your OpenAI API key (required for all samples)
  • OPENAI_CHAT_MODEL_ID: The OpenAI model to use (e.g., gpt-4o, gpt-4o-mini, gpt-3.5-turbo) (required for all samples)
  • AZURE_AI_PROJECT_ENDPOINT: Azure AI Project endpoint URL (required for service-managed thread examples)
  • AZURE_AI_MODEL_DEPLOYMENT_NAME: The name of your model deployment (required for service-managed thread examples)