-
Notifications
You must be signed in to change notification settings - Fork 862
Python: Fix DurableState schema serializations #2670
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
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||
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 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, andApiResponseFieldsconstant classes to eliminate hardcoded field names and ensure consistency across serialization/deserialization - Fixes the
created_atbug whereDurableAgentStateMessage.from_run_requestwas incorrectly defaulting to current time instead of preservingNonewhen no timestamp was provided - Moves
DurableAgentStateEntryJsonTypeenum 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 |
python/packages/azurefunctions/agent_framework_azurefunctions/_durable_agent_state.py
Show resolved
Hide resolved
cgillum
left a comment
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.
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. |
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.
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. |
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.
This last sentence is a little weird. Consider removing it since I think it's mostly adding misinformation.
Motivation and Context
This PR addresses the following bugs -
created_atbug where the timestamp for each response content was always getting updated for each reply.Description
Fixes #2483 and #2644
Contribution Checklist