← 返回
未分类

Sharpagent Memory System

SharpAgent Layered Memory System — 6-layer memory hierarchy from ephemeral to long-term archive. Features dream processing (consolidation/archiving/forgettin...
SharpAgent 分层记忆系统 —6 层记忆层级,从瞬时到长期归档。支持梦境处理(整合、归档、遗忘…)
yezhaowang888-stack
未分类 clawhub v1.0.0 1 版本 99487.2 Key: 无需
★ 0
Stars
📥 194
下载
💾 0
安装
1
版本
#latest#layered#mcp#memory#sharpagent

概述

SharpAgent Layered Memory System v1.0.0

> Memory like a human — remembers what matters, forgets the rest, and searches accurately.

> Based on Layered Memory Sys (ClawHub, +324% in 24 days) 6-layer architecture + dream processing + Mem0 persistence.

Core Problem

Current agent memory problems:

ProblemSymptomConsequence
-------------------------------
ForgetsEvery session starts freshRepeats mistakes, no accumulation
Never forgetsAll history flatHigh retrieval noise, key info drowned
Poor searchKeyword only, no semantics"five-factor" doesn't find "trust verification"

SharpAgent memory solves all three with 6 layers + dream processing.

Memory Layers

                        [User interaction]
                            │
                   ┌────────┴────────┐
                   │   L1: Ephemeral │  ← Current session context
                   └────────┬────────┘
                            │ Session ends
                   ┌────────┴────────┐
                   │   L2: Short-Term│  ← Recent sessions (rolling window)
                   └────────┬────────┘
                            │ Periodic migration
                   ┌────────┴────────┐
                   │   L3: Working   │  ← Active task state
                   └────────┬────────┘
                            │ Task complete
                   ┌────────┴────────┐
                   │   L4: Contextual│  ← Task-level context
                   └────────┬────────┘
                            │ Dream processing
                   ┌────────┴────────┐
                   │   L5: Long-Term │  ← Preferences & lessons
                   └────────┬────────┘
                            │ Archive expired
                   ┌────────┴────────┐
                   │   L6: Archive   │  ← Historical archive
                   └─────────────────┘

L1: Ephemeral

Storage: Current session all messages

Capacity: Model context window

Lifespan: Session end = gone

Index: None, linear

Use: In-context understanding

L2: Short-Term

Storage: Last N sessions (default N=5)

Medium: In-memory (Redis optional)

Capacity: 5 session summaries, ≤2KB each

Lifespan: 7 days → auto-migrate to L4

Index: Session ID + timestamp + tags

Use: Quick cross-session reference

L3: Working

Storage: Active task state

Medium: JSON files (memory/working/)

Capacity: ≤10KB per task

Lifespan: Task complete → L4; task interrupted → kept

Index: Task ID + status + last update

Use: Resume interrupted tasks, multitasking

L4: Contextual

Storage: Completed task full context

Medium: JSON files (memory/contextual/) + optional SQLite

Capacity: Unlimited, but retrieval Top 5

Lifespan: Until dream processing (30d no reference → L5)

Index: TF-IDF full-text

Use: Look back at past tasks, reuse solutions

L5: Long-Term

Storage: Persistent cross-session knowledge

Medium: SQLite (memory/long_term.db) + Chinese tokenizer index

Capacity: Unlimited

Lifespan: Permanent unless explicitly forgotten

Index: TF-IDF + jieba Chinese tokenization

Use: User preferences, lessons, best practices, key decisions

L6: Archive

Storage: Expired or low-referenced L4/L5 entries

Medium: SQLite (memory/archive.db), read-only

Capacity: Theoretically infinite

Lifespan: Permanent read-only

Index: None (time + category)

Use: Legal compliance retention, audit trail

Dream Processing

Dreams aren't just for humans. Agents need low-load memory maintenance too.

Trigger: Heartbeat (low load, every 30 min), user says "clean up", or scheduled 04:00 daily.

Four Dream Operations:

1. Consolidation

Combine scattered memory fragments into coherent knowledge.

Input: Multiple fragments
→ "Use 150-char abstracts" (verified multiple times)
→ "User prefers shorter versions"
→ "Briefing read rate improved 30%"
→ Consolidate to:
  "Best practice: 150-char abstract in briefings (3x verified, +30% read rate)"

Trigger: Same pattern appears ≥3 times

2. Archiving

Move low-reference items out of working cache.

→ L4 entries with 0 references in 30 days
→ Move to L6 archive
→ Remove from L4 tag index

Trigger: 30-day reference count = 0

3. Forgetting

Actively delete low-value, duplicate, or outdated content.

→ "User once preferred Python 3.9" (3 months ago, now 3.13)
→ Outdated, delete
→ Keep space for valuable info

Trigger:

  • Newer version available
  • Explicitly contradicted
  • >90 days with <2 references
  • User says "forget this"

4. Merging

Combine multiple related L5 entries into higher-level patterns.

→ "Prefers 150-char abstract" (confidence=8)
→ "Prefers bullet points" (confidence=7)
→ "Dislikes tables" (confidence=6)
→ Merge:
  "User prefers briefings in bullet points + 150-char abstract, avoid tables"

Trigger: High confidence (≥7) + same category

Search

Standard Search

def search(query, layers=["L4", "L5"]):
    tokens = jieba.cut(query)      # Chinese tokenization
    vec = tfidf_vectorizer.transform(tokens)
    scores = cosine_similarity(vec, layer_index)
    return top_k(scores, k=5)

Chinese Tokenization

jieba.load_userdict("memory/custom_dict.txt")
# "五元组审查" → ["五元组", "审查"] not mis-split
# "惠迈校准框架" → ["惠迈", "校准", "框架"]

Search Priority

ScenarioSearch layersK
---------------------------
Real-time replyL5 → L4 → L23
Deep analysisL5 → L4 → L65
User asks "earlier..."L4 → L53
User asks "I remember..."L5 → L43

Storage Architecture

memory/
├── working/            # L3: Task working area (JSON)
├── contextual/         # L4: Contextual memory (JSON)
├── long_term.db        # L5: SQLite + FTS5 index
├── archive.db          # L6: Archive storage
├── custom_dict.txt     # Domain Chinese word dictionary
└── dream_log.json      # Dream processing log

Edge Cases

SituationAction
-------------------
Chinese + English mixed inputjieba auto-detects Chinese, English space-tokenized
No search resultsFallback to simple keyword matching
L5 exceeds 1000 entriesTrigger dream (archive + forget + merge)
Dream active, new interactionDream pauses immediately, interaction wins
User says "forget xxx"Soft delete in L5, L6 retains for audit
Bulk history importWrite directly to L6, skip layer traversal

Quality Gates

CheckWhatFail action
--------------------------
Layers separatedEphemeral/Short/Working/Contextual/Long/Archive distinctRestructure
Search recall"five-factor" retrieves "trust verification"Check tokenization
Dream non-blockingNormals interaction during dreamsAsync flag
Forget traceableForgotten entries auditableSoft delete
Chinese tokenizationDomain words preservedUpdate custom_dict.txt

Integration Points

Five-Factor Review

  • Important memory entries verified before writing
  • L5 entries carry FiveFactorResult

Self-Evolving Loop

  • Reflections → L4 contextual, verified lessons → L5 long-term
  • Dream consolidation output = new "best-practice" L5 entries

Engineering Lifecycle

  • Working L3 supports task checkpoint/resume
  • L4 stores engineering decision traces

Version History

  • v1.0.0 — Initial release. 6-layer memory architecture with dream processing, TF-IDF search, Chinese tokenization.

SharpAgent · MIT-0 · 2026-05-11

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-12 05:54 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

智能文档处理Skill

yezhaowang888-stack
基于DeepSeek v4技术,支持PDF、Word、Excel等文档的智能解析、信息提取、内容分析与格式转换,准确率99%。
★ 1 📥 544

📝 论文写作指导

yezhaowang888-stack
论文结构模板、引用规范、写作技巧——从开题到终稿全程陪伴。
★ 1 📥 496

学术研究助手

yezhaowang888-stack
学术研究全流程助手,提供论文写作指导、文献检索方法、学术工具推荐、期刊投稿指南、学术会议信息、科研项目管理等。适用于大学生、研究生和科研人员。支持家庭(知识库)和商业(API扩展)双模式。触发条件:用户提出与论文、文献、期刊、投稿、学术、科
★ 1 📥 768