Skip to main content
Glama

compact_session

Compress a session by hiding a source pair and dropping a fraction of remaining pairs based on importance scoring, retaining key context for use in prompts.

Instructions

Assemble a compacted-markdown view of the source pair's session.

    Hides the source pair (so it can be used as ground truth in
    reconstruction-QA) and returns the remaining session pairs
    ranked by the chosen scoring source, truncated to keep
    `(1 - k_drop)` of the session.

    Args:
        source_pair_idx: index into pairs.jsonl identifying the
            pair whose session should be compacted. The pair itself
            is hidden from the output.
        k_drop: fraction of session pairs to drop (0.0 = keep all,
            0.9 = aggressive compaction).
        ranker: scoring source. Currently only "importance" is
            supported here (query-aware rankers belong in
            search_pairs).
        rem_decay: if True, multiply scores by the nightly REM-decay
            map (requires `weighted-compact rem-pass` to have run).

    Returns a dict with `markdown` (the compacted context, ready to
    paste into a prompt) and `meta` (budget-transparency: pairs_total,
    pairs_kept, input_chars, output_chars, tokens_estimate,
    compaction_ratio, signals_top3, ranker label).

    On invalid input or missing substrate returns a dict with an
    `error` key rather than raising.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
source_pair_idxYes
k_dropNo
rankerNoimportance
rem_decayNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

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

Detailed behavioral description without annotations: hides source pair, ranks by chosen scorer, truncates by k_drop, error handling. Does not explicitly state side effects (e.g., read-only), but the description covers most behavioral traits.

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?

Well-structured with clear sections, but slightly verbose for a concise description. Could tighten wording while retaining all information.

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

Completeness5/5

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

Covers all aspects: purpose, parameters, behavior, return value structure, error handling. Output schema referenced but description explains keys; no gaps identified.

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

Parameters5/5

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

Schema coverage is 0%, but description compensates fully by explaining each parameter's role, constraints, and examples (e.g., k_drop defaults, ranker limitations, rem_decay requirement).

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 states a specific verb ('Assemble a compacted-markdown view') and resource ('source pair's session'). It distinguishes from siblings by noting query-aware rankers belong in search_pairs.

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?

Clear context for when to use (compaction, hiding source pair) and alternatives (search_pairs for query-aware rankers). Lacks explicit when-not-to-use, but provides helpful limitations and prerequisites.

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/zzallirog/weighted-compact'

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