Python: serialize durabletask options response format - #6819
Python: serialize durabletask options response format#6819VectorPeak (VectorPeak) wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes durable JSON transport serialization for RunRequest.options["response_format"] by converting Pydantic model classes to the existing {module, qualname} marker format during to_dict(), and restoring them during from_dict(). This ensures durable requests can safely cross a JSON boundary without embedding non-serializable Python class objects.
Changes:
- Add
_serialize_options()to convertoptions["response_format"](when it’s a Pydantic model class) into the durable marker dict duringRunRequest.to_dict(). - Add
_deserialize_options()to restoreoptions["response_format"]marker dicts back into the Pydantic model class duringRunRequest.from_dict(). - Add a regression test that round-trips
to_dict() -> json.dumps/loads -> from_dict()foroptions["response_format"].
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/packages/durabletask/agent_framework_durabletask/_models.py | Serializes/deserializes the durable options["response_format"] value to cross JSON boundaries. |
| python/packages/durabletask/tests/test_models.py | Adds regression coverage for JSON round-tripping options["response_format"]. |
1466fe4 to
7e52b8f
Compare
|
VectorPeak (@VectorPeak) please have a look at the failing CI/CD checks. |
|
Thanks for the heads up. I fixed the failing Local validation passed:
The new GitHub Actions |
Motivation & Context
RunRequest.to_dict()already serializes the top-levelresponse_format, butoptions["response_format"]can still contain a raw Pydantic model class.That means a durable request like this cannot cross the JSON transport boundary:
Calling
json.dumps(request.to_dict())raises because the model class is not JSON serializable. The affected path is:Description & Review Guide
What are the major changes?
options["response_format"]using the same module/qualname marker already used for top-levelresponse_format.RunRequest.from_dict()when it can be resolved.response_format.What is the impact of these changes?
options["response_format"]can cross the JSON boundary.response_formatbehavior is unchanged.What do you want reviewers to focus on?
response_formatoption rather than recursively transforming arbitrary options.Related Issue
Fixes #6821
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) - a workflow keeps the label and title prefix in sync automatically.