How does an agent typically decide it has completed its task and should stop the agentic loop?