Ohr Hachaim explains Breishit 50:20 by way of a mashal: someone intended to give his fellow poison but ended up giving him wine. The perpetrator is not deemed to be chayav for what he intended to do.
Ohr Hachaim’s comment above seems at odds with Rashi’s comment on Bamidbar 30:6 (dibbur hamatchil “va’Hashem yislach la”). Rashi gives the example of a woman who takes a neder to become a nazir while her father hears and secretly annuls the neder but she transgresses her neder. She needs slicha because kavana (and seemingly not the ma’aseh) is what matters. In the case of the Ohr Hachaim’s example it seems that the ma’aseh (and not kavana) matters. Why is it the opposite for both cases?