Prune History • AI Agent SDK
prune_history: Prune chat history to keep only the last N messages.
prune_history
Method
</div>
Prune chat history to keep only the last N messages.
Useful for cleaning up large history after image analysis sessions to prevent context window saturation.
Signature
def prune_history(keep_last: int) -> intParameters
ParamField
intNumber of recent messages to keep
Returns
ResponseField
intNumber of messages deleted
Source
View on GitHubpraisonaiagents/agent/agent.py at line 4213