4. Given $A\left(x_{1}, y_{1}\right) 、 B\left(x_{2}, y_{2}\right)$ are any two points (which can coincide) on the graph of the function
$$
f(x)=\left\{\begin{array}{ll}
\frac{2 x}{1-2 x}, & x \neq \frac{1}{2} \\
-1, & x=\frac{1}{2}
\end{array}\right.
$$

Point $M$ lies on the line $x=\frac{1}{2}$, and $\overrightarrow{A M}=\overrightarrow{M B}$. Then the value of $y_{1}+y_{2}$ is
4. -2 .

Given that point $M$ is on the line $x=\frac{1}{2}$, let $M\left(\frac{1}{2}, y_{M}\right)$.
Also, $\overrightarrow{A M}=\overrightarrow{M B}$, that is,
$$
\begin{array}{l}
\overrightarrow{A M}=\left(\frac{1}{2}-x_{1}, y_{M}-y_{1}\right), \\
\overrightarrow{M B}=\left(x_{2}-\frac{1}{2}, y_{2}-y_{M}\right) .
\end{array}
$$

Thus, $x_{1}+x_{2}=1$.
(1) When $x_{1}=\frac{1}{2}$, $x_{2}=\frac{1}{2}$, then
$$
y_{1}+y_{2}=f\left(x_{1}\right)+f\left(x_{2}\right)=-1-1=-2 \text {; }
$$
(2) When $x_{1} \neq \frac{1}{2}$, $x_{2} \neq \frac{1}{2}$, then
$$
\begin{array}{l}
y_{1}+y_{2}=\frac{2 x_{1}}{1-2 x_{1}}+\frac{2 x_{2}}{1-2 x_{2}} \\
=\frac{2 x_{1}\left(1-2 x_{2}\right)+2 x_{2}\left(1-2 x_{1}\right)}{\left(1-2 x_{1}\right)\left(1-2 x_{2}\right)} \\
=\frac{2\left(x_{1}+x_{2}\right)-8 x_{1} x_{2}}{1-2\left(x_{1}+x_{2}\right)+4 x_{1} x_{2}}=-2 .
\end{array}
$$

In summary, $y_{1}+y_{2}=-2$.