How does your agent know it is finished?

Technical