4. Given point $A(0,2)$ is an external point of circle $M: x^{2}+y^{2}-2 a x-2 a y=0(a>0)$, and there exists a point $T$ on circle $M$ such that $\angle M A T=45^{\circ}$. Then the range of the real number $a$ is $\qquad$.
4. $[\sqrt{3}-1,1)$.

The equation of circle $M$ can be transformed into
$$
(x-a)^{2}+(y-a)^{2}=2 a^{2},
$$

with the center at $M(a, a)$ and the radius as $\sqrt{2} a$. When points $A, M, T$ are collinear, $\angle M A T=0^{\circ}$ is the smallest. When $A T$ is tangent to circle $M$, $\angle M A T$ is the largest. For there to be a point $T$ on circle $M$ such that $\angle M A T=45^{\circ}$, it is only necessary that when $\angle M A T$ is the largest, it satisfies $45^{\circ} \leqslant \angle M A T<90^{\circ}$.
$$
M A=\sqrt{(a-0)^{2}+(a-2)^{2}}=\sqrt{2 a^{2}-4 a+4},
$$

At this time, line $A T$ is tangent to circle $M$, so
$$
\sin \angle M A T=\frac{M T}{M A}=\frac{\sqrt{2} a}{\sqrt{2 a^{2}-4 a+4}} .
$$

Since $45^{\circ} \leqslant \angle M A T<90^{\circ}$, we have $\frac{\sqrt{2}}{2} \leqslant \sin \angle M A T<1$, so
$$
\frac{\sqrt{2}}{2} \leqslant \frac{\sqrt{2} a}{\sqrt{2 a^{2}-4 a+4}}<1,
$$

Solving this, we get $\sqrt{3}-1 \leqslant a<1$.