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
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It discloses key behavioral traits: the compression strategy (removes oldest non-system messages), preservation rules (preserves system messages and recent context), and triggering condition (token count exceeds threshold). However, it doesn't mention performance characteristics, error conditions, or what happens when compression isn't possible.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tightly packed sentences with zero waste. The first sentence states the core purpose, the second explains the specific algorithm. Every word earns its place, and the most important information (what the tool does) is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 4 parameters, 100% schema coverage, but no annotations and no output schema, the description provides adequate but not complete context. It explains the compression algorithm well but doesn't describe the return value format or error handling. The description compensates somewhat for the lack of annotations by explaining behavioral aspects.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond what's in the schema - it mentions 'token-based trimming' which relates to the parameters but doesn't explain their interactions or provide additional semantic context. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'compress' and resource 'chat message history' with specific strategy details ('token-based trimming', 'removes oldest non-system messages'). It distinguishes from sibling 'summarize_messages' by focusing on compression rather than summarization.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('when token count exceeds threshold'), but doesn't explicitly state when NOT to use it or mention the sibling tool 'summarize_messages' as an alternative. The guidance is implicit rather than explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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