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

# Keep Last N • Rust AI Agent SDK

> keep_last_n: Keep only the last n messages

# keep\_last\_n

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

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

Keep only the last n messages

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def keep_last_n(n: usize) -> impl Fn(HandoffInputData) -> HandoffInputData
```

## Parameters

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

### Returns

<ResponseField name="Returns" type="impl Fn(HandoffInputData) -> HandoffInputData">
  The result of the operation.
</ResponseField>
