Skip to content

Conversation

@larohra
Copy link
Contributor

@larohra larohra commented Dec 5, 2025

Motivation and Context

This PR addresses the following bugs -

  • Consolidating serialization for DurableState schema to use constants.
  • Fix the created_at bug where the timestamp for each response content was always getting updated for each reply.
  • Added a comment for the Streaming example.

Description

Fixes #2483 and #2644

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.

@larohra larohra requested a review from a team as a code owner December 5, 2025 20:05
Copilot AI review requested due to automatic review settings December 5, 2025 20:05
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Dec 5, 2025
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Dec 5, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/azurefunctions/agent_framework_azurefunctions
   _constants.py610100% 
   _durable_agent_state.py45913071%75, 82–83, 103–104, 130–132, 149, 159–160, 167–168, 176–177, 185–186, 193–194, 200–201, 207–208, 212–213, 220–223, 229, 231, 265, 276, 294, 298, 300, 302, 304, 307–313, 356, 419, 430–431, 440–443, 445, 471–472, 475, 477, 482, 541–542, 544, 602, 674, 685, 756, 758, 835, 838, 860–861, 864, 872, 875, 902, 916, 939–941, 944, 954–958, 960–963, 965, 968, 989–990, 993, 1001, 1004, 1022, 1025, 1029, 1032, 1051, 1054, 1063, 1066, 1108, 1111, 1115, 1118, 1138–1139, 1142, 1150, 1153, 1188, 1193–1195, 1199, 1210, 1218, 1241, 1244, 1251, 1254, 1273, 1276, 1280, 1283–1285
TOTAL16283254684% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2324 130 💤 0 ❌ 0 🔥 57.323s ⏱️

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 consolidates and fixes serialization for the DurableState schema by introducing centralized constants, fixing a created_at timestamp bug, and improving documentation for streaming examples.

Key changes:

  • Introduces DurableStateFields, ContentTypes, and ApiResponseFields constant classes to eliminate hardcoded field names and ensure consistency across serialization/deserialization
  • Fixes the created_at bug where DurableAgentStateMessage.from_run_request was incorrectly defaulting to current time instead of preserving None when no timestamp was provided
  • Moves DurableAgentStateEntryJsonType enum to the top of the file for better code organization
  • Updates streaming example documentation to clarify in-memory store limitations and suggest distributed alternatives

Reviewed changes

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

Show a summary per file
File Description
python/packages/azurefunctions/agent_framework_azurefunctions/_constants.py Adds comprehensive constant classes for JSON field names, content type discriminators, and API response fields to centralize serialization constants
python/packages/azurefunctions/agent_framework_azurefunctions/_durable_agent_state.py Replaces all hardcoded strings with constants, fixes created_at handling in DurableAgentStateMessage.from_run_request, moves enum definition, and updates correlation_id type to allow None in DurableAgentStateResponse
python/packages/azurefunctions/tests/test_entities.py Adds tests to verify created_at field handling in DurableAgentStateMessage.from_run_request with both None and valid timestamp values
python/samples/getting_started/azure_functions/03_callbacks/function_app.py Clarifies that the in-memory callback store is for streaming examples and suggests Redis or Service Bus for distributed environments
python/samples/getting_started/azure_functions/03_callbacks/README.md Expands documentation to explain streaming nature of the example and recommends distributed alternatives for production use

Copy link
Member

@cgillum cgillum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments below.

Also, is the python/uv.lock change required? I can't view it in GitHub because it's too big, and I worry that it will create merge conflict headaches. Please remove that change if it's not required.

@larohra larohra requested a review from moonbox3 December 8, 2025 22:33
@larohra larohra added this pull request to the merge queue Dec 8, 2025
Merged via the queue into microsoft:main with commit 71d9d26 Dec 8, 2025
24 checks passed
@larohra larohra deleted the fix-created-at-bug branch December 8, 2025 22:44
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 python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Timestamp in Durable Entity data is updated with every call

4 participants