> ## 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

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**Agent**](../classes/Agent) class in the [**agent**](../modules/agent) 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) or `"error"`. Lets CLI/CI callers branch on truncation
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

<ResponseField name="Returns" type="str">
  The result of the operation.
</ResponseField>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/agent.py#L3228">
  `praisonaiagents/agent/agent.py` at line 3228
</Card>
