Have Passive monitor iRule skipped if url contains

We are trying to setup a passive iRule that will mark a load balanced member down if it gets a number of errors from the server. I found an example of one and it seems to work OK however our developers stated that some of the API calls the develop can return a 500 error and that is to be expected. Luckily all the API stuff is under a /services/ url. Is there an easy way to take the code below and have it just exit the rule if the url contains /services/ in the url?

when HTTP_REQUEST {
   if { not [info exists orig_request]} {
       set orig_request [HTTP::request]
   }
 }
when HTTP_RESPONSE {
    if { [HTTP::status] >= 500 } {
       set failures [session lookup dest_addr [LB::server addr]]
      if { $failures >= 3 } {
          LB::down
        log local0.warning "Pool member down for '[LB::server addr]' - May want to investigate"  
       } else {
          session add dest_addr [LB::server addr] [incr failures]
         LB::detach
         HTTP::retry $orig_request
       }
   }
}

Reference URL:

F5 Friday - Eavesdropping on avialability

Perhaps adding something like this will allow the traffic to continue on. It would be another if statement in your existing code

when HTTP_REQUEST {
    if { [HTTP::uri] contains "/services/ url" } {
        default pool XYZ
     }
    }

You could, at the top of HTTP_RESPONSE, do the following:

when HTTP_RESPONSE {
    if { [HTTP::path] starts_with "/services/" } {
        return
    }
        
    ... all of your code here ...
}

Alternatively, you could wrap all of your code in a negating if:

when HTTP_RESPONSE {
    if { not ([HTTP::path] starts_with "/services/") } {
        ... all of your code in here ...
    }
}

As a side comment, I seem to be getting a TCL error when trying to increment:

TCL error: /common/count_server_down  - expected integer but got "" while executing "incr failures"

I have since found this F5 Solution: F5 - SOL7440 Is one solution better than another?