leaveLastNMessages

fun AIAgentLLMWriteSession.leaveLastNMessages(n: Int, preserveSystemMessages: Boolean = true)(source)

Keeps only the last N messages in the session's prompt by removing all earlier messages.

Parameters

n

The number of most recent messages to retain in the session's prompt.