I tried this on R54.1.4 and came across a similar error but fixed it by appending .toString() to $seq. Below is the updated formula code.
//creates a condition for 1 minute of time encompassing 30 seconds on either side of a transition
$Transition = $CompressorStage.toCondition().beforeStart(0.5min).afterStart(1min)
//Assigns the mode on both sides of the step change to a concatenated string that is a property of the capsule.
$Transition
.transform( $cap -> $cap.setProperty('StartModeEndMode',
$CompressorStage.toCondition()
.toGroup($cap, CAPSULEBOUNDARY.INTERSECT)
.reduce("", ($seq, $stepCap) -> $seq.toString() +
$stepCap.getProperty('Value')
//Changes the format of the stage names for more clear de-lineation as a property in the capsules pane.
.replace('STAGE 1','-STAGE1-').replace('STAGE 2','-STAGE2-').replace('TRANSITION','-TRANSITION-').replace('OFF','-OFF-')
)))