Skill站外收录 @skilllib/skill-2117939930272415245
migrating-memory
实现跨智能体的记忆迁移与共享,支持将已有智能体的记忆块复制或关联至当前实例,可通过重命名避免标签冲突,适用于新代理初始化或知识协同场景。
效率工具 AI 技能
Skills.MD
# Migrating Memory
This skill helps migrate memory blocks from an existing agent to a new agent, similar to macOS Migration Assistant for AI agents.
## When to Use This Skill
- User is setting up a new agent that should inherit memory from an existing one
- User wants to share memory blocks across multiple agents
- User is replacing an old agent with a new one
- User mentions they have an existing agent with useful memory
## Migration Methods
### 1. Manual Copy (Recommended for partial content)
If you only need **part** of a source block, or the source is messy and needs cleanup:
1. Use `get-agent-blocks.ts` to view the source block's content
2. Use the `memory` tool to create a new block with just the content you want
3. No scripts needed - you have full control over what gets copied
Best for: Extracting sections, cleaning up messy content, selective migration.
### 2. Script Copy (Full block duplication)
Creates new blocks with the same content using `copy-block.ts`. After copying:
- You own the copy - changes don't sync
- Best for: One-time migration, forking an agent
### 3. Share (Linked Blocks)
Attaches the same block to multiple agents using `attach-block.ts`. After sharing:
- All agents see the same block content
- Changes by any agent are visible to all others
- Can be read-only (target can read but not modify)
- Best for: Shared knowledge bases, synchronized state
## Handling Duplicate Label Errors
**You cannot have two blocks with the same label.** If you try to copy/attach a block and you already have one with that label, you'll get a `duplicate key value violates unique constraint` error.
**Solutions:**
1. **Use `--label` (copy only):** Rename the block when copying:
```bash
npx tsx <SKILL_DIR>/scripts/copy-block.ts --block-id <id> --label project-imported
```
2. **Use `--override` (copy or attach):** Automatically detach your existing block first:
```bash
npx tsx <SKILL_DIR>/scripts/copy-block.ts --block-id <id> --override
npx tsx <SKILL_DIR>/scripts/attach-block.ts --block-id <id> --override
```
If the operation fails, the original block is automatically reattached.
3. **Manual detach first:** Use the `memory` tool to detach your existing block:
```
memory(agent_state, "delete", path="/memories/<label>")
```
Then run the copy/attach script.
**Note:** `attach-block.ts` does NOT support `--label` because attached blocks keep their original label (they're shared, not copied).
## Workflow
### Step 1: Identify Source Agent
Ask the user for the source agent's ID (e.g., `agent-abc123`).
If they don't know the ID, load the **finding-agents** skill to search:
```
Skill({ command: "load", skills: ["finding-agents"] })
```
Example: "What's the ID of the agent you want to migrate memory from?"
### Step 2: View Source Agent's Blocks
Inspect what memory blocks the source agent has:
```bash
npx tsx <SKILL_DIR>/scripts/get-agent-blocks.ts --agent-id <source-agent-id>
```
This shows each block's ID, label, description, and value.
### Step 3: Migrate Blocks
For each block you want to migrate, choose copy or share:
**To Copy (create independent block):**
```bash
npx tsx <SKILL_DIR>/scripts/copy-block.ts --block-id <block-id> [--label <new-label>]
```
Use `--label` if you already have a block with that label (e.g., `--label project-imported`).
**To Share (attach existing block):**
```bash
npx tsx <SKILL_DIR>/scripts/attach-block.ts --block-id <block-id>
```
Add `--read-only` flag to share to make this agent unable to modify the block.
Note: These scripts automatically target the current agent (you) for safety.
## Script Reference
All scripts are located in the `scripts/` directory and output raw API responses (JSON).
| Script | Purpose | Args |
|--------|---------|------|
| `get-agent-blocks.ts` | Get blocks from an agent | `--agent-id` |
| `copy-block.ts` | Copy block to current agent | `--block-id`, optional `--label`, `--override` |
| `attach-block.ts` | Attach existing block to current agent | `--block-id`, optional `--read-only`, `--override` |
## Authentication
The bundled scripts automatically use the same authentication as Letta Code:
- Keychain/secrets storage
- `~/.config/letta/settings.json` fallback
- `LETTA_API_KEY` environment variable
You can also make direct API calls using the Letta SDK if you have the API key available.
## Example: Migrating Project Memory
Scenario: You're a new agent and want to inherit memory from an existing agent "ProjectX-v1".
1. **Get source agent ID from user:**
User provides: `agent-abc123`
2. **List its blocks:**
```bash
npx tsx <SKILL_DIR>/scripts/get-agent-blocks.ts --agent-id agent-abc123
# Shows: project (block-def456), human (block-ghi789), persona (block-jkl012)
```
3. **Copy project knowledge to yourself:**
```bash
# If you don't have a 'project' block yet:
npx tsx <SKILL_DIR>/scripts/copy-block.ts --block-id block-def456
# If you already have 'project', use --label to rename:
npx tsx <SKILL_DIR>/scripts/copy-block.ts --block-id block-def456 --label project-v1
```
4. **Optionally share human preferences (read-only):**
```bash
npx tsx <SKILL_DIR>/scripts/attach-block.ts --block-id block-ghi789 --read-only
```
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「migrating-memory」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次