-
Notifications
You must be signed in to change notification settings - Fork 871
.NET: Add TTLs to durable agent sessions #2679
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces automatic session cleanup using Time-To-Live (TTL) functionality for Durable Agent sessions, addressing the issue of unbounded state accumulation in storage. The feature provides configurable, automatic cleanup of idle agent sessions using scheduled entity signals.
Key changes:
- Added configurable TTL support with default (30 days) and per-agent type overrides
- Implemented automatic state deletion using scheduled entity signals that reschedule themselves
- Added comprehensive logging for TTL operations and expiration tracking
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.DurableTask.IntegrationTests/TimeToLiveTests.cs | Integration tests verifying TTL expiration and reset behavior |
| dotnet/src/Microsoft.Agents.AI.DurableTask/State/DurableAgentStateData.cs | Added ExpirationTime property to track session expiration |
| dotnet/src/Microsoft.Agents.AI.DurableTask/ServiceCollectionExtensions.cs | Registered DurableAgentsOptions for dependency injection |
| dotnet/src/Microsoft.Agents.AI.DurableTask/Logs.cs | Added logging methods for TTL operations (expiration updates, scheduling, deletion) |
| dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentsOptions.cs | Added DefaultTimeToLive and MinimumTimeToLiveSignalDelay properties with per-agent TTL support |
| dotnet/src/Microsoft.Agents.AI.DurableTask/AgentEntity.cs | Implemented TTL logic with expiration tracking, deletion scheduling, and automatic rescheduling |
| dotnet/samples/AzureFunctions/01_SingleAgent/Program.cs | Updated sample to demonstrate per-agent TTL configuration (1 hour) |
| docs/features/durable-agents/durable-agents-ttl.md | Comprehensive documentation explaining TTL feature, configuration, behavior, and best practices |
Motivation and Context
The Durable Task extension for Agent Framework ("Durable Agents") provides built-in thread storage. However, there's no clear way to cleanup the thread storage data, which will accumulate in either the Azure Storage account or in the Durable Task Scheduler resource owned by the user.
Applies to #2615
Description
This PR introduces automatic session cleanup using TTLs, implemented using scheduled entity signals. See the documentation file in the PR for more details.
Contribution Checklist