4. As shown in Figure 3, square $ABCD$ is divided into 8 triangles of equal area. If $AG=\sqrt{50}$, then the area $S$ of square $ABCD$ is $ \qquad $.
4. 128 .

As shown in Figure 5, draw $K L / / D C$ through point $F$, take the midpoint $N$ of $A B$, and connect $G N$ with $A H$ intersecting at point $P$.
Let the side length of the square $A B C D$ be $a$.
Given $S_{\triangle D C I}=S_{\triangle M B H}=\frac{1}{8} S$, we know
$C I=B H=\frac{1}{4} B C=\frac{a}{4}$.
Since $S_{\triangle M D F}=2 S_{\triangle D C I}$, we have
$A D \cdot K F=2 C D \cdot C I$.
Therefore, $K F=2 C I=\frac{1}{2} a$.
Thus, $F$ is the midpoint of $D I$.
Given $S_{\triangle C A H}=S_{\triangle C H F}=S_{\triangle C F A}$, we know $G$ is the centroid of $\triangle F A H$.
Then $E$ and $P$ are the midpoints of $A F$ and $A H$ respectively, and
$$
G P=\frac{1}{2} F G \text {. }
$$

Also, $F P$ is the midline of trapezoid $A H I D$, so,
$F P=\frac{H I+A D}{2}=\frac{\frac{1}{2} a+a}{2}=\frac{3 a}{4}$
$\Rightarrow G P=\frac{1}{3} F P=\frac{a}{4}$
$\Rightarrow G N=G P+P N=\frac{a}{4}+\frac{a}{8}=\frac{3 a}{8}$.
Since $A N=\frac{a}{2}$, by the Pythagorean theorem we get
$$
\begin{array}{l}
A G^{2}=\left(\frac{a^{2}}{2}\right)+\left(\frac{3 a}{8}\right)^{2}=\frac{25 a^{2}}{64}=50 \\
\Rightarrow a^{2}=128 \Rightarrow S=128 .
\end{array}
$$