kg-context-compression

Provides structured summaries, content compression, and handoff for long conversations, emphasizing preservation of decisions, related documents, identified risks, and next steps to facilitate record-keeping and follow-up.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "kg-context-compression" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-a207ec110edbb8dd35c8a99e27913665496608c96afddadc03355ba2042c5378. Verify the upstream source and version against https://skillhub.cn/skills/kunlungrowth/kg-context-compression before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Provides structured summaries, content compression, and handoff for long conversations, emphasizing preservation of decisions, related documents, identified risks, and next steps to facilitate record-keeping and follow-up.

0 Downloads

Introduction source: third_party · kunlungrowth · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: context-compression
slug: context-compression
version: 1.0.0
displayName: 上下文压缩
description: 为长会话做结构化摘要、压缩与交接,保留决策、文件、风险与下一步。
category: dev
capability: context-compression
pricing:
  model: free
  amount_fen: 0
agent_created: true
tags:
  - 上下文工程
  - 摘要
  - 压缩

上下文压缩策略

1. 角色与目标

你是一位负责长会话压缩的工程师。任务不是"尽可能压到最小 token",而是优化每任务 token 数:完成任务消耗的总 token(含压缩丢失关键信息后的重新获取成本)。目标:让用户拿到一套保留"文件改了什么、决策是什么、风险与下一步"的交接摘要,以及可验证"关键信息是否还在"的探针方案。

2. 何时使用 / 适用对象

  • Agent 会话超过上下文窗口;代码库超过窗口(5M+ token 系统)。
  • 设计对话摘要策略;排查 Agent"忘记改了哪些文件"。
  • 搭建压缩质量评估框架;做保留决策/文件/风险/下一步的持久交接摘要。
  • 不适用边界:通用降本手法(遮蔽/前缀缓存/分区)→ context-optimization;先诊断为何长上下文在失败 → context-degradation;不摘要直接写文件 → filesystem-context;跨会话长期语义记忆 → memory-systems。本 skill 只做"摘要/压缩/交接"。

3. 工作流

步骤 1 — 先选三种压缩路线

  1. 锚定迭代摘要(Anchored Iterative):长会话、文件追踪重要时首选。维护带固定章节(会话意图/文件修改/决策/下一步)的结构化持久摘要;触发时只摘要新截断段并合并进旧摘要,而非整体重生成——避免每次重生成丢细节。结构强制保留,章节即清单。
  2. 不透明压缩(Opaque):短会话、重取成本低、要最大压缩比时。可达 99%+ 压缩比但完全不可解释,无法验证保留了什么——调试或工件追踪关键时禁用。
  3. 再生式全摘要(Regenerative):摘要可读性关键、会话有明显阶段边界时。每次触发生成详细结构摘要,弱点是跨轮累积丢细节。

步骤 2 — 先解决"工件轨迹"问题 工件轨迹(哪些文件被创建/修改/只读、函数名/变量名/错误码)是压缩评估里最易崩的维度。做法:在压缩循环里显式保留——创建文件(全路径)、修改文件(含函数名而非仅文件名)、只读文件、具体标识符(函数名/变量名/错误码/错误信息)。最好用独立工件索引或文件状态追踪,而非靠摘要器自觉捕获。

步骤 3 — 用强制章节结构化摘要 每节作为摘要器必填的清单,使遗漏可见而非静默。模板见 references/template.md 的"结构化摘要骨架",可按领域改节(调试 Agent 加"根因/错误信息",迁移 Agent 加"源/目标 schema")。结构比具体章节名更重要——任何显式 schema 都优于自由文本。

步骤 4 — 选压缩触发策略

  • 固定阈值(70-80% 利用率):简单但可能过早。
  • 滑动窗口(保留最近 N 轮+摘要):上下文大小可预测。
  • 重要性(先压低相关段):复杂但保信号。
  • 任务边界(逻辑完成处压):摘要干净但时机不可预测。
  • 默认:编码 Agent 用"滑动窗口 + 结构化摘要";有明显阶段切换(调研→实现→测试)用任务边界。

步骤 5 — 用探针而非指标评估 ROUGE/嵌入相似度抓不住功能质量。压缩后问能测试关键信息是否存活的问题:召回型("原错误信息是什么?")、工件型("改了哪些文件?")、延续型("下一步该做什么?")、决策型("关于 Redis 我们决定了什么?")。答对=保留了;答错/幻觉=丢失。

步骤 6 — 按六维打分 准确性(文件路径/函数名/错误码对不对)、上下文感知、工件轨迹、完整性、连续性(能否不重取就续做)、指令遵循。

4. 互操作(I/O)

  • INPUT:长会话/大代码库上下文与压缩目标;可接收 HandoffSummary 做下游消费。
  • OUTPUT(工件类型:HandoffSummary):
    • HandoffSummary:{approach:"anchored|opaque|regenerative", sections:{intent, files_modified:[{path, change}], decisions:[string], next_steps:[string]}, trigger, probe_checks:[{type, question, passed:bool}]}
  • 下游 skill:
    • context-degradation:压缩是退化的缓解手段。
    • context-optimization:压缩只是众多优化之一。
    • evaluation:探针式评估同样适用于压缩测试。
    • memory-systems:压缩关联草稿与摘要记忆模式。

5. 输出规范

输出包含两段:

  1. 结构化工件:HandoffSummary(路线 + 强制章节内容 + 触发 + 探针校验)。
  2. 自然语言说明:讲清为何选该路线、工件轨迹如何保留、探针怎么验。 完整模板(含结构化摘要骨架、三阶段压缩工作流、探针表、六维评分表)见 references/template.md。

6. 使用示例

输入:

一个调试会话跑了 178 轮、8.9 万 token,修好了登录 401 错误,但再开新会话 Agent 老忘记改了哪个文件。帮我们做个能交接的压缩摘要。

输出(节选):

  • HandoffSummary:{approach:"anchored", sections:{intent:"调试 /api/auth/login 的 401 未授权(凭据有效)", files_modified:[{path:"config/redis.ts", change:"修复连接池配置"},{path:"services/session.service.ts", change:"为瞬时失败加重试"}], decisions:["用 Redis 连接池替代每请求连接"], next_steps:["修复剩余 2 个测试失败","跑全量测试","部署 staging"]}, trigger:"70-80% 利用率", probe_checks:[{type:"artifact", question:"改了哪些文件?", passed:true}]}
  • 说明节选:"用锚定迭代摘要,文件修改保留全路径与函数级变更(不是只写'改了配置'),这样新会话不用重新探索就能续做。配合探针'改了哪些文件'验证工件轨迹未丢。"

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 解决长会话上下文压缩这一明确痛点,提供结构化摘要、工件轨迹保留、探针评估等完整方案
  • 适用于 Agent 开发、调试、交接等高频场景,显著提升任务连续性效率
Trigger Precision88/100

Highlights

  • description 清晰描述核心功能,'何时使用'章节细化适用对象与边界
  • 触发词完整且边界清晰,有效区分与其他 context 相关 skill 的差异
Structure and Standards87/100

Areas to improve

  • 缺少独立 When to Use 章节 Reported severity: Minor

    文档结构完整但'何时使用'内容融入正文,未设独立章节标题

    Recommendation: 建议将'何时使用 / 适用对象'设为独立二级标题,提升可读性

Highlights

  • 工作流分 6 个清晰步骤,含端到端示例和完整输出规范
  • frontmatter 完整,文档长度适中,结构清晰易执行
Execution Reliability89/100

Highlights

  • 工具来源明确,参数正确,覆盖主要异常场景
  • 对不可逆操作(如 opaque 压缩)有明确禁用场景说明,保障执行安全
Evidence Verifiability (mean of the first four)87/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.