Skip to content

.NET: [Durable Agents] Filter empty AIContent from durable agent state responses#4670

Merged
cgillum merged 3 commits intomainfrom
cgillum/fix-empty-aicontent-state
Mar 13, 2026
Merged

.NET: [Durable Agents] Filter empty AIContent from durable agent state responses#4670
cgillum merged 3 commits intomainfrom
cgillum/fix-empty-aicontent-state

Conversation

@cgillum
Copy link
Member

@cgillum cgillum commented Mar 13, 2026

Prevent opaque AIContent objects (e.g., with only RawRepresentation set) from being stored in durable entity state, where they serialize to empty JSON payloads. Base AIContent instances are kept only if they have Annotations or AdditionalProperties.

Fixes #4481, which has more context

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.

Prevent opaque AIContent objects (e.g., with only RawRepresentation set)
from being stored in durable entity state, where they serialize to empty
JSON payloads. Base AIContent instances are kept only if they have
Annotations or AdditionalProperties.

Fixes #4481
Copilot AI review requested due to automatic review settings March 13, 2026 00:42
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

Updates DurableTask state serialization to avoid persisting response messages that contain only non-serializable/opaque AIContent, reducing noisy/empty durable state entries.

Changes:

  • Filter AgentResponse.Messages during DurableAgentStateResponse.FromResponse to keep only messages with serializable content.
  • Add unit tests covering the filtering behavior (drop opaque-only messages; keep mixed content; keep base AIContent when it has annotations/additional properties).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dotnet/src/Microsoft.Agents.AI.DurableTask/State/DurableAgentStateResponse.cs Filters out response messages that would serialize as empty/meaningless state.
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/State/DurableAgentStateResponseTests.cs Adds test coverage for the new filtering rules.

You can also share your feedback on Copilot code review. Take the survey.

@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Mar 13, 2026
@cgillum cgillum requested a review from a team March 13, 2026 16:58
@cgillum cgillum added this pull request to the merge queue Mar 13, 2026
Merged via the queue into main with commit c67d352 Mar 13, 2026
30 of 33 checks passed
@cgillum cgillum deleted the cgillum/fix-empty-aicontent-state branch March 13, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation durabletask .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [DurableAgents] Tool call content items serialize as empty objects in entity state

5 participants