set_folder_path not working for level sequence spawnable

I am working on a python script to set up a level sequence that contains nested level sequences (one for each shot in a sequence). Those nested level sequences contain actors set up as spawnable so that they only exist for that shot. I want to organise these actors in the scene outliner, by using set_folder_path.

Here’s the equivalent code to what I have in the script:

binding = levelSequence.add_spawnable_from_class(unreal.StaticMeshActor)
actorTemplate = binding.get_object_template()
actorTemplate.set_folder_path("Static Meshes")

Unfortunately, calling set_folder_path on the actor template doesn’t work. If I then query the folder path with get_folder_path, I get None back, so it doesn’t actually get set. The actor template doesn’t have a level associated which, when looking at the code, seem to be fine and should still set the folder path property, yet that doesn’t seem to be the case.

If I open up the sequence, move the time slider to the shot containing the specific nested level sequence, then it spawns the actor from the template (other properties set on the template do get set up properly on the spawned in actor). If I call set_folder_path on that actor, then it does work, exactly as intended. (However if I had first called set_folder_path on the actor template then it seems to break set_folder_path on the actual spawned in actor until I manually move it to a folder via the UI).

So, I then tried adding in all of the bindings, loading in the level sequence, move to the right frame, forcing it to update, then find the spawned in actor, and call set_folder_path on that, all in the same script. Here’s the equivalent code:

binding = levelSequence.add_spawnable_from_class(unreal.StaticMeshActor)
binding.set_name(identifier)
binding.set_display_name(identifier)

unreal.LevelSequenceEditorBlueprintLibrary.open_level_sequence(levelSequence)

playbackParams : unreal.MovieSceneSequencePlaybackParams = unreal.MovieSceneSequencePlaybackParams()
playbackParams.frame = unreal.FrameTime(unreal.FrameNumber(startFrame))
playbackParams.position_type = unreal.MovieScenePositionType.FRAME
playbackParams.update_method = unreal.UpdatePositionMethod.JUMP
unreal.LevelSequenceEditorBlueprintLibrary.set_global_position(playbackParams)

unreal.LevelSequenceEditorBlueprintLibrary.force_update()

spawnedActor = None
allActors = unreal.GameplayStatics.get_all_actors_of_class(unreal.EditorLevelLibrary.get_editor_world(), unreal.Actor)
for actor in allActors:
    if str(actor.get_actor_label()) == identifier:
        spawnedActor = actor
        break

if spawnedActor is not None:
    spawnedActor.set_folder_path("Static Meshes")

What’s weird is that it seems to work. The outliner does then have a folder called “Static Meshes” but the actor isn’t in there. What appears to be happening is that the actor does get its folder path set and the folder gets created, but then as the UI reloads after the script is done, the actor ends up being destroyed and then spawned in again, and now it doesn’t have its folder path set anymore.

If I then manually in the console get a reference to the actor and call set_folder_path, then it does work and the folder path does persist when the actor gets destroyed and spawned in again. So it seems like the folder path doesn’t properly get saved, wherever it needs to be saved, when set in the script. But it does once the UI is fully loaded for that level and level sequence, and it’s then set.

Preferably, I’d just set the folder path on the actor template and that’s it (setting other properties on the actor template does just work) and maybe this is just a bug, or maybe I’m doing something wrong.

Does anyone have a solution to this?

For reference, I am running Unreal 5.5.0-37670630+++UE5+Release-5.5 on Windows 11 (23H2) [10.0.22631.4460] (x86_64)