2. Let $\min \{a, b, c\}$ be the minimum of $a, b, c$. If $x, y$ are any positive real numbers, then the maximum value of $M=\min \left\{x, \frac{1}{y}, y+\frac{1}{x}\right\}$ is $\qquad$.
2. $\sqrt{2}$.

Given $-\frac{1}{y} \geqslant M, x \geqslant M, y+\frac{1}{x} \geqslant M$, then $y \leqslant \frac{1}{M}, \frac{1}{x} \leqslant \frac{1}{M}, M \leqslant y+\frac{1}{x} \leqslant \frac{2}{M}$.
Thus, $M^{2} \leqslant 2, M \leqslant \sqrt{2}$.
When $x=\sqrt{2}, y=\frac{1}{\sqrt{2}}$, then $\frac{1}{y}=\sqrt{2}, y+\frac{1}{x}=\frac{1}{\sqrt{2}}+\frac{1}{\sqrt{2}}$ $=\sqrt{2}$. Therefore, $M=\sqrt{2}, M$'s maximum value is $\sqrt{2}$.