There's two assumptions in this approach you want to be careful of:
- Sessions always last 30 minutes
- You don't end sessions when the call ends
The safer, and more reliable approach to this would be to store the calls in a database as soon as the agent picks the call up, and then have the script query that database for new calls that come in. You'd want to enable something like a nightly/hourly scheduled job to purge entries from the table that are past your 30 minute threshold.
I'm not able to prove or disprove your existing approach, but based on experience, it could have holes that you'd end up having to deal with down the road.
By the way, I love this concept of sticky agent transfer, and I think I'll be pitching it to our team managers internally.