Skip to main content
Tool results can remain in an agent’s context and be sent back to the model on later turns. A file read or long command result can therefore consume context more than once. ReclaimLLM’s native hooks reduce that repeated context before it reaches the model, while recording what changed and whether the reduction was enforced or only observed.

Enabling compression

Fresh hook installations enable range caching, loop detection, and text-output compression by default. Repeated-result dedupe, image lifecycle controls, response brevity, and shadow mode remain opt-in.
Use the --no-read-cache, --no-loop-breaker, or --no-compress forms to disable a default mechanism. Installation choices persist in ~/.reclaimllm/config.json across reinstalls. The text-compression thresholds are stored together:
Compression hooks are local configuration, like the --dlp flag. Enterprise policy can additionally set individual mechanisms to off, observe, or enforce.

Compression mechanisms

ReclaimLLM reports each technique separately so the User Stats and Enterprise Tokens pages can show which mechanism produced the reduction.

Range cache

Telemetry IDs: range_cache and historical H1_read_cache · Flag: --read-cache · Measured ReclaimLLM tracks the exact line ranges already returned from each file. A fully covered reread becomes a short unchanged reference, while a partially overlapping read returns only unseen lines. File metadata and content hashes prevent stale reuse; writes and edits invalidate affected state. The parser covers native reads and a conservative set of exact shell reads across supported clients and PowerShell. Antigravity view_file calls are also capped to 200 lines before execution when the requested range is missing or larger than the cap. See supported commands, invalidation rules, and telemetry details.

Search shaping

Telemetry ID: H2_search_shaping · Flag: --compress · Measured Long grep and rg results are grouped into total matches, per-file counts, and representative matching lines. Explicit count, file-only, and context modes pass through because the command already asked for a compact or context-rich shape. Search shaping intentionally removes repetitive detail. The result tells the agent how much was omitted so it can issue a narrower search when it needs more context.

Lossless search/path folding

Telemetry ID: lossless_search_path_folding · Flag: --compress · Measured Repeated file and directory prefixes are folded out of search results and path listings without dropping result rows. Before a fold is accepted, ReclaimLLM expands it again and verifies that the exact original output is recovered. Ambiguous shapes and oversized inputs pass through unchanged. This fast, reversible stage can run after command-aware shaping or by itself when a chained command obscures the command family.

Exec compaction

Telemetry IDs: H3_exec_compaction, exec_compaction, and historical legacy_compress · Flag: --compress · Measured Recognized shell output is reduced with command-aware filters:
  • Git status, diff, log, and common action output retain the useful summary and bounded detail.
  • Directory listings group repeated paths and report omitted counts.
  • Generic long output collapses repeated lines and retains useful beginning and ending context.
  • Large browser accessibility snapshots use the same bounded generic compaction.
  • Large read-only Supabase results retain the first and last rows, the untrusted-data safety envelope, and an explicit omitted-row marker. Mutations and unfamiliar result shapes pass through.
Unknown commands, non-zero exits, image-like payloads, malformed structured output, and ambiguous multi-block results fail open and remain unchanged.

Provider output canonicalization

Telemetry IDs: provider_output_shaping and provider_canonicalization · Flag: --compress · Measured Recognized provider wrappers can add timestamps, execution headers, repeated path prefixes, and read-window explanations around otherwise useful output. ReclaimLLM removes only known boilerplate from Codex exec envelopes and Antigravity-style view, search, and listing results. The transform keeps provider wire formats intact and changes only an unambiguous text field. Unknown wrappers and structured results containing multiple independent text blocks pass through unchanged.

Stateful result delta

Telemetry ID: stateful_delta · Flag: --compress · Measured Repeated commands, searches, and directory listings against the same semantic target are compared with the preceding result. When at least 60% of the new result overlaps and a delta is smaller, the model receives the additions, removals, unchanged-line count, and a digest of the exact captured result. Failed commands are never converted into deltas. State is session-scoped and bounded to 128 targets, 256,000 characters per result, and 8,000,000 characters total. Claude Code, Codex CLI, and Gemini CLI use this stage when their result-rewrite contract supports enforcement.

Edit receipts

Telemetry ID: edit_receipt · Flag: --compress · Measured Recognized successful edit tools can return an entire diff after the agent already supplied that edit. ReclaimLLM replaces a matching echoed diff with a receipt containing the target, hunk count, added and removed line counts, new-line ranges, and a SHA-256 digest. Failures, malformed diffs, and target mismatches remain unchanged. Antigravity edit receipts can currently be evaluated in Replay, but Antigravity does not expose a post-result rewrite field for live enforcement.

Repeated log-line collapse

Telemetry ID: repeated_line_collapse · Flag: --compress · Measured Retry loops, pollers, and progress logs often print the same line many times with only numbers changing. When at least five such lines repeat and the fold saves at least 200 characters, ReclaimLLM keeps the first occurrence and adds a marker:
Only log-like lines are eligible. Tables, CSV rows, JSON, and key: value or key=value lines are never folded, because the numbers in them are usually the data.

Blob placeholders

Telemetry ID: blob_placeholder · Flag: --compress · Measured Long base64 runs (160+ characters, including data: URIs) and long hex runs (128+ characters) are replaced with a placeholder that keeps the kind, length, and a short digest:
Shorter hex values, such as commit hashes and SHA-256 digests, are left unchanged because agents quote them.
Both minifiers run only on successful (exit code 0) shell output that no command-specific filter already claimed. They never touch file contents (Read, cat, head, tail, nl, sed -n, …), edit results, failed commands, error results, or images. Each step is recorded as its own mechanism, so the dashboards show what each one saved.

Cross-session outline on re-read

Telemetry ID: cross_session_outline · Config: cross_session_outline · Measured · Observe by default Different sessions in the same repository often re-read the same large files from the top. When a native Claude Code Read would return at least 200 lines from line 1 of a file with at least 300 lines, and another session already read the same content (verified by re-hashing the file on disk), the model receives a symbol outline instead:
The outline covers Python, JavaScript/TypeScript, Go, Rust, SQL, and Markdown headings, and it is used at most once per file per session. Reading the file again returns the real content. If the model re-reads an outlined file anyway, ReclaimLLM records a negative saving equal to that read, so the dashboard does not keep credit for a replacement that cost a follow-up read. The outline stays in observe mode until you enable it in ~/.reclaimllm/config.json:
Accepted values are off, observe (default), and enforce. Enterprise policy can set the mode per organization. Unlike other mechanisms, the outline is not switched to enforce by organization-wide forced enforcement, because it hides content the model asked for. The shared read history lives on the local machine under ~/.reclaimllm/project_reads/, one file per repository, capped at 5,000 files with the last five sessions per file.

Recallable compact results

Telemetry: attributed to the transform that shortened the result · Flag: existing --compress enforcement Before adding a recall handle to an enforced compact result, ReclaimLLM stores the exact secret-safe text as a content-addressed local artifact. Storage uses owner-only permissions and is bounded to 32 artifacts, 32 MiB per session, and 8 MiB per artifact. A stub is added only when persistence succeeds and the stub still leaves the result smaller. Retrieve an exact, end-exclusive character range with:
Recall artifacts stay on the machine that produced the session. They are not synchronized between devices or uploaded as part of the model hot path.

Typed task ledger

Telemetry: no independent savings claim Supported hooks also maintain bounded structured task state: explicit goals, constraints, decisions, file operations, test outcomes, errors, next actions, and associated recall handles. The ledger is derived from recognized plan fields and tool events rather than another model call. The ledger does not rewrite model-visible output or report token savings by itself. It preserves auditable task state alongside more aggressive result reduction and can support later recovery and handoff workflows.

Test output filter

Telemetry ID: test_filter · Flag: --compress · Measured Pytest, Jest, Vitest, Go, and Cargo output keeps failures, errors, assertion details, relevant tracebacks, and the final summary while collapsing routine passing-test noise. If a non-zero run cannot be parsed confidently, ReclaimLLM returns the original output unchanged. Filtered output is bounded by test_filter_max_chars.

Hash dedupe

Telemetry ID: hash_dedupe · Flag: --dedupe · Measured A large tool result equivalent to an earlier result in the same session is replaced with a compact reference to the first occurrence. ReclaimLLM normalizes only volatile presentation details such as ANSI formatting, timestamps, durations, repository-absolute paths, and explicitly labeled process identifiers before hashing. Results below min_dedupe_chars and results marked as errors pass through. Dedupe is session-scoped and off by default.

Loop breaker

Telemetry ID: H4_loop_breaker · Flag: --loop-breaker · Estimated Claude Code sessions are checked for consecutive identical calls and repeated failures against the same file or command. ReclaimLLM first adds corrective context; after the pattern is well established, it asks for permission before another retry. It does not silently block the call. Loop-breaker impact is estimated from the avoided attempt because no completed tool result exists for a true before-and-after measurement.

Image downscale

Telemetry ID: image_downscale · Flag: --image-lifecycle · Measured Oversized screenshots and supported base64 tool-result images are resized and re-encoded before they enter the transcript. Images preserve their aspect ratio, are never enlarged, and default to a maximum dimension of 1280 pixels. The optional rclm[images] package is required. Claude Code can enforce the rewritten image. Codex currently records the measured before-and-after opportunity without applying the MCP image rewrite because its hook contract does not accept that replacement.

Stale-image eviction opportunity

Telemetry ID: image_eviction · Flag: --image-lifecycle · Estimated only When a newer screenshot supersedes an older image for the same tool, page, and viewport, ReclaimLLM estimates the context that could be released. It also models the prompt-cache write cost that eviction could introduce. This mechanism is measurement-only today. It never removes an image, even outside shadow mode, and appears separately from measured context reduction.

Execution order and fail-open behavior

For successful text results, the hot path applies mechanisms in this order:
  1. DLP redaction, when enabled.
  2. Cross-session outline (native Claude Code Read only).
  3. Range cache.
  4. Stateful result delta.
  5. Provider or command compaction, edit receipts, and verified lossless folding, followed by blob placeholders and repeated log-line collapse on eligible shell output.
  6. Hash dedupe.
A mechanism that claims a result prevents later lossy mechanisms from reshaping or double-counting it. Command-aware compaction, verified lossless folding, and the two minifiers can still contribute independently when each shortens the same recognized result. Any parser error or unsupported shape returns the original result. Every mechanism shapes a result once, as it enters the context. Earlier turns are never rewritten, so the provider’s prompt cache stays valid.

Compaction and subagents

Range cache, stateful delta, hash dedupe, and outline state all point back to content the model saw earlier. When Claude Code compacts a conversation, that content may no longer be in context, so ReclaimLLM resets this state as soon as the transcript shows a compaction boundary. Each subagent also keeps its own state, so a notice like “unchanged since turn 14” never refers to a read made by a different agent.

Replacement shape on Claude Code

Claude Code applies a replacement tool result only when it has the same shape as the original result: file content for Read, stdout/stderr for Bash, and content for other tools. A plain-string replacement is silently ignored. ReclaimLLM keeps the original shape for every replacement, including DLP redaction.
rclm releases before this fix could log Claude Code read-cache replacements as enforced when the model still received the original output, and redacted Read/cat output could be dropped the same way. Upgrade with pip install -U rclm.
Image results follow the separate image-lifecycle path.

Shadow mode and measurement types

--shadow-mode runs supported detection logic and records the potential reduction without rewriting model-visible results. Use it to evaluate your own workload before enforcement.
Range cache, search shaping, lossless folding, exec compaction, provider canonicalization, stateful deltas, edit receipts, repeated log-line collapse, blob placeholders, cross-session outline, test filtering, hash dedupe, and image downscaling compare an original result with a shorter candidate. Every event records whether it was applied. Dashboards report saved tokens (the model received the shorter result) separately from potential tokens (measured in observe mode, original result kept).
Loop breaking and stale-image eviction do not have an observed replacement result. Their figures depend on an avoided-call or cache-cost model and stay separate from measured reduction.
A provider may expose enough information to measure a candidate but no reliable hook contract for applying it. ReclaimLLM records the opportunity as potential and leaves the original result unchanged.
Shadow measurements and Replay are counterfactual context reductions, not realized billing savings. Prompt caching, future turns, retries, and model behavior can change the eventual provider-token impact.

Provider boundaries

  • Claude Code: uses the ordered text pipeline, including range caching, cross-session outlines, stateful deltas, recognized result compaction, log-line and blob minifiers, edit receipts where eligible, test filtering, hash dedupe, and loop detection. Supported images can be downscaled.
  • Cross-session outline: enforced only on Claude Code today. Codex CLI, Cursor, Gemini CLI, and GitHub Copilot record it in observe mode.
  • Codex CLI: uses the ordered text pipeline and now preserves both standard and custom tool-call output blocks during capture. MCP image downscaling remains measured but is not rewritten today.
  • Gemini CLI: uses range caching, stateful deltas, recognized text compaction, test filtering, and hash dedupe through its native hook contract.
  • Cursor: preserves explicit empty and falsy captured results and uses text reduction only where its hook contract provides a safe rewrite path. Results absent from historical transcripts cannot be reconstructed.
  • Antigravity: caps view_file before execution and routes supported commands through command compression. Its post-tool hook must return an empty object, so result-side canonicalization, deltas, and receipts are capture/Replay-only.
  • GitHub Copilot: hooks into VS Code agent events (PreToolUse and PostToolUse) to apply local DLP redaction and context compression transforms. Image downscaling is currently unsupported and passes through unchanged.

MCP tools for context efficiency

Two MCP tools complement the hook-level compression mechanisms for managing context across sessions:

file_brief

Returns a distilled summary of prior RCLM sessions that touched a given file. Use it for orientation before an edit, instead of re-reading the full file and replaying its entire change history.

handoff

Packages the current session’s state into a document you can paste into a fresh session. Useful once a session has grown large enough that the resend multiplier itself is the problem — a clean session start with prior context is cheaper than continuing a bloated one.

Session-start context packs

New Claude Code sessions can be seeded with highlights from recent ReclaimLLM sessions in the same project. The agent begins with compact prior decisions, changed files, and outstanding work instead of reconstructing all of that context through repeated reads. Response brevity is a related opt-in control:
Brevity adds an advisory instruction at session start. Its impact is a cohort estimate rather than a measured per-session mechanism, so it is not included in Measured Context Reduction.

Viewing context reduction

Individual users can review the mechanism breakdown in User Portal → Stats → Measured Context Reduction. Enterprise administrators can review organization-wide results in Enterprise → Tokens → Measured context reduction. Each technique has a help tooltip, a saved total, a potential total, and enforced and observe-only event counts, for example 9k saved (3 enforced) · 3k potential (2 observe-only). Select a row with linked evidence to inspect contributing sessions. For data recorded before the applied flag existed, a mechanism’s savings count as saved only when it never ran in observe mode; otherwise its historical saved figure is 0. This undercounts some history rather than overstating it.
These pages need captured session telemetry to populate. New organizations show an empty state until eligible sessions have been processed.
To evaluate the mechanisms on your own workload:
  1. Install with --shadow-mode to record eligible reductions without changing model-visible text.
  2. Run representative sessions, then compare potential and enforced totals in the User or Enterprise dashboard.
  3. Use the ReclaimLLM MCP replay_session, replay_corpus, or replay_compare tools to run the shipped deterministic transforms over captured sessions.
  4. Compare each mechanism with the combined configuration. In Replay, shell_compaction includes provider canonicalization and eligible edit receipts, while stateful_delta is selectable separately.
  5. Check live task success, retries, turns, and follow-up reads before treating lower result tokens as an end-to-end improvement.
For example, ask an agent connected to the ReclaimLLM MCP:
The implementation corpus of 50 recent sessions showed 39.35% immediate text tool-result reduction in combined Replay, or 41.49% when modeling the 200-line Antigravity pre-tool cap. A separate recallable-context model estimated 15.11% fewer repeated tool-step context tokens. These are workload-specific replay figures, not provider billing or output-token measurements. See Verify token reduction with Replay for eligibility rules and interpretation.

Current limitations

Session and organization dashboards aggregate mechanism telemetry. Range-cache file attribution and linked session evidence are available, but not every provider exposes a uniform per-call drill-down.
The local --shadow-mode flag observes all locally enabled supported mechanisms together. Enterprise policy can assign off, observe, or enforce per mechanism.
ReclaimLLM does not yet change compression flags automatically based on session patterns. Review shadow telemetry and Replay evidence before enforcement.
An outline can cost an extra turn when the model needs most of the file anyway; the negative event records the tokens, not the round trip. Log-line collapse can fold lines where the numbers mattered. Report either case with the session so thresholds can be tuned. Runtime token figures are character-based estimates (characters ÷ 4), not provider tokenizer counts.
Exact recall handles resolve only on the machine that stored the artifact. They do not currently provide cross-device or hosted recovery, and a handle is added only after durable local storage succeeds.
Antigravity result-side transforms are Replay-only under its current post-tool contract. Cursor cannot recover outputs omitted from historical transcripts, and Codex image replacement remains measurement-only.
Command, test-runner, and structured-result filters intentionally accept only recognized shapes. Tool updates can create new edge cases, so unfamiliar or ambiguous output passes through unchanged. Report a consistently verbose unsupported command so a conservative filter can be added.