跳到正文
Skillpedia
智能体8.6k · #12398

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/mvschwarz/openrig/blob/main/packages/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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-fork or agent-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:

  1. Claude built-in /compact — a Claude Code HARNESS feature, not OpenRig code. OpenRig only emits the literal /compact toward the pane after a prep turn; there is no compaction algorithm in the OpenRig repo. Provider-owned.
  2. 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.
  3. 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: true in 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能