session-compaction-and-restore
它能做什么
这个技能说明 AI 智能体在上下文被压缩、重启或刷新时,如何保留有用的工作状态。适合长期运行、重置后不能变得冷清的席位的运维人员和智能体。
适用场景
- ✓席位即将压缩或刚刚压缩的时候。
- ✓你为正在进行的工作设计恢复数据包的时候。
- ✓你必须在原生恢复、分叉和基于产物重建之间做选择的时候。
技能链接
https://github.com/mvschwarz/openrig/blob/main/packages/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们的规划者席位即将压缩。请设计一个恢复数据包,保留产品意图,而不只是文件名。”
每周 5 个新技能,1 分钟读完。
工作原理
它解释各种恢复模式以及常见的失败模式,帮助智能体既保留细节,也保留产品意图和下一步。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Session Compaction and Restore
Preserving useful working state across compaction, context loss, restart, or seat refresh. Includes Claude compaction restore, Codex resume/fork mechanics, transcript-based mental-model rebuilds, and durable handoff packets.
Long-lived seats are valuable only if they can survive context pressure. If compaction turns a senior seat into a cold-started agent, users will avoid persistent topologies and fall back to throwaway agents.
Use this when
- A seat is approaching compaction or just compacted
- Designing a high-fidelity restore packet for an active workflow
- Distinguishing native runtime resume vs fork vs artifact-backed mental-model rebuild
- Reasoning about what should be preserved vs reconstructable
- Auditing a restore for product-intent preservation (not just detail preservation)
Don't use this when
- The session is fresh and has no working state to preserve
- The intent is to create a new seat from a primed source — that's
session-source-forkoragent-starters - The packet is a one-off snapshot for human review — restore packets are for re-entering active work
The 5 distinctions (do not collapse)
Per the cross-runtime restore/reentry packet standard:
| Mode | What it means | Outcome literal |
|---|---|---|
| Native resume | Continue the same managed seat with native runtime token | resumed |
| Fork | New managed seat from prior native runtime conversation; new post-fork token | forked |
| Rebuild | Fresh-launch seeded with operator-declared artifacts in trust-precedence order | rebuilt |
| Artifact-backed mental-model rebuild | Restored seat derives understanding from a packet rather than native runtime continuity | (case of rebuilt) |
| Fresh launch | New agent without prior continuity | fresh |
These are load-bearing distinctions. Do NOT collapse fork into
artifact-backed reentry; do NOT collapse rebuild into fork.
The three mechanisms — who owns each (verified vs main d37a08ad, 2026-07-21)
The outcomes above ride on three DISTINCT mechanisms; keep them separate:
- Claude built-in
/compact— a Claude Code HARNESS feature, not OpenRig code. OpenRig only emits the literal/compacttoward the pane after a prep turn; there is no compaction algorithm in the OpenRig repo. Provider-owned. - OpenRig-managed restore — the enforcer + hook bridge: a precompact hook
WRITES a restore packet; a bridge READER injects exactly ONE restore directive
back via the harness hook channel (
hookSpecificOutput.additionalContext), seat-isolated. The OpenRig-owned half. - Codex session continuity — resume/rollout tokens (
codex resume <token>), a separate path from the Claude mechanisms. Never conflate with Claude restore.
Safety boundary (ties to native-session-file-lab-boundary): no supported
OpenRig path EDITS provider-owned native session / auth / transcript files to
inject context. Context enters ONLY through sanctioned channels: the hook
additionalContext, a normal user message via rig send, or Codex resume tokens.
Precise nuance: OpenRig does write ~/.codex/config.toml — but only to install
OpenRig activity hooks and [features], never session or auth state. So the
rule is "never edits native session/auth/transcript files," NOT "never touches any
provider-owned file."
Claude's own idle compaction while managed compaction is on
While policies.claude_compaction.enabled is true with a valid threshold (the enforcer treats any other
threshold as off), every Claude session OpenRig launches (fresh, fork, resume and restore; ordinary, kernel,
team-default and full-bypass seats) carries idleCompaction: false in its one --settings value. Claude Code then
doesn't compact an idle session on its own, so managed seats compact through OpenRig's sequence (restore map, then
/compact at the threshold).
- Version boundary: Claude Code supports the key from 2.1.290. Earlier versions ignore it, so idle compaction stays possible there.
- Precedence: it overrides a lower-precedence
idleCompaction: truein user or project settings for those launches. Claude's managed settings still win. - Native threshold auto-compaction is untouched (
autoCompactEnabled,DISABLE_AUTO_COMPACT). Where the enforcer has no fresh status-line usage sample for a seat, it doesn't compact that seat, and native auto-compaction is then the only compaction. Nothi
常见问题
什么是恢复数据包?
它是一份文档,使智能体在重置后能够重新进入正在进行的工作,并带有关键上下文。
原生恢复等同于交接吗?
不等同。技能说明,运行环境的原生恢复不应被误认为是交接。
它也涵盖 Codex 吗?
涵盖。它既涵盖 Claude 压缩后的恢复,也涵盖 Codex 的恢复和分叉机制。
详情
作者的原始描述
Use when reasoning about what survives compaction/context-loss/restart/seat-refresh, designing a high-fidelity restore packet, or distinguishing native runtime resume vs fork vs artifact-backed mental-model rebuild. Covers the 4 failure modes that prevent honest restore (compacted seat drops hot potato; restore packet preserves details but loses product intent; runtime resume mistaken for handover or fork; rebuilt seat starts with stale instructions).
repo: mvschwarz/openrig
热度
- GitHub 星标
- 8.6k
- 排名
- #12398
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agent-operated-software
8.6k帮你的智能体设计、构建或调试一个后端包含 AI 智能体的持续运行应用,例如基于 Markdown 或 JSON 的智能体控制层。
agent-operated-workflows
8.6k帮你的智能体判断一个有边界的流程应由 AI 智能体还是普通代码执行,并基于已验证的证据从中断处恢复。
applying-a-permission-policy
8.6k帮你的智能体在团队设置时配置 AI 编程智能体使用的命令权限,让常规命令减少审批提示。
claude-compaction-restore
8.6k帮助 Claude Code 智能体在上下文被压缩后,借助保存的恢复图、对话记录和它改动过的文件,重建工作认知。