Let $f,g:X\rightarrow Y$ be morphisms of locally ringed spaces, such that the topological maps $f$ and $g$ are identical, and the maps of sheaves $f^\sharp,g^\sharp:\mathcal{O}_Y\rightarrow f_*\mathcal{O}_X$ agree on stalks. By this I mean that for all $x\in X$, the maps $f_x,g_x:(\mathcal{O}_Y)_{f(x)}\rightarrow (\mathcal{O}_X)_x$ agree. I want to know if $f^\sharp=g^\sharp$.
The stacks project seems to use this fact here in Lemma 26.23.7, but maybe I'm wrong.
The way I think of the map $f_x:(\mathcal{O}_Y)_{f(x)}\rightarrow (\mathcal{O}_X)_x$ is as a composition of the stalk maps $f^\sharp_{f(x)}:(\mathcal{O}_Y)_{f(x)}\rightarrow (f_*\mathcal{O}_X)_{f(x)}$, $(f^*)_x:(f_*\mathcal{O}_X)_{f(x)}\rightarrow (\mathcal{O}_X)_x$. The first map is just the usual induced map on stalks, and the second map is given by: $$[U,s]_{f(x)}\longmapsto [f^{-1}(U),s]_x$$ which is well defined by some universal property of colimits. Since $f$ and $g$ are equal, its clear that $(f^*)_x=(g^*)_x$, so we have that: $$(f^*)_x\circ (f^\sharp)_{f(x)}=(f^*)_x\circ g^\sharp_{f(x)}$$ and so I guess if $(f^*)_x$ is a monomorphism, we have have that $(f^\sharp)_{f(x)}=g^\sharp_{f(x)}$ for all $y\in \text{im } f$, but a) I dont know think that $(f^*)_x$ is a monomorphism in general, and b) this only shows they agree on some of the stalks not all of them.
Am I missing something here? Perhaps my map of stalks is not correct?
To show that $f^\sharp=g^\sharp\colon\mathcal{O}_Y\to\mathcal f_*{O}_X$, it suffices to show that the adjoint maps $f_\sharp,g_\sharp\colon f^{-1}\mathcal{O}_Y\to\mathcal{O}_X$ are equal. This can be checked on stalks, so we need to show that, for all $x\in X$, the maps $(f_\sharp)_x,(g_\sharp)_x\colon \mathcal{O}_{Y,f(x)}\cong(f^{-1}\mathcal{O}_Y)_x\to\mathcal{O}_{X,x}$ are equal. But this is the assumption you started with.