Defining the map between tangent space in locally ringed space

I had a doubt studying locally ringed space about what is the canonical map between tangent spaces in the case the residue field is different:

Let $(f,f^*):(X,O_X) \to (Y,O_Y)$ a morphism of locally ringed space. Then is clear that given $x \in X$ you have that $k(x)$ is a field extension of $k(f(x))$. So you have a natural map of cotangent spaces $m_{f(x)}/{m_{f(x)}}² \to m_x/(m_x)²$, that is $k(f(x))$ linear. Now if the residue field is the same, i dualize the map on it and i have a map of tangent space. But if the residue field is different, i can see both space as vector space on $k(f(x))$ and dualize in this way. Or i can see that one extend the scalars to the second and induce a map on the field $k(x)$. What is the conventional map that one take in consideration? It seems to me that only the second one gives a nice formula between the tangent space(via a tensor product for the tangent space on $f(x)$ with $k(x)$), so should this advice that is the second a more "canonical" choice?

Disclaimer: I haven't though of this issue before so this is my attempt at figuring out what is going on. I believe it's correct but no guarantees.

It depends on what your base field is. As you've noticed, the tangent space in general only makes sense with respect to a field. So fixing a field $k$, the $k$ tangent space of $X$ at a $k$-rational point $x$ can be thought of as the set of $k$-morphisms $\operatorname{Spec}k[\epsilon]/(\epsilon^2) \to X$ sending the maximal ideal of $\operatorname{Spec}k[\epsilon]/(\epsilon^2)$ to $x \in X$.

So such a morphism picks out a $k$-rational point of $X$ and a tangent vector $\textit{defined over}$ $k$ at $x$. So in particular, if we're viewing $X$ and $Y$ as $k$-schemes, then a $k$-morphism from $X$ to $Y$ induces a linear map of the $k$ tangent spaces. In particular, $k \hookrightarrow k(x)$ and $k \hookrightarrow k(f(x))$ so the cotangent spaces are both vector spaces over $k$. Thus, in your notation the $k$ tangent spaces are the $k$ duals of cotangent spaces and the induced map on tangent spaces is as $k$ vector spaces.

So, in your example, both constructions are meaningful. The first, where you view everything as $k(f(x))$ vector spaces and take the $k(f(x))$ dual is the induced map on tangent spaces over $k(f(x))$, while the second where you tensor by $k(x)$ and take the $k(x)$ dual is the induced map of $k(x)$ tangent spaces of the $\textit{base extension}$ of your morphism to $k(x)$.

Here is an example. Take

$$\operatorname{Spec} \mathbb{C}[x] \to \operatorname{Spec} \mathbb{R}[x] \text{ induced by the inclusion } \mathbb{R}[x] \hookrightarrow\mathbb{C}[x].$$

Then these schemes and the morphism are defined over $\mathbb{R}$. This is the double cover $\mathbb{A}^1_{\mathbb{C}} \to \mathbb{A}^1_{\mathbb{R}}$. Let's look at the cotangent spaces at the origin. The induced map on residue fields is $\mathbb{R} \to \mathbb{C}$ and on cotangent spaces is the same inclusion viewed as $\mathbb{R}$ vector spaces. Taking $\mathbb{R}$ duals gives the map on $\mathbb{R}$ tangent spaces as the projection from the two dimensional real vector space $\mathbb{C}$ to the real line.

Now if we instead tensor everything with $\mathbb{C}$, then the map on tangent spaces is now the projection from a two dimensional complex space $\mathbb{C} \otimes_\mathbb{R} \mathbb{C}$ to the one dimensional complex vector space $\mathbb{R} \otimes_\mathbb{R} \mathbb{C}$ which corresponds to the double cover $\mathbb{A}^1_\mathbb{C} \otimes_\mathbb{R} \mathbb{C} = \mathbb{A}^1_\mathbb{C} \sqcup \mathbb{A}^1_\mathbb{C} \to \mathbb{A}^1_\mathbb{R} \otimes_\mathbb{R} \mathbb{C} = \mathbb{A}^1_\mathbb{C}$.