How to get call-id of transferred call?

We use an AGI application for transferring calls. The transfer part itself simply executes Dial() and, after Dial returns, pulls some channel variables such as DIALSTATUS and SIPCALLID. For what seems to be an obvious reason, SIPCALLID always contains the call-id of the “main” call in which the transfer was initiated. Is there a way to somehow get the call-id of the transfer itself?

(Asterisk 13.18.2)