layered-history-compression-reuse

Compress layered conversational history while preserving tool_use/tool_result pair integrity.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/liuyu520/cc_source --skill layered-history-compression-reuse
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: layered-history-compression-reuse
Source: https://github.com/liuyu520/cc_source/tree/main/.claude/skills/layered-history-compression-reuse
Command: npx skills add https://github.com/liuyu520/cc_source --skill layered-history-compression-reuse

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reduces token usage and keeps conversations performant by applying layered history compression that preserves recent content and defensively manages older tool results.

Core Features & Use Cases

  • Layered tiering preserves recent turns verbatim, truncates middle-age tool results, and elides very old interactions.
  • Tool-pair safety runs after compression to repair orphaned tool_use/tool_result pairs and maintain API integrity.
  • Extensible architecture integrates with snipCompact, env gating, and SnipResult contracts for future tier additions.

Quick Start

Use this skill to apply layered history compression to an ongoing conversation by enabling the most recent content, truncating the middle, and eliding the oldest items while preserving tool-use pairs.

Frequently Asked Questions about layered-history-compression-reuse

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce token usage in conversational AI without losing essential context?

Layered history compression reduces token usage by preserving recent turns verbatim, truncating middle-age tool results, and eliding very old interactions to maintain conversational context. This keeps conversations performant while retaining essential recent data.

How does layered history compression handle tool_use and tool_result pairs?

Layered history compression runs tool-pair safety after compression to automatically repair orphaned tool_use and tool_result pairs. This defensive management ensures API integrity is maintained even when older tool results are truncated or elided.

What is the best way to truncate middle-age chat history in LLM conversations?

The best way to truncate middle-age chat history is applying a layered tiering approach that keeps recent content verbatim, shrinks middle-age tool results, and fully elides the oldest interactions to optimize token consumption.

Can I use snipCompact with layered history compression for chat history management?

Yes, layered history compression integrates directly with snipCompact and the SnipResult contract. This extensible architecture supports env-gate logic and allows for safe handling of non-text blocks while enabling future tier extensions.

When do I need to compress conversational history with layered tiering?

You need layered tiering when ongoing conversations experience high token usage and performance degradation. It is specifically required in tool-integrated conversations where preserving tool_use and tool_result pair integrity is critical.

Why does eliding older interactions break tool API integrity in chat history?

Eliding older interactions can break tool API integrity by orphaning tool_use and tool_result pairs. Layered history compression solves this by running tool-pair safety after compression to repair the broken pairs and maintain API validity.