Much of my career was spent in AI work, and we thought about this question a lot. The place that we generally landed is that agency (and related concepts like self-awareness and consciousness) is very much a gray area. There’s no line in the sand, because intelligence is an emergent property of the complex structure of the brain, and there’s an infinite spectrum of complexity there in animals. Trees are an interesting middle ground, since they do exhibit many aspects that look like “goals” and “intentionality” but it’s important to tread lightly here because the human capacity for anthropomorphism is immense.
That said, there are clear cases as well. A rock has no agency, and likewise evolution is just a property of a system, like gravity or chemical reactions. Chemical reactions aren’t trying to do anything or get anywhere, they just happen because electrons exist. Evolution is the same, but we struggle to grok that because morphology in plants and animals appeals so strongly to our sense of design. This effect is so strong that we justify entire religions around it. But no, evolution just “is”.