← 返回 Skills 市场
lgy2020

Context Persistence

作者 lgy2020 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
282
总下载
1
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install context-persistence
功能描述
Solve cross-session context storage and sync problems. Use when (1) isolated sessions (cron/subagent/heartbeat) lack context from main session, (2) long-runn...
使用说明 (SKILL.md)

Context Persistence & Cross-Session Sync

Design and implement persistent context systems that survive session boundaries.

Core Problem

OpenClaw has multiple session types with different context access:

Session Memory Files History Cron Context
Main DM ✅ All injected ✅ Full N/A
Group Chat ❌ Not loaded ✅ Partial N/A
Cron (isolated) ❌ None ❌ None ✅ Payload only
Heartbeat ❌ None ✅ Partial N/A
Subagent ❌ None ❌ None ✅ Task only

Result: State created in one session is invisible to others unless persisted to files.

Architecture: Three-Layer Memory System

Layer 1: Long-Term Memory (MEMORY.md)

  • What: Curated facts, decisions, lessons, key state
  • Who writes: Main session only
  • Who reads: Main session only (injected via AGENTS.md)
  • Update frequency: On significant events, periodic review during heartbeats
  • Size limit: \x3C 200 lines (context budget)

Layer 2: Daily Logs (memory/YYYY-MM-DD.md)

  • What: Raw chronological notes, conversations, decisions
  • Who writes: Any session that has something to record
  • Who reads: Main session (at startup), heartbeats (for review)
  • Update frequency: Real-time as events happen
  • Size limit: Unbounded (not injected into context)

Layer 3: Task Progress Files (memory/\x3Ctask>-progress.md)

  • What: Structured progress for long-running work
  • Who writes: Any session doing the task
  • Who reads: Any session continuing the task
  • Update frequency: At task boundaries (session end, checkpoints)
  • Size limit: \x3C 300 lines

The Key Insight

Files are the only cross-session communication channel. In-memory state dies with the session. Files survive.

Pattern 1: Progress Tracking

For tasks spanning multiple sessions (source code reading, data analysis, etc.)

See references/progress-tracking.md for full template.

Essential elements:

# \x3CTask> Progress
- Total: X items
- Completed: Y items  
- Progress: Z%
## Completed List (dedup)
## Current Position / Next Steps
## Key Findings

Pattern 2: Cron Job Context Injection

Isolated cron sessions have NO access to workspace memory. Solutions:

  1. Embed context in payload message (for \x3C1KB state)
  2. Read from progress files (task loads its own context)
  3. Shared state file (coordination between sessions)

See references/cross-session-sync.md for patterns.

Pattern 3: Main Session Initialization

The AGENTS.md startup sequence ensures context loading:

1. Read SOUL.md (persona)
2. Read USER.md (who you help)
3. Read memory/YYYY-MM-DD.md (today + yesterday)
4. If main session: also read MEMORY.md

This is the ONLY automated context loading. Everything else must be explicit.

Quick Checklist

When designing context for a new task:

  • Can this span multiple sessions? → Create progress file
  • Does cron/subagent need this? → Embed in payload or file
  • Is this a fact to remember? → Update MEMORY.md
  • Is this a raw event? → Append to daily log
  • Should future sessions know this? → Write it DOWN, never rely on memory
安全使用建议
This skill appears coherent and useful for cross-session state, but note it centralizes data on disk. Before installing: (1) decide whether progress/daily files may contain sensitive user data — avoid putting secrets in them; (2) apply file permissions, encryption, or an access policy for memory/ directory; (3) add retention/rotation and purge rules so long-term logs don't accumulate sensitive history; (4) be careful when embedding context into cron payloads (payloads may be logged or visible to operators); (5) use atomic writes or the recommended lock pattern to avoid races. If you need stronger guarantees (encryption, audit logs, or remote secure storage), plan those controls before relying on these patterns.
功能分析
Type: OpenClaw Skill Name: context-persistence Version: 1.0.0 The skill bundle provides a structured framework for an AI agent to maintain state across different session types (Cron, Heartbeat, Subagents) using local file-based storage. It defines a three-layer memory system (long-term, daily logs, and task-specific progress) and provides templates for implementation in files like SKILL.md and references/memory-patterns.md. No malicious intent, data exfiltration, or unauthorized execution patterns were found; the logic is entirely focused on workspace organization and context management.
能力评估
Purpose & Capability
Name and description match the SKILL.md: it provides file-based patterns (MEMORY.md, daily logs, progress files) and cron/payload guidance. It requests no binaries, env vars, or installs — proportional to an instruction-only persistence design.
Instruction Scope
Instructions stay within context-persistence responsibilities (read/write workspace files, embed small context into cron payloads, use progress files, locks). However, the guidance assumes writing potentially sensitive user and task data to disk without recommending access controls, encryption, or retention policies — this is a practical privacy/security concern (not an incoherence).
Install Mechanism
Instruction-only skill with no install spec or downloaded artifacts — lowest-risk install footprint and consistent with a patterns-and-guidelines skill.
Credentials
No environment variables, credentials, or config paths are requested. The skill does not ask for unrelated secrets or external API keys; its file-based approach aligns with its purpose.
Persistence & Privilege
always is false and the skill is user-invocable. It does not request persistent or cross-skill privileges or to modify other skills. Autonomous invocation is allowed (platform default) but not combined with broad credentials here.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install context-persistence
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /context-persistence 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of the context-persistence skill for cross-session memory and progress tracking. - Introduces a three-layer memory architecture: curated long-term memory, daily logs, and task-specific progress files. - Solves issues with context and state loss across isolated session types (cron jobs, subagents, heartbeats). - Provides filing patterns and templates for progress tracking, cron job context injection, and main session initialization. - Includes a design checklist to ensure reliable cross-session state persistence.
元数据
Slug context-persistence
版本 1.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Context Persistence 是什么?

Solve cross-session context storage and sync problems. Use when (1) isolated sessions (cron/subagent/heartbeat) lack context from main session, (2) long-runn... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 282 次。

如何安装 Context Persistence?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install context-persistence」即可一键安装,无需额外配置。

Context Persistence 是免费的吗?

是的,Context Persistence 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Context Persistence 支持哪些平台?

Context Persistence 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Context Persistence?

由 lgy2020(@lgy2020)开发并维护,当前版本 v1.0.0。

💬 留言讨论