def serialize(self, value: Any) -> str:
        """Serialize while prioritizing JSON, falling back to Pickle."""
        try:
            return super().serialize(value)
        except Exception:
            return base64.b64encode(pickle.dumps(value)).decode("utf-8")
Serialize while prioritizing JSON, falling back to Pickle.
llama-index-core/llama_index/core/workflow/context_serializers.py