Last Stop Reason • AI Agent SDK
last_stop_reason: Structured reason the last tool-execution loop stopped.
last_stop_reason
Method
</div>
Structured reason the last tool-execution loop stopped.
One of `"completed" (task finished), "max_steps" (the unified step budget from ExecutionConfig.max_steps was reached and the run was truncated), a provider block/refusal/truncation ("content_filtered" | "refused" | "length_truncated") derived from the LLM finish_reason/refusal signal, "timeout" (the turn passed ExecutionConfig.max_execution_time or the run_autonomous deadline), or "error"`. Lets CLI/CI callers branch on the terminal reason instead of parsing a magic string. Reads from whichever backend (OpenAI-native or LiteLLM) executed the last turn.
Signature
def last_stop_reason() -> strReturns
strThe result of the operation.
Source
View on GitHubpraisonaiagents/agent/agent.py at line 4120