Skip to main content
Glama

audit_and_pack_rag_context

Audit retrieved RAG passages against encoder token limits, re-chunk truncated text, remove near-duplicates, and order passages for attention within a strict context budget.

Instructions

Audit retrieved RAG passages against embedding encoder hard limits (MiniLM 256, BGE/E5 512, Nomic 2048, OpenAI 8191, Voyage 32k), eliminate silent truncation via sentence-bounded re-chunking, remove Jaccard near-duplicates, and apply Lost-in-the-Middle U-shaped attention ordering inside a strict token budget.

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": {
      "chunks": "<chunks>"
    },
    "name": "audit_and_pack_rag_context"
  }
}

Input Schema

NameRequiredDescriptionDefault
chunksYesCandidate retrieved passages with text, optional id, source, and relevance score.
encoderModelNoEmbedding encoder preset for truncation audit (default: all-minilm-l6-v2).
overlapTokensNoSentence overlap tokens when re-chunking (default: 32).
dedupThresholdNoJaccard near-duplicate threshold 0..1 (default: 0.72).
encoderMaxTokensNoOptional custom encoder token limit override.
maxContextTokensNoHard token budget for final packed prompt context (default: 4000).
reorderForAttentionNoApply U-shaped Lost-in-the-Middle ordering (default: true).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It does disclose the transformation pipeline well — sentence-bounded re-chunking to prevent silent truncation, Jaccard duplicate removal, and U-shaped attention ordering — but it never states whether the input chunks are modified, what the returned artifact looks like (packed context vs. audit report), or what happens to dropped passages.

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?

A single front-loaded sentence with the primary verb first and no filler. It is dense with jargon and long, but each clause (limits, re-chunking, dedup, ordering, budget) maps to actual tool behavior rather than padding.

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?

Seven parameters are fully documented and the transformation logic is described, but with no output schema and no annotations, the agent still cannot tell what the tool returns or whether the result replaces or supplements the input chunks. For a packing/pipeline tool that is a meaningful omission.

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 the baseline is 3, and the description adds real meaning on top: it supplies the per-encoder token ceilings (256/512/2048/8191/32k) that explain encoderModel, spells out the Lost-in-the-Middle concept behind reorderForAttention, and clarifies the 'hard budget' nature of maxContextTokens. It stops short of explaining overlapTokens or dedupThreshold interaction.

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 concrete verbs and a specific resource: audit retrieved RAG passages, re-chunk against encoder limits, dedup, and reorder for attention. The enumerated encoder presets and named technique (Lost-in-the-Middle) make it distinguishable from generic siblings like compile_context_pack or simulate_context_budget without opening the schema.

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?

Usage is implied by the domain framing (retrieved RAG passages being packed into a token budget), but there is no explicit when-to-use/when-not statement and no routing to alternatives such as compile_context_pack or simulate_context_budget. An agent can infer the scenario but not the boundary conditions.

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