Skip to main content
Glama

trim_messages

Compress chat message history by trimming oldest non-system messages when token count exceeds threshold, preserving system messages and recent context.

Instructions

Compress chat message history using token-based trimming strategy. Removes oldest non-system messages when token count exceeds threshold while preserving system messages and recent context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messagesYesArray of chat messages to compress
maxModelTokensNoModel's maximum token context window
thresholdPercentNoPercentage threshold to trigger compression (0-1)
minRecentMessagesNoMinimum recent messages to always preserve

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/agentailor/slimcontext-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server