agent-sleep
🧠 agent-sleep
AIエージェントのための永続的な経験統合と意思決定サポート。
軽量でフレームワークに依存しないPythonライブラリおよびMCPサーバーであり、ホストエージェントがセッションをまたいで適応するために使用できる永続的な経験統合と意思決定サポートのシグナルを提供します。生物学的な脳が睡眠サイクルを使って覚醒時の経験を永続的な手続き的ルールと教訓に統合する仕組みに着想を得ています。
問題: 「エージェント健忘症」
あらゆる現代のAIエージェントフレームワーク(LangChain、AutoGen、CrewAI、OpenAI Assistants)はエージェント健忘症に悩まされています:
新しいチャットやサブエージェントの実行は毎回完全にゼロから始まります。
エージェントが月曜日にエラーに遭遇したり、コードベースの規約を発見したりしても、火曜日にはまったく同じミスを繰り返します。
ベクターDB(RAG)は静的なドキュメントを検索するだけであり、実行時の経験から学習することはありません。
Related MCP server: cortex-engine
MCPクイックスタート — 10秒
これが主要な利用経路です。
agent-sleepはMCPサーバーとして提供されるため、MCPをサポートする任意のエージェント(Antigravity、Claude Desktop、Cursor、Cline)はコードを書かずに利用できます。
ステップ1 — インストールと設定の生成
# Option A: zero-install (recommended)
uvx agent-sleep-mcp
# Option B: install first, then run the init helper
pip install "agent-sleep[mcp]"
agent-sleep init # prints the correct config snippet for your platformagent-sleep init はOSを自動検出し、MCPクライアントの設定ファイルに貼り付けるJSONスニペットを出力します。手動編集は不要です。
ステップ2 — 設定スニペットを貼り付ける
init コマンドは、何をどこに貼り付けるかを正確に出力します。macOS上のClaude Desktopでの出力例:
{
"mcpServers": {
"agent-sleep": {
"command": "uvx",
"args": ["agent-sleep-mcp"]
}
}
}それを ~/Library/Application Support/Claude/claude_desktop_config.json に貼り付け、Claudeを再起動すれば完了です。
ステップ3 — エージェントに使うよう依頼する
"Before we start, check your memory for anything relevant to this task."
"Record that we use pytest fixtures — not unittest — in this project."
"Run a sleep consolidation so you remember today's lessons next session."メモリはプロジェクトディレクトリ内の .agent_sleep/memory.db に自動的に保存されます(デフォルトでgitignoreされます)。
保存内容の確認 — CLI
エージェントが何を学習したかを確認するのにLLMを経由する必要はありません:
# See all memories and rules for the current project
agent-sleep show
# Clear a project's memory (with confirmation prompt)
agent-sleep reset
# Target a specific scope or DB
agent-sleep show --scope my_api --db /path/to/memory.db仕組み: 3フェーズパイプライン
[ ONLINE EXECUTION PHASE ]
Agent executes tool calls
│
▼
┌──────────────────────────────────────────────┐
│ 1. EPISODIC RECORDING │
│ memory.record_episode(...) │ Fast, minimal overhead.
│ Records goal, action, outcome, errors. │ Stores execution events.
└──────────────────────┬───────────────────────┘
│
(Session ends / Agent idle)
│
▼
[ OFFLINE SLEEP CONSOLIDATION ]
┌──────────────────────────────────────────────┐
│ 2. SLEEP CONSOLIDATOR (8-Stage Pipeline) │
│ SleepConsolidator.run(session_id) │
│ │
│ • Priority Replay (prediction error) │
│ • Deterministic Episodic Distillation │ Grounding first:
│ • Procedural Recipe Extraction │ distills facts & lessons
│ • How-Memory Trajectory Abstraction │ before optional LLM
│ • Behavioral Rule Promotion (seen ≥2x) │ generalization passes.
│ • Epistemic Status (observed vs verified)│
│ • Episodic Compression over time │
│ • Self-Competence EMA Tracking │
└──────────────────────┬───────────────────────┘
│
(Next session / New task)
│
▼
[ ONLINE SELECTIVE RECALL ]
┌──────────────────────────────────────────────┐
│ 3. SELECTIVE SEMANTIC RECALL │
│ memory.recall(new_task) │ Pre-computed vector BLOBs.
│ Returns only relevant lessons & rules │ Prevents prompt dilution.
│ filtered by project scope & relevance. │
└──────────────────────────────────────────────┘主要機能 (v0.1.2-alpha)
事前計算済みベクトルBLOB: クエリを一度だけ埋め込み、事前計算済みの保存ベクトルと比較することで、想起時のテキスト埋め込みの繰り返しを排除します。
認識論的メモリライフサイクル: メモリの進行をステージ(
RAW→OBSERVED→REPEATED→VERIFIED→ACTIVE)で追跡し、矛盾したメモリや失敗率の高いメモリを自動的に隔離します。検証可能な因果帰属とユーティリティフィードバック: 構造化された証拠記録(
retrieval→action change→outcome attribution)を通じて、取得したメモリが将来の実行に実際に役立ったかどうかを評価します。証拠多様性に基づく因果仮説: 独立した情報源と環境にわたる証拠多様性スケーリングを用いて、繰り返し発生する失敗を因果メカニズムに蒸留します。
ベイズ自己コンピテンスモデル: 複合ドメインにわたるドメインコンピテンスとベイズベータ分布の不確実性を推定し、ホストエージェントに適応的な意思決定サポート(検証強度、リトライ予算)を提供します。
ファーストクラスのルール特異性エンジン: 階層的な優先順位(
specific verified>general verified>specific candidate>general candidate)と動的な例外抑制によってルールの競合を解決します。スコープとプロジェクトの分離: 多層ネームスペース(
scope="repo_a"、scope="global")。プロジェクト固有の知識は厳密に分離され、汎用的なイディオムやツールの失敗モードはオプションでglobalを介して共有できます。必須の重い依存関係ゼロ: 標準のSQLiteと決定論的ハッシュ化bag-of-wordsフォールバックを使用して、そのまま動作します。
sentence-transformers(all-MiniLM-L6-v2)がインストールされている場合はシームレスにアップグレードされます。
ベンチマークと評価
1. 制御された転移シミュレーション (benchmarks/run.py)
繰り返し発生するアーキテクチャ上の罠を含む12の連続ソフトウェアタスクにわたって、メモリ統合、ベクトル検索、知識転移を評価します:
メトリック | メモリOFF | メモリON | 改善 |
合格率 (Pass@12) | 67% | 92% | +25パーセントポイント |
タスクあたりの平均LLM呼び出し | 14.7 | 8.5 | -42%(呼び出し削減) |
繰り返しのミス | 8 | 2 | -75%(ミス削減) |
注: 制御された転移シミュレーションは、メモリ検索と罠回避の決定論的な認知制御ダイナミクスを評価します。
2. 標準的な6方向アブレーションベンチマーク (benchmarks/agent_eval/runner.py)
8つの標準化されたソフトウェアエンジニアリングタスクにわたる、メモリ駆動型エージェント制御ダイナミクスの制御されたサンドボックス評価:
実験条件 | 合格率(ゼロショット) | タスクあたりの平均LLM呼び出し | 繰り返しの罠 | メモリ有用率 |
| 12.5% | 3.6 | 4 | 0.0% |
| 12.5% | 3.6 | 4 | 0.0% |
| 12.5% | 3.6 | 4 | 0.0% |
| 25.0% | 2.9 | 2 | 12.5% |
| 37.5% | 2.5 | 1 | 25.0% |
| 75.0% | 1.4 | 0 | 75.0% |
python benchmarks/agent_eval/runner.py[!NOTE] 科学的およびバックエンドの開示:
サンドボックスベンチマークは、制御されたテストスイートの下でエージェント制御ダイナミクス、トークン効率、エラー回避を評価します。
埋め込みバックエンド: 高精度のベクトル類似度は
sentence-transformers(all-MiniLM-L6-v2)に依存します。依存関係がない場合、ライブラリは自動的に決定論的ハッシュ化bag-of-words埋め込みにフォールバックします。完全な再現性プロトコルとメトリックログは
benchmarks/agent_eval/results.jsonに文書化されています。
Pythonライブラリの使用方法
MCP経由ではなく、独自のエージェントコードからメモリシステムを操作したい場合は、Python APIが完全にサポートされています。
from agent_sleep import AgentMemory, SleepConsolidator
# 1. Initialize memory scoped to your project/repo
memory = AgentMemory(session_id="session_01", scope="payment_service")
# 2. Record actions and outcomes during your agent's loop
memory.record_episode(
goal="Refactor payment processor to async",
action="edit_file('processor.py', ...)",
outcome="failure",
failure_reason="SyntaxError: 'await' outside async function",
)
# 3. Trigger sleep consolidation when idle or at session end
consolidator = SleepConsolidator(scope="payment_service")
report = consolidator.run(session_id="session_01")
# -> {'episodes_processed': 1, 'memories_written': 1, 'rules_promoted': 0, ...}
# 4. Next session: recall relevant context before executing
context = memory.recall("Add Stripe webhook handler")
print(context)
# [MEMORY CONTEXT]
# Relevant past experience:
# ⚠ [LESSON] Caution on task: Refactor payment processor to async:
# A previous attempt failed: SyntaxError: 'await' outside async function.
# [END MEMORY CONTEXT]インストール
MCPサポート付きクイックインストール:
pip install "agent-sleep[mcp]"完全なセマンティック埋め込みを使用(推奨):
pip install "agent-sleep[all]"GitHubから(最新アルファ版):
pip install git+https://github.com/thevisionhub/agent-sleep.git開発用の編集可能インストール:
git clone https://github.com/thevisionhub/agent-sleep.git
cd agent-sleep
pip install -e ".[all]"MCPツールリファレンス
ツール | 呼び出しタイミング |
| 計画や実行の前に、非自明なタスクに対して呼び出し — 教訓、ルール、因果的な罠、自己コンピテンス指示を取得します |
| 実行中に、各ツールの失敗やマイルストーンの後に呼び出し |
| セッション終了後、またはエージェントがアイドル状態のときに呼び出し |
| いつでも — メモリの健全性、認識論的な内訳、保留中のエピソードを検査します |
| 取得した知識を適用した後に呼び出し — 因果的な結果の帰属を記録し、ユーティリティスコアを更新します |
| 既存のルールに対する例外や境界条件を発見したときに呼び出し |
すべてのツールは、scope を現在の作業ディレクトリ名に、db_path をプロジェクトルートの .agent_sleep/memory.db にデフォルト設定します。一般的なケースでは設定は不要です。
テストの実行
pytest tests/ -v発見される — レジストリ掲載
agent-sleep をMCPレジストリに提出するのは各約5分で、メモリツールを探している開発者にリーチする最速の方法です:
Smithery — GitHubのURLを貼り付け、短い説明を追加すれば完了です。
modelcontextprotocol/servers — READMEの「Community Servers」の下にエントリを追加するPRを開いてください。
Cursor — MCPサーバーも表示します。最新の提出プロセスについては現在のドキュメントを確認してください。
ライセンス
MITライセンス — 個人、商用、研究利用は無料です。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to retain memory of past interactions and detect behavioral drift, preventing repeated mistakes without LLM token extraction.236MIT
- AlicenseNot gradedqualityAmaintenancePersistent memory for AI agents with semantic memory, belief tracking, and dream consolidation, enabling cross-session knowledge retention.3149MIT
- AlicenseNot gradedqualityDmaintenanceProvides persistent, cross-session memory for AI agents, allowing them to store and automatically retrieve information across different conversations and sessions without repeating context.9175MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to store, search, and recall semantic memories with three memory types (semantic, episodic, procedural) and auto-consolidation, compounding intelligence over time.16MIT
Related MCP Connectors
Persistent memory for AI agents — verbatim conversations, searchable by meaning.
Persistent memory and drift detection for AI agents across session restarts.
Persistent memory for AI agents. Search, store, and recall across sessions.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/thevisionhub/agent-sleep'
If you have feedback or need assistance with the MCP directory API, please join our Discord server