Kapacitor TICK Script Alert Node Issues

Hello,
I have a TICK Script to retrieve a field - queue depth of an MQ queue from Influx DB and compare the value with another field - alert threshold also in InfluxDB.
My requirement is if the queue depth is greater than alert threshold then send an alert to an email.

below is a sample of my tick code:

var inCount = stream
    |from()
        .database(db)
        .retentionPolicy(rp)
        .measurement(measurement)
        .groupBy(groupBy)
        .where(whereFilter)
    |eval(lambda: "input_count")
        .as('value')
    |log()
    
var curDepth = stream
    |from()
        .database(db)
        .retentionPolicy(rp)
        .measurement(measurement)
        .groupBy(groupBy)
        .where(whereFilter)
    |eval(lambda: "current_q_depth")
        .as('value')
    |log()    

var data = inCount
    |join(curDepth)
        .as('inCount', 'curDepth')

var trigger = data
    |alert()
        .crit(lambda: "curDepth.value" > "inCount.value")
        .stateChangesOnly()
        .message(message)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)

trigger
    |eval(lambda: float("value"))
        .as('value')
        .keep()
    |influxDBOut()
        .create()
        .database(outputDB)
        .retentionPolicy(outputRP)
        .measurement(outputMeasurement)
        .tag('alertName', name)
        .tag('triggerType', triggerType)

trigger
    |httpOut('output')

As soon as I save this script, it magically gets removed from the Alert Rules and I get an evaluation error in the logs.
Upon debugging, I figured this script give me error at line:

  |alert()
            .crit(lambda: "curDepth.value" > "inCount.value")

For the Alert above, if I change the code to

var crit = 10
.
.
      |alert()
                .crit(lambda: "value" > crit)

This code works and the Alert rule works just fine, sending an email alert.

Now, Can I not do a comparison with dynamic values for alert node? Could you pls. suggest what am I missing or is this feature not supported in TICK Script?

Thanks,
Rav