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.py45813171%75, 82–83, 103–104, 130–132, 153–154, 160–161, 168–169, 176–177, 183–184, 187–188, 193–196, 202–205, 210–211, 214–215, 246, 257, 275, 279, 281, 283, 285, 288–294, 337, 400, 411–412, 421–424, 426, 452–453, 456, 458, 463, 522–523, 525, 583, 655, 666, 737, 739, 816, 819, 841–842, 845, 853, 856, 883, 897, 920–922, 925, 935–939, 941–944, 946, 949, 970–971, 974, 982, 985, 1003, 1006, 1010, 1013, 1032, 1035, 1044, 1047, 1089, 1092, 1096, 1099, 1119–1120, 1123, 1131, 1134, 1169, 1174–1176, 1180, 1191, 1199, 1222, 1225, 1232, 1235, 1254, 1257, 1261, 1264–1266
TOTAL16274253684% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2321 130 💤 0 ❌ 0 🔥 55.528s ⏱️

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.

# =============================================================================
# JSON Field Name Constants for Durable Agent State Serialization
# =============================================================================
# These constants ensure consistent camelCase field names in JSON serialization.
Copy link
Member

Choose a reason for hiding this comment

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

We should add a note here that changing the value of any of these constants is a breaking change.

> **Note:** This is a streaming example that currently uses a local in-memory store for simplicity.
> For distributed environments, consider using Redis, Service Bus, or another pub/sub mechanism for
> callback coordination. For production scenarios you should also persist events to Application
> Insights, Azure Storage, Cosmos DB, or another durable store.
Copy link
Member

Choose a reason for hiding this comment

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

This last sentence is a little weird. Consider removing it since I think it's mostly adding misinformation.

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

3 participants