> ## 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 Iteration • AI Agent SDK

> last_iteration: Return the highest journalled iteration index, or ``None``.

# last\_iteration

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

> This is a method of the [**RunJournal**](../classes/RunJournal) class in the [**journal**](../modules/journal) module.

Return the highest journalled iteration index, or `None`.

Used to restore the loop cursor exactly on resume.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def last_iteration(run_id: str) -> Optional[int]
```

## Parameters

<ParamField query="run_id" type="str" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="Optional[int]">
  The result of the operation.
</ResponseField>

## Uses

* `events`

## Source

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