Skip to main content
Glama

find_optimal_compact_turn

Read-onlyIdempotent

Scans candidate /compact checkpoint turns to find the exact compaction turn that minimizes total session and monthly token spend for a coding session.

Instructions

Scan every candidate /compact checkpoint turn across a multi-turn coding session to compute the exact compaction turn that minimizes total session and monthly token spend.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "find_optimal_compact_turn"
  }
}

Input Schema

NameRequiredDescriptionDefault
turnsNoTotal coding session length in turns (1..100).
modelIdNoReference LLM pricing tier ID.claude_sonnet_4_5
imageTokensNoToken count of visual attachments when imageInjectionTurn > 0.
cacheTtlModeNoPrompt-cache TTL mode (5m, 1h, or none).5m
avgOutputTokensNoAverage assistant output tokens per turn.
mcpSchemaTokensNoEager MCP schema token weight per turn.
compactKeepRatioNoFraction of accumulated conversation history retained after /compact summarization (default: 0.20).
sessionsPerMonthNoMonthly session count used to project monthly savings.
avgTurnGapMinutesNoAverage minutes elapsed between turns.
systemRulesTokensNoStatic rules token weight per turn.
imageInjectionTurnNoOptional turn where visual screenshots are injected mid-session.
avgTurnGrowthTokensNoAverage context delta added per turn.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.4/5.0
Behavior3/5

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

The annotations already declare readOnlyHint, idempotentHint, non-destructive and closed-world, so safety is covered. The description adds that the scan is exhaustive ("every candidate turn") with a dual objective (session and monthly spend), which is useful behavioral context, but it omits what the response contains and makes no statement about computational cost or runtime for a full scan.

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

Conciseness4/5

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

It is a single, front-loaded sentence with no filler, and the optimization objective appears immediately. It is dense and could have been split to expose the output and the exclusions, but nothing is wasted.

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?

With 12 optional parameters and no output schema, the description should explain what is returned (for example, the optimal turn and the projected savings) and how the baseline comparison works. It conveys the goal but leaves the result shape and interpretation to the caller, which is a gap for an analytical tool with this many inputs.

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%, with clear descriptions, defaults, ranges and enums for all 12 parameters, so the schema does the heavy lifting. The description adds no parameter-level meaning such as how compactKeepRatio or imageInjectionTurn affect the computed optimum, 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 uses a specific verb and resource: it computes the exact /compact checkpoint turn that minimizes total session and monthly token spend, which is far more informative than the tool name alone. It does not differentiate from the sibling simulate_agent_session_cost, which sounds closely related, so an agent must infer which one to pick.

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

Usage Guidelines3/5

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

The purpose implies when to use it (optimizing /compact placement in a multi-turn session), but there is no explicit when-to-use or when-not-to-use guidance and no mention of the sibling cost-simulation tool as an alternative. An agent can guess the context but gets no routing rules.

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