This is an interesting issue you’ve found! The problem is that SCAMP doesn’t pass the duration to the synthdef at the start of the note; it just sets the gate on and off. For your use case, and other similar use cases, this is a bit of an issue.
A good work around for now might be to use an extra playback parameter, and pass it the duration of the note multiplied by the beat length of the current clock, e.g. in Python:
sc_inst.play_note(pitch, volume, duration, {"param_dur": duration * current_clock().beat_length})
It’s a little hacky and redundant, but it should pass along the tempo-modified duration to the dur argument in your SynthDef.
Let me know if that works, and if it makes sense!