4. Given real numbers $x, y, z$ satisfy
$$
\begin{array}{l}
\frac{y}{x-y}=\frac{x}{y+z}, z^{2}=x(y+z)-y(x-y) . \\
\text { Then } \frac{y^{2}+z^{2}-x^{2}}{2 y z}=
\end{array}
$$
4. $\frac{1}{2}$.

From the given, we have $z^{2}=x z+y^{2}, x^{2}-y^{2}=x y+y z$.
Then $\frac{y^{2}+z^{2}-x^{2}}{2 y z}=\frac{(y-x)(y-z)}{2 y z}$
$=-\frac{(y+z)(y-z)}{2 x z}=\frac{z^{2}-y^{2}}{2 x z}=\frac{1}{2}$.