跳到正文
Skillpedia
智能体18k · #10651

self-managed-context

它能做什么

这个技能涵盖由智能体自行控制实时上下文的情况,它决定保留、压缩或删除什么,而不是由固定的系统来决定。适合试验能够编辑自身工作记忆的模型的团队。

适用场景

  • ✓当你希望模型编辑自己的上下文,而不是遵循固定的压缩计划时。
  • ✓当你需要安全规则,防止自我编辑破坏缓存或添加隐藏指令时。
  • ✓当智能体必须逐字保留关键细节,并按需删除无关内容时。

技能链接

https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/self-managed-context/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/self-managed-context/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“在一项长任务中,让我的智能体编辑它自己的工作笔记,并确保它不会意外破坏自己的指令。”

每周 5 个新技能,1 分钟读完。

工作原理

该技能描述把上下文作为可编辑文件暴露出来,并配合安全措施,例如固定前缀、编辑关卡、编辑回执,以及上下文溢出时的回滚。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Self-Managed Context

This skill covers agents that manage their own context window: the model, not the harness, decides what stays in the live context, what is compacted, what is evicted, and what is rewritten in place. The reference implementation is Context Language Models (CLMs), which mirror the editable part of the conversation into a file that the model edits with ordinary code tools, then re-parse that file into the next prompt. Applied zero-shot to existing models on a shared agent backbone, this matched or beat harness-scheduled and action-based context management on accuracy and compute across deep-research, terminal-coding, and multi-hour repository-optimization tasks (claim-self-managed-context-zero-shot-results, claim-self-managed-context-long-horizon-results).

The controlling trade-off: model control buys adaptivity (verbatim retention, surgical in-place updates, eviction on demand) and creates three problems the harness must absorb. Edits break prefix caching, so a badly placed edit can cost more compute than the tokens it frees. Models do not know how full their context is. And a model-writable context is a persistence channel for whatever the model writes into it, including instructions. Most of this skill is the harness contract that makes the first property worth the other three.

When to Activate

Activate this skill when:

  • Giving a model write access to its own live context instead of compacting on a fixed schedule
  • Designing a context-as-a-file protocol: turn headers, parse-back, pinned prefix, edit receipts
  • An agent must keep exact values, update state in place, or evict offloaded material, and fixed summarization loses or duplicates it
  • Pricing mid-context edits under prefix caching, or evaluating suffix cache reuse
  • Budget readouts, tiered nudges, or rollback for an agent that times its own compaction
  • Steering, evolving, or training a model's context-editing strategy
  • Diagnosing a self-editing agent that never edits, wipes useful state, livelocks after overflow, or carries injected instructions in its own notes

Do not activate this skill for adjacent work owned by other skills:

  • Replacement-note content and fixed-threshold summarization: context-compression.
  • Cache-stable layout and observation masking under harness control: context-optimization.
  • File offloading while the live context stays append-only: filesystem-context.
  • Latent KV transfer between agents: latent-briefing.
  • Cross-session stores: memory-systems.
  • Loop governance and acceptance gates: self-improvement-loops. This skill supplies the context-editing signal; that skill governs the loop.

Core Concepts

The Control Spectrum

Context-management designs differ in who decides the transition from one context to the next. Append-only agents extend the context each step; a self-managing agent produces the whole next context as a function of the current one.

Level Who decides Examples Characteristic failure
Harness-scheduled Harness, at a threshold or every turn Threshold summarization, per-turn state rewrite Wrong timing; summaries lose or invent verbatim state
Action-based Model chooses when; harness defines what Self-compaction tools, offload-and-retrieve tools, context folding Strategy bounded by the action set; offload without eviction
Model-controlled Model chooses when and what, with general tools Context as an editable file Edit cache cost, budget blindness, persisting self-written instructions

A diagnostic built to isolate context management from reasoning (verbatim retention, in-place board updates, offload-and-evict) found no fixed strategy perfect even on simple synthetic tasks (claim-self-managed-context-contextbench-pilot). Each failure maps to a missing capability: summaries cannot hold exact values, append-only designs re-emit full state for every small update, and tool-based offloading cannot remove the original from the window.

Context as an Editable File

The implementation needs no new model capability:

  1. Split the context into a pinned prefix (system prompt and task) and an editable region (every later turn).
  2. Before each command, render the editable region to a file, each turn preceded by a header such as [[CTX_TURN 7 role=tool]].
  3. The model edits the file with the same shell and code tools it uses for the task, locating text with code (header regexes, unique anchors) instead of retyping it.
常见问题

什么是自我管理的上下文?

由模型自己决定哪些内容留在它的实时上下文中,而不是由一个固定的系统替它决定。

为什么编辑会增加成本?

编辑可能破坏前缀缓存,因此放置不当的编辑可能比它释放的空间消耗更多计算。

它描述了哪些安全措施?

固定前缀、编辑关卡、编辑回执、预算读数,以及上下文溢出时的回滚。

详情

作者的原始描述

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

repo: muratcankoylan/Agent-Skills-for-Context-Engineering

热度

GitHub 星标
18k
排名
#10651
许可证
MIT
更新时间
2026/10/11

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能