self-managed-context
Skill này làm gì
Skill này bao quát các agent kiểm soát ngữ cảnh sống của chính chúng, quyết định giữ, nén hoặc xóa gì, thay vì một hệ thống cố định làm việc đó. Nó dành cho các nhóm thử nghiệm với model tự chỉnh sửa bộ nhớ làm việc của mình.
Khi nào nên dùng
- ✓Khi bạn muốn một model tự chỉnh sửa ngữ cảnh của nó thay vì theo lịch nén cố định.
- ✓Khi bạn cần quy tắc an toàn để tự chỉnh sửa không làm hỏng cache hoặc thêm chỉ dẫn ẩn.
- ✓Khi một agent phải giữ chi tiết nguyên văn và xóa thông tin không liên quan theo yêu cầu.
Liên kết skill
https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/self-managed-context/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Cho agent của tôi tự chỉnh sửa ghi chú làm việc trong một tác vụ dài, và đảm bảo nó không vô tình làm hỏng hướng dẫn của mình.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill mô tả việc phơi bày ngữ cảnh như một file có thể chỉnh sửa, cùng các biện pháp bảo vệ như tiền tố được ghim, cổng chỉnh sửa, biên nhận chỉnh sửa và hoàn tác khi cửa sổ bị tràn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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.
Câu hỏi thường gặp
Ngữ cảnh tự quản lý là gì?
Chính model quyết định phần nào ở lại trong ngữ cảnh sống của nó, thay vì một hệ thống cố định quyết định thay.
Vì sao chỉnh sửa tốn thêm chi phí?
Chỉnh sửa có thể làm hỏng prefix caching, nên một chỉnh sửa đặt sai có thể tốn nhiều tính toán hơn lượng chỗ nó giải phóng.
Skill mô tả những biện pháp bảo vệ nào?
Tiền tố được ghim, cổng chỉnh sửa, biên nhận chỉnh sửa, chỉ số ngân sách và hoàn tác khi ngữ cảnh bị tràn.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 18k
- Vị trí xếp hạng
- #10651
- Giấy phép
- MIT
- Cập nhật
- 11/10/2026
Bình luận
- …
Thêm skill từ kho mã này
context-engineering-collection
18kGiúp agent của bạn quản lý những gì đưa vào cửa sổ ngữ cảnh của model AI, từ bộ nhớ và công cụ đến thiết lập nhiều agent và đánh giá.
advanced-evaluation
18kDạy agent của bạn cách đánh giá câu trả lời AI bằng một AI khác, với chấm điểm, so sánh cạnh nhau và kiểm tra thiên lệch.
bdi-mental-states
18kDạy agent của bạn mô hình hóa niềm tin, mục tiêu và kế hoạch bằng cách tiếp cận BDI, để các quyết định của nó có thể được truy vết và giải thích.
context-compression
18kGiúp agent của bạn rút gọn các phiên AI dài thành bản tóm tắt giữ lại quyết định, file, rủi ro và bước tiếp theo.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.