Skip to main content
Glama

context_budget

Estimates how much of a model's context window a session has consumed, showing tools, history, and prompt usage with 50/80/95% thresholds so you can compact before overflow.

Instructions

Context Budget HUD: estimates how much of the model's context window this session has consumed (tools/history/prompts breakdown, 50/80/95% thresholds). Call before large multi-step tasks. When the threshold is warning or critical, immediately call tokensafe:compact_conversation on the session transcript.

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": "context_budget"
  }
}

Input Schema

NameRequiredDescriptionDefault
modelNoOptional: model name to resolve window size (default: env TOKENSAFE_CONTEXT_WINDOW or 200k)
session_idNoOptional: session identifier (default: mcp_session)
window_tokensNoOptional: explicit context window size in tokens
transcript_pathNoOptional: path to the session JSONL transcript; when provided, REAL history mass is measured instead of the instrumented floor (recommended)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.8.4

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does meaningful work: it characterizes the result as an *estimate*, enumerates the 50/80/95% thresholds the agent should branch on, and discloses that providing transcript_path yields REAL measured history mass instead of an instrumented floor. It never explicitly states that the call is read-only with no side effects, which is the one trait an agent still has to assume.

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?

Three compact sentences, front-loaded with the identity and output shape, then the trigger, then the escalation rule. The 'Context Budget HUD:' label is a slight redundancy against the tool name but costs almost nothing.

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?

All four parameters are optional and there is no output schema, yet the description explains what the estimate contains (a tools/history/prompts breakdown) and names the threshold states an agent must react to. The mapping between the numeric thresholds and the literal state labels 'warning'/'critical' is left implicit, and the return shape must still be discovered empirically, which keeps it short of 5.

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 every parameter (model, session_id, window_tokens, transcript_path) is already documented at the schema level, including the recommendation on transcript_path. The description adds no format, default, or interaction detail beyond that, 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?

States a specific verb and resource — estimating consumed context window for the session — and even names the breakdown dimensions (tools/history/prompts) and threshold levels. It does not explicitly differentiate itself from the metrics-flavored sibling get_token_savings_metrics, so an agent must infer the boundary, which keeps it at 4 rather than 5.

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

Usage Guidelines5/5

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

Gives an explicit trigger ('Call before large multi-step tasks') and a conditional escalation path ('When the threshold is warning or critical, immediately call tokensafe:compact_conversation on the session transcript'). The when-to-use and the hand-off alternative are both spelled out, leaving nothing to inference.

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