Community编程与开发github.com

隐式简报与KV缓存记忆共享

此技能用于在多智能体系统中通过KV缓存压缩实现表示级内存共享,减少工作器令牌消耗,避免重新完整传递编排器轨迹。

隐式简报与KV缓存记忆共享 是什么?

隐式简报是一种针对分层多智能体系统的专用技术,旨在解决编排器与工作器之间上下文重复传递导致的令牌爆炸问题。其核心方法是在工作器模型的KV缓存层面进行选择性保留,而非依赖文本摘要或检索。该方法基于注意力匹配(Attention Matching)KV缓存压缩,并针对推理时多智能体交接进行适配,包括任务引导查询、跨头共享令牌掩码和鲁棒阈值选择。它适用于拥有可控推理运行时的编排器-工作器架构,能够显著减少工作器令牌开销,同时保持任务相关的潜在状态。但该技术对基础设施有严格要求,需要能直接操作KV张量,且工作器与编排器需共享相同的模型空间。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/latent-briefing

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

隐式简报与KV缓存记忆共享 是做什么的?

分层多智能体系统通常为同一上下文重复付费。编排器积累了一条漫长的推理轨迹,但每个工作器通常只收到一个狭窄的文本交接,例如子任务提示加原始文档片段。传递完整轨迹可以解决覆盖问题,但这会在每次工作器调用时推高令牌成本。摘要引入了延迟和信息丢失。检索有助于文档访问,但无法保留编排器不断演化的推理状态。

隐式简报通过在表示层而非文本层共享内存来解决此问题。核心思想是在工作器模型的KV缓存中压缩编排器轨迹,仅保留与当前工作器任务最相关的位置。该方法基于注意力匹配(AM) KV缓存压缩,并针对推理时多智能体交接进行了适配,引入了任务引导查询、跨头共享令牌掩码以及鲁棒阈值选择。

何时激活

在以下情况激活此技能:

  • 设计编排器-工作器或监督者-专家系统时,工作器需要访问先前的编排器状态,而无需以文本形式重放完整轨迹
  • 评估基于LLM摘要或RAG的跨智能体状态迁移替代方案时
  • 实现或研究KV缓存压缩作为一类推理原语时,而不仅仅是相同提示的前缀缓存
  • 调试递归、分层或工具密集型智能体图中的令牌爆炸问题
  • 解读同时报告工作器令牌节省、总令牌节省、压缩开销和准确率的基准测试时

不要将此技能用于其他技能负责的相邻工作:

  • 仅API栈且内部KV张量不可访问的情况:请使用context-compression、memory-systems或multi-agent-patterns。
  • 普通的持久化记忆、实体追踪或图检索:请使用memory-systems。
  • 不涉及表示级状态共享的通用多智能体拓扑:请使用multi-agent-patterns。
  • 不转换KV状态的前缀缓存、掩码或预算策略:请使用context-optimization。

核心概念

令牌爆炸模式。 在递归或REPL式系统中,编排器反复调用工作器来检查证据、验证假设或回答子问题。编排器的轨迹随着部分结论、死胡同、工具输出和先前工作器的响应而增长。如果每次工作器调用都完整传递该轨迹,成本会迅速累积。

表示级共享。 系统不是在自然语言中总结轨迹,而是在工作器模型的KV缓存上操作。它保留工作器针对当前任务会关注的位置,并丢弃其余部分。这比普通前缀缓存更具体:前缀缓存重用相同的先前内容,而隐式简报还在重用的轨迹内部执行任务条件选择性保留。

注意力匹配作为压缩引擎。 AM寻求一个更小的缓存,其注意力输出近似于完整缓存。隐式简报通过改变评分信号和批处理策略,将AM适配于多智能体推理:

  1. 使用从当前工作器提示派生的任务引导查询向量。
  2. 将分数聚合为共享全局掩码,而不是每个头独立的子集。
  3. 使用鲁棒阈值,例如中位数 + tau * MAD,而不是每个头固定的top-k。

参考结果形式。 公开报告显示,在长文档QA工作负载上,工作器令牌显著减少,总令牌节省明显,压缩开销仅为低个位数秒(claim-latent-briefing-public-results)。请将这些数字视为工作负载特定证据,而非通用保证。

详细主题

为何纯文本缓解方案效果不佳

方法主要弱点
LLM摘要延迟高、抽象有损,且无法保证摘要能保留下一个子任务所需的内容
检索/RAG依赖于分块和嵌入;可能遗漏跨块或跨步骤的依赖关系
传递完整轨迹每次工作器调用成本增加,且无关上下文可能降低工作器质量

当瓶颈不是文档检索本身,而是如何高效且精确地将编排器状态传递给工作器时,隐式简报非常有用。

递归编排器-工作器形态

诸如递归语言模型之类的框架将长上下文视为环境并对其进行递归:编排器分解工作并委派给工作器。隐式简报填补了一个空白:编排器已经构建了应该告知工作器的任务特定状态,但将该状态重新序列化为文本成本太高或噪声太大。

在理想设置中,工作器为编排器轨迹维护一个持久化的KV状态。新的轨迹令牌扩展该状态,然后在为当前子任务生成之前执行压缩。

三项推理时修改

  1. 任务引导查询向量。 使用来自当前工作器任务提示的查询,而不是上下文的通用样本。将轨迹加当前任务通过工作器模型前向传播,然后根据任务对每个轨迹位置的关注程度对其进行评分。

  2. 共享令牌选择。 将跨层和跨头的分数聚合成每个位置一个分数。一个共享掩码支持批量操作,并避免数百个不相容的逐头求解。

  3. MAD阈值选择。 保留高于鲁棒异常值阈值(如中位数 + tau * MAD)的位置。更高的tau更激进。最佳设置取决于任务类型、轨迹质量和文档长度。

基础设施前提条件

只有当系统能够足够紧密地控制工作器推理运行时以检查或转换KV状态时,隐式简报才实用。对于内部KV张量不可访问的仅API栈,它不是一个好的默认选择。它还假定编排器轨迹可以在工作器的模型空间中表示。如果编排器和工作器在分词器、架构或注意力布局方面存在实质性差异,直接表示共享可能不可行。

决策框架

选择与瓶颈匹配的机制:

需求偏好原因
稳定的重复前缀,最少的逻辑更改前缀缓存成本最低的优化;无信息丢失
可读且可审计的跨步状态结构化笔记或摘要易于检查和存储
跨大型外部语料库的稀疏查找检索/RAG高效查找文档
工作器需要编排器状态的任务特定切片且运行时访问可用隐式简报无需重放所有文本即可转移相关的潜在状态

隐式简报并非摘要或检索的通用替代品。它是针对已运行可控编排器-工作器栈的系统的专门优化。

阈值区间

已报告的长文档QA结果建议:

  • 更长的文档: 较轻的压缩可以保留更广泛的证据覆盖,同时仍然节省令牌。
  • 更难的问题: 当编排器轨迹包含投机性或低价值分支时,更激进的压缩可能会有所帮助。
  • 更短、更简单的上下文: 适度的压缩可以消除冗余而不丢失必要的证据。

这些是调优假设,而非可移植法则。请根据目标工作负载重新测量。

实践指导

  • 首先定义共享内存边界。 精确决定哪些内容进入轨迹缓存:先前工作器的回复、工具输出、思维链,还是仅选定的工件。压缩质量首先取决于允许哪些内容进入缓存。
  • 在验证数据上调优,而非轶事。 同时跟踪任务准确率、工作器令牌数、总令牌数、保留率和压缩开销。
  • 测量端到端延迟。 只有当压缩加生成在相同质量目标下优于最佳文本层替代方案时,压缩才划算。
  • 使用强基线。 与前缀缓存、结构化笔记、检索和选择性文本交接进行比较,而不仅仅是“发送所有内容”。
  • 预期编排器方差。 如果分解策略随运行而变化,请平均足够多的试验,以将压缩效应与编排器噪声分开。

示例

场景:编排器轨迹随工作器调用而增长

调用1:轨迹T1 -> 工作器回答子问题A
调用2:轨迹T2 = T1 + 新推理 + 回复A
        使用任务提示B压缩KV(T2)
        工作器回答子问题B

针对B的任务提示决定了T2的哪些部分会保留到压缩后的工作器状态中。

负面示例:仅API工作器

如果工作器在托管文本生成API后运行,该API不暴露KV张量,则无法直接实现隐式简报。请改用context-compression中的结构化文本交接,或从memory-systems检索状态。

指南

  1. 当主要浪费来自向工作器重放编排器状态,而非检索源文档时,首选隐式简报。
  2. 当可审计性、可移植性或封闭模型API比令牌效率更重要时,首选纯文本交接。
  3. 将压缩与评估共同设计。微小的质量下降可能会抵消巨大的令牌节省。
  4. 将压缩激进程度作为可控参数公开,而非隐藏常数。

陷阱

  1. 基础设施访问是首要关卡。 如果运行时无法检查并重写工作器KV状态,隐式简报只是一个研究想法,而非可部署技术。
  2. 共享模型空间很重要。 KV压缩是在特定模型的注意力空间中定义的。不要假设隐式交接能在不相关的模型系列之间干净地工作。
  3. 阈值取决于工作负载。 单一的全局tau很少能同时适用于长短上下文以及难易任务。当压缩变得过于激进时,预计会出现准确率悬崖。
  4. 基准测试范围狭窄。 公开结果侧重于长文档QA。代码生成、数学和多文档合成可能表现不同。
  5. 编排器方差可能掩盖信号。 随机编排器可以极大地改变轨迹,从而淹没小的压缩收益或损失。
  6. 弱基线会夸大明显收益。 在声称系统级优势之前,请与强大的文本级替代方案进行比较。

集成

  • context-optimization - 前缀缓存和观察掩码仍然是默认的首选措施;隐式简报是针对兼容编排器-工作器栈的更专门优化。
  • multi-agent-patterns - 当多智能体令牌成本由监督者轨迹重放驱动,而不仅仅是协调开销时适用。
  • context-compression - 当人类可读状态、可移植性或审计日志更重要时,文本层摘要仍然是首选。
  • memory-systems - 有助于决定何时将跨步状态保持在外部存储器中,何时保持在工作器的潜在状态中。
  • tool-design - 工作器调用形状和任务提示决定了哪些令牌在压缩过程中得分较高。

参考资料

内部参考:

此集合中的相关技能:

  • context-optimization - 当主要需求是前缀缓存、观察掩码或文本层压缩而不是工作器KV操作时阅读
  • multi-agent-patterns - 在决定架构是否应为编排器-工作器模式时阅读
  • context-compression - 当人类可读摘要可能比潜在转移更适合时阅读
  • memory-systems - 在比较模型内潜在状态与外部持久化记忆时阅读

外部资源:


技能元数据

创建时间:2026-04-14 最后更新:2026-05-15 作者:Agent Skills for Context Engineering Contributors; 主要技术来源为Ramp Labs(公开帖子) 版本:1.2.0

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

advanced-evaluation

This skill should be used for advanced LLM evaluation: LLM-as-judge systems, direct scoring, pairwise comparison, rubric calibration, evaluator bias mitigation, confidence scoring, and automated quality assessment.

bdi-mental-states

This skill should be used when modeling agent mental states with BDI concepts: beliefs, desires, intentions, RDF-to-belief transformations, rational agency traces, cognitive agents, BDI ontologies, and neuro-symbolic AI integration.

book-sft-pipeline

This skill should be used for book-to-SFT pipelines: ePub extraction, literary segmentation, author-voice dataset construction, style-transfer training, LoRA workflows, and model evaluation for voice replication.

compaction-control-profiling

This skill should be used when deciding, for a specific model and workload, whether the harness or the model should control compaction, and when qualifying or calibrating that choice with measurements: context-budget sweeps that compare harness-driven and model-driven compaction on one harness, the context-pressure regime where delegation pays, a per-model compaction behavior profile (interface uptake, compression factor per call, reopen rate of archived content, context fill at first compaction, response to pressure warnings), context anxiety and timing-instruction calibration, reversible collapse-and-archive interfaces, and re-qualification after a model or prompt change. Route the editable-file protocol, harness invariants, and edit-position cache cost of self-editing agents to self-managed-context, summary content to context-compression, harness thresholds and cache layout to context-optimization, and general evaluation design to evaluation.

comprehensive-research-agent

Ensure thorough validation, error recovery, and transparent reasoning in research tasks with multiple tool calls

context-compression

This skill should be used when long-running agent sessions need context compression, structured summarization, compaction, token-per-task optimization, or durable handoff summaries that preserve decisions, files, risks, and next actions.

context-degradation

This skill should be used for diagnosing and mitigating context degradation: lost-in-middle failures, context poisoning, context clash, context confusion, attention-pattern issues, and agent performance degradation caused by accumulated or conflicting context.

context-fundamentals

This skill should be used to explain or reason about the foundational concepts of context engineering: what context is, the anatomy of a context window, how attention mechanics work, the U-shaped attention curve, why context quality matters more than quantity, and the mental models needed to interpret every other context-engineering decision. Use this for conceptual explanation, onboarding, and background reading. Route operational work to the specialized skills: debugging attention failures goes to context-degradation, token-efficiency work goes to context-optimization, conversation summarization goes to context-compression, and project-shape decisions go to project-development.

context-optimization

This skill should be used for improving context efficiency: context budgeting, observation masking, prefix or KV-cache strategy, partitioning, token-cost reduction, retrieval scoping, and extending effective context capacity without lowering answer quality.

evaluation

This skill should be used when building agent evaluation systems: deterministic checks, regression suites, multi-dimensional rubrics, quality gates, production monitoring, baseline comparison, and outcome measurement for agent pipelines.

filesystem-context

This skill should be used when agent work needs file-backed context: durable scratchpads, tool-output offloading, just-in-time discovery, cross-agent handoff files, filesystem memory, or cleanup policies for context stored outside the prompt.

harness-engineering

This skill should be used when designing autonomous agent harnesses: research loops, evaluation scaffolds, locked and editable surfaces, durable logs, novelty gates, pruning, rollback, PR preparation, and human approval boundaries.

hosted-agents

This skill should be used when designing hosted or background agent infrastructure: sandboxed execution, remote coding environments, warm pools, session persistence, multiplayer collaboration, self-spawning agents, or Modal-style sandboxes.

instruction-surface-security

Hardens agent runtimes against persistent prompt injection or unauthorized changes to instructions and permissions. Use to audit what agents auto-load, design reviewed activation for project rules, skills, memory, or tool configuration, and test whether trust boundaries hold after reload, restart, or delegation.

long-horizon-prompting

This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.

memory-systems

This skill should be used for persistent semantic memory in agent systems: cross-session knowledge retention, entity tracking, temporal validity, graph or vector retrieval, memory consolidation, and memory benchmark selection. Route file-backed scratchpads to filesystem-context, handoff summaries to context-compression, and token-efficiency tactics to context-optimization.

multi-agent-patterns

This skill should be used when designing multi-agent systems that need context isolation, supervisor or swarm coordination, explicit handoffs, parallel execution, or a decision on whether multiple agents are justified.

project-development

This skill should be used for project-level decisions about LLM-powered systems: whether an LLM is the right primitive for the task at hand, the shape of a multi-stage batch or agent pipeline, token and cost estimation, choosing between single-agent and multi-agent at the project level, structured output design for downstream parsing, and structuring agent-assisted iteration. Use this when the unit of work is a whole project or a multi-stage pipeline. Route individual tool design to tool-design and individual skill-loading or context-budget tactics to context-optimization.

self-improvement-loops

This skill should be used when the harness, scaffold, workflow, or optimizer itself is the optimization target: recursive self-improvement (RSI) loops, meta-harnesses, self-improving harnesses that mine their own failures and propose bounded edits, evolutionary or population-based search over agent scaffolds, acceptance gates for self-modifying systems, and agentic context evolution where the mechanism that produces context is versioned and evolved. Route governance of a single autonomous loop (locked surfaces, durable logs, rollback, novelty gates, approval boundaries) to harness-engineering, measurement and quality-gate design to evaluation, judge design to advanced-evaluation, and remote sandbox infrastructure to hosted-agents.

self-managed-context

This skill should be used when a model gets read-write control over its own live context window instead of a harness-scheduled compaction policy: the context exposed as an editable file the model rewrites with code tools, model-driven eviction and in-place updates, the harness invariants that keep self-editing safe (pinned prefix, edit gate, edit receipts, budget readouts, rollback on overflow), the prefix-cache cost of mid-context edits, and steering or training the model's own context-editing strategy. Route note content and fixed-threshold summarization to context-compression, cache-stable layout under harness control to context-optimization, file offloading to filesystem-context, and loop governance to self-improvement-loops.

相关技能