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

# Delete History Matching • AI Agent SDK

> delete_history_matching: Delete all messages matching a pattern.

# delete\_history\_matching

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

Delete all messages matching a pattern.

Useful for removing all image-related messages after processing.

## Signature

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

## Parameters

<ParamField query="pattern" type="str" required={true}>
  Substring to match in message content
</ParamField>

### Returns

<ResponseField name="Returns" type="int">
  Number of messages deleted
</ResponseField>

## Source

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