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

# Compress History • AI Agent SDK

> compress_history: Compress all messages into a single summary message.

# compress\_history

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

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

Compress all messages into a single summary message.

This filter concatenates all message contents into one user message,
reducing token usage while preserving context. Useful for handoffs
where the target agent needs context but not full conversation history.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def compress_history(data: HandoffInputData) -> HandoffInputData
```

## Parameters

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

### Returns

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

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
Handoff(agent=target, input_filter=handoff_filters.compress_history)
```

## Source

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