4. Let $0<\theta<\pi$, then the maximum value of $\sin \frac{\theta}{2}(1+\cos \theta)$ is $\qquad$ .
$$
\begin{array}{l}
\text { 4. } \frac{4}{9} \sqrt{3} \text {. } \\
\sin \frac{\theta}{2}(1+\cos \theta)=2 \sin \frac{\theta}{2} \cos ^{2} \frac{\theta}{2} \\
=\sqrt{2} \cdot \sqrt{2 \sin ^{2} \frac{\theta}{2} \cos ^{2} \frac{\theta}{2} \cos ^{2} \frac{\theta}{2}} \\
\leqslant \sqrt{2} \cdot \sqrt{\left[\frac{2 \sin ^{2} \frac{\theta}{2}+\cos ^{2} \frac{\theta}{2}+\cos ^{2} \frac{\theta}{2}}{3}\right]^{3}} \\
=\sqrt{2} \cdot \sqrt{\left(\frac{2}{3}\right)^{3}}=\sqrt{2} \cdot \frac{2}{3} \sqrt{\frac{2}{3}} \\
=\frac{4 \sqrt{3}}{9} \text {. } \\
\end{array}
$$

The equality holds if and only if $2 \sin ^{2} \frac{\theta}{2}=\cos ^{2} \frac{\theta}{2}$, i.e., $\theta=2 \operatorname{arcctg} \sqrt{2}$. Therefore, the answer should be $\frac{4 \sqrt{3}}{9}$.