Skip to content

MessagePruning

Namespace: Vercel.AI.GenerateText

public static class MessagePruning

Message pruning. Maps to pruneMessages.

Inheritance: object

View source

public static IReadOnlyList<ModelMessage> PruneMessages(PruneMessagesOptions options)

Prunes reasoning, tool calls, results, errors, and approvals from a list of messages. The input is not changed. A tool message upstream holds several parts. Here its parts are separate consecutive tool messages, and they count as one message for BeforeLastMessage and the trailing-message rules.

Parameters

Name Type Description
options PruneMessagesOptions The messages and the pruning settings.

Returns: IReadOnlyList<ModelMessage> — The pruned messages.

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product