Replace private encode/decode imports with pickle serialization#28
Merged
pamelafox merged 1 commit intoAzure-Samples:mainfrom Mar 4, 2026
Merged
Replace private encode/decode imports with pickle serialization#28pamelafox merged 1 commit intoAzure-Samples:mainfrom
pamelafox merged 1 commit intoAzure-Samples:mainfrom
Conversation
Remove usage of private agent_framework._workflows._checkpoint_encoding functions (encode_checkpoint_value, decode_checkpoint_value) in the PostgreSQL checkpoint storage examples, as these are internal APIs not meant for public use (see microsoft/agent-framework#4428). Instead, serialize WorkflowCheckpoint objects directly with pickle and store as BYTEA in PostgreSQL. This is simpler than reimplementing the pickle+base64 hybrid that the private API uses, and avoids depending on internals that may break across releases.
Contributor
|
lgtm! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove usage of private
agent_framework._workflows._checkpoint_encodingfunctions (encode_checkpoint_value,decode_checkpoint_value) in the PostgreSQL checkpoint storage examples, per microsoft/agent-framework#4428. These are internal APIs not meant for public use.Changes
Both
examples/workflow_hitl_checkpoint_pg.pyandexamples/spanish/workflow_hitl_checkpoint_pg.py:from agent_framework._workflows._checkpoint_encoding import decode_checkpoint_value, encode_checkpoint_valuefrom psycopg.types.json import Jsonbimport picklefor direct serializationJSONBtoBYTEAsince we're storing binary pickle datapickle.dumps(checkpoint)instead ofencode_checkpoint_value(checkpoint.to_dict())+Jsonb()pickle.loads(row["data"])instead ofWorkflowCheckpoint.from_dict(decode_checkpoint_value(...))Rationale
Per the MAF maintainer's response,
encode_checkpoint_value/decode_checkpoint_valueare intentional internals — custom checkpoint storage backends should implement their own serialization.WorkflowCheckpointcontains live framework objects (WorkflowMessage,WorkflowEvent, etc.) that aren't directly JSON-serializable, so straight JSON isn't an option without reimplementing the same pickle+base64 hybrid the private API uses internally. Directpickle→BYTEAis the simplest correct approach and mirrors what MAF's built-inFileCheckpointStoragedoes under the hood.