Skip to content

Conversation

@cgillum
Copy link
Member

@cgillum cgillum commented Dec 6, 2025

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

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@cgillum cgillum added the azure-functions Issues and PRs related to Azure Functions label Dec 6, 2025
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Dec 6, 2025
@cgillum cgillum marked this pull request as ready for review December 8, 2025 16:50
Copilot AI review requested due to automatic review settings December 8, 2025 16:50
Copy link
Contributor

Copilot AI left a 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

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

Labels

azure-functions Issues and PRs related to Azure Functions documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants