StopAgentRun -- how to use

Hello
When a tool runs into a problem, I raise StopAgentRun
I get back a RunResponse from the agent.run call.
How do i know, based on the RunResponse object, that the run was not completed?

Thanks

Hey @shai
Thank you for your question.
When a tool raises StopAgentRun , you can detect that the run was not completed by checking the status attribute of the RunResponse object. Here’s how:


from agno.agent import Agent
from agno.exceptions import StopAgentRun

# Your agent setup
response = agent.run("Your message here")

# Check if the run was completed or not
if response.status == "CANCELLED":
    print("Run was stopped/cancelled - not completed")
elif response.status == "PAUSED":
    print("Run was paused - awaiting user input")
elif response.status == "RUNNING":
    print("Run is still in progress")
else:
    print("Run completed successfully")