Skip to main content
Glama

fit_messages

Reduce a chat message array to fit within a token budget by dropping least important messages, preserving system messages and specified first/last messages. Choose from drop-oldest, drop-middle, or priority strategies.

Instructions

Drop messages from the input array until the total is under maxTokens. Three strategies: drop-oldest (default), drop-middle, priority (uses each message's priority field). Always returns a structured result with token counts before and after; never throws across the wire.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNoOptional model name for estimator selection.
messagesYesChat messages to fit.
overheadNoPer-message overhead in tokens.
strategyNoDrop strategy. Default drop-oldest.
maxTokensYesToken budget the result must come in under.
preserveLastNNoNever drop the last N messages of the input array. Default 0.
preserveFirstNNoNever drop the first N messages of the input array. Default 0.
preserveSystemNoDefault true: never drop messages with role === "system".
Behavior5/5

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

With no annotations, the description fully discloses behavior: it drops messages, provides three strategies, returns a structured result with token counts, and never throws errors. This covers safety and operational traits comprehensively.

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?

The description is concise, front-loaded with the main action, and each sentence adds value. No redundancy or filler.

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

Completeness4/5

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

Given 8 parameters (2 required) and no output schema, the description explains the core behavior and return format (token counts) clearly. It does not detail every parameter but schema covers them. The strategies and error behavior are well described.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3. The description adds context beyond schema by explaining the three strategies and the meaning of the priority field, enhancing understanding of parameter usage.

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 tool's purpose: dropping messages to fit under maxTokens. It lists three strategies, distinguishing it from sibling tools like count_tokens and list_estimators.

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 implicitly guides usage by describing the tool's function and strategies, but does not explicitly compare to siblings or state when not to use it. The sibling tools are sufficiently different to imply appropriate use cases.

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/MukundaKatta/agentfit-mcp'

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