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に貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
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:
- Split the context into a pinned prefix (system prompt and task) and an editable region (every later turn).
- Before each command, render the editable region to a file, each turn preceded by a header such as
[[CTX_TURN 7 role=tool]]. - 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
人気
- GitHubのスター
- 18k
- ランキング
- #10651
- ライセンス
- MIT
- 更新日
- 2026/10/11
コメント
- …
このリポジトリの他のスキル
context-engineering-collection
18kエージェントが、AIモデルのコンテキストウィンドウに何を入れるかを管理するよう支援します。メモリやツールから、マルチエージェントの構成、評価までを扱います。
advanced-evaluation
18kエージェントが、スコアリング、並べての比較、バイアスの確認を使って、別のAIによりAIの回答を判定する方法を教えます。
bdi-mental-states
18kエージェントが、BDIの方法を使って信念、目標、計画をモデル化するよう教えます。そのため、各決定を追跡して説明できます。
context-compression
18kエージェントが、長いAIのセッションを、決定、ファイル、リスク、次のステップを残した要約に短縮するよう支援します。
似ているスキル
add-model-provider
394k安全なセットアップコマンドで新しいAIモデルプロバイダーをOpenClawに接続し、APIキーを平文で残さず、ライブテストを行うようエージェントを支援します。
acp-router
394kClaude CodeやCursorなどのコーディングアシスタントに、OpenClaw経由でタスクを渡し、その作業がそのツール内で行われるようエージェントを支援します。
browser-automation
394kログイン、タブ、応答しなくなったページからの復旧を含め、Webページを段階的に操作するようエージェントに教えます。