Skip to content

Implement custom serializers for pause/resume checkpoints #3

@rajkumar42

Description

@rajkumar42

Summary

Add support for custom serializers in the checkpoint/pause-resume system. This allows users to define how their custom objects are serialized and deserialized during agent execution pauses.

Context

The current checkpoint system (src/opensymbolicai/checkpoint.py) handles pause/resume for distributed execution. However, it may not gracefully handle custom object types that users define in their agents.

Expected Behavior

Users should be able to register custom serializers:

from opensymbolicai import register_serializer

@register_serializer(MyCustomClass)
class MyCustomSerializer:
    def serialize(self, obj: MyCustomClass) -> dict:
        return {"field": obj.field}
    
    def deserialize(self, data: dict) -> MyCustomClass:
        return MyCustomClass(field=data["field"])

Implementation Hints

  • Add a serializer registry in checkpoint.py
  • Provide a decorator or registration function
  • Fall back to default JSON/pickle behavior if no custom serializer is found
  • Consider using Pydantic's serialization capabilities

Acceptance Criteria

  • Implement serializer registry
  • Add @register_serializer decorator or equivalent API
  • Add unit tests for custom serialization round-trips
  • Add integration test with a real pause/resume cycle
  • Document usage in docstrings

Files to Look At

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions