> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Last Stop Reason • AI Agent SDK

> last_stop_reason: Structured reason the last tool-execution loop stopped.

# last\_stop\_reason

Method

> This is a method of the [**Agent**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/Agent.md) class in the [**agent**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/agent.md) module.

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

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def last_stop_reason() -> str
```

### Returns

**Returns** `str`

The result of the operation.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/agent.py#L4120)
>
> `praisonaiagents/agent/agent.py` at line 4120


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.