A workaround is to pass the max retry count as a parameter in the HTTP request when you add tasks to TaskQueue. Then, you can detect if is the last attempt comparing the header attribute "X-AppEngine-TaskRetryCount" with your custom param:
Boolean isLastAttempt = (taskRetryCount == (maxRetryCount - 1));
Not exactly a good design approach though...