Make agent compatible with tornado 2.x and 3.x