That is a very deep question.
Here is an example of a range of ways to think about that question: https://philosophynow.org/issues/149/What_is_a_Person
If one thinks that agency (and actions) is what defined personhood, it is worth having a framework for thinking about free will, such as https://psyche.co/guides/how-to-think-about-free-will-in-a-w...