4. Given that $\alpha, \beta$ are both acute angles, and
$$
(1+\tan \alpha)(1+\tan \beta)=2 \text{.}
$$

Then $\alpha+\beta=$ $\qquad$
4. $\frac{\pi}{4}$.

From the given information, we have
$$
\begin{array}{l}
\tan \alpha + \tan \beta = 1 - \tan \alpha \cdot \tan \beta \\
\Rightarrow \tan (\alpha + \beta) = \frac{\tan \alpha + \tan \beta}{1 - \tan \alpha \cdot \tan \beta} = 1 .
\end{array}
$$

Since $\alpha, \beta \in \left(0, \frac{\pi}{2}\right)$, therefore, $\alpha + \beta = \frac{\pi}{4}$.