I tested what would happen if my mod does not attempt to write the schedule or group when it changes the loaded for an unloaded wagon (or vice versa). When I have it load at an interrupt stop, the temporary record for the interrupt stop stays in the schedule, but when the train is reassembled and set back to automatic, it starts at the beginning of the schedule anyways.
Currently, the script writes the schedule if there is one (including temporary stops and which record is next, and erases interrupts), then writes the group if there is one (which erases the temporary stops in the schedule and resets to the first record, and adds interrupt definitions), and then sets the train to automatic mode.
If I don't set the group, then the schedule gets set and the train stays at the temporary stop but no longer has any interrupts defined. If I don't set the schedule, but do set the group, then it's just like it is now. If I set neither, then the train retains the temporary stop and the group but still departs to the first schedule entry, without removing the temporary stop it just left.
There is no winning with the current broken state of the API, sorry.