Skip to main content
Glama

Trim Context

trim_context
Read-only

Compacts retrieved context for a target operation before inference by dropping metadata, boilerplate, and repeats while preserving error lines, stack frames, trace IDs, and matching declarations.

Instructions

Compact retrieved context for one target operation before inference: drops metadata and boilerplate, collapses repeats, and keeps error lines, stack frames, trace ids and matching declarations verbatim. Deterministic unless useModel is true and the result is still over tokenBudget.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "rawContext": "<rawContext>",
      "targetOperation": "<targetOperation>"
    },
    "name": "trim_context"
  }
}

Input Schema

NameRequiredDescriptionDefault
useModelNoAllow an LLM compaction pass when over budget. Default: false.
rawContextYesRaw retrieved text to compact.
tokenBudgetNoTarget size in estimated tokens. Default: 2000.
targetOperationYesWhat the downstream model must do with the context.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.40.1

TDQS

A4.1/5.0
Behavior5/5

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

Beyond the readOnlyHint annotation, the description discloses exactly what is dropped (metadata and boilerplate), what is collapsed (repeats), and what is preserved verbatim (error lines, stack frames, trace ids, matching declarations). It also explicitly flags the determinism boundary: useModel true plus an over-budget result permits an LLM compaction pass.

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 definition is two tight sentences with the core action and preservation guarantees front-loaded. Every clause carries useful information, including the deterministic default and the conditional model-assisted path, with no 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?

For a four-parameter, read-only compaction utility with no output schema, the description covers the important transformations and the determinism fallback. It stops short of explicitly describing the return value or what happens if the result remains over budget, but the operational picture is otherwise complete.

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 coverage is 100%, so all four parameters already have structured descriptions; the description adds only light semantic context such as 'one target operation' and the over-tokenBudget fallback condition. It does not add new meaning for rawContext or targetOperation beyond what the schema provides, so the baseline of 3 applies.

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

Purpose4/5

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

The description states a specific verb (compact) and resource (retrieved context) and scopes it to one target operation before inference. It does not explicitly route the agent away from related siblings such as plan_context_footprint or unified_context, so it stops short of full sibling differentiation.

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?

It provides clear usage context: use before inference and per target operation. It does not state when not to use it or name an alternative tool for other context-management needs, but the intended operational moment is unambiguous.

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