AIセッション間のコンテキストを記憶 — コーディング向けの永続メモリ
問題点:AIエージェントは全てを忘れる
Section titled “問題点:AIエージェントは全てを忘れる”Claudeで機能をビルドしているとします。以下を説明します:
- 「ACID準拠のためにPostgresをMongoDBより選んだ」
- 「Redisプール枯渇はmax_connections=20で修正した」
- 「RESTエンドポイントには常に/api/v1/プレフィックスを使う」
次のセッションでは?Claudeはこれらの記憶がない。最初からやり直します。
これは以下を無駄にします:
- トークン — 同じコンテキストを再説明
- 時間 — 決定を再構築
- お金 — 同じAPIコールを二重に支払う
ソリューション:全てを記憶する
Section titled “ソリューション:全てを記憶する”toon-memoryはAIコーディングエージェントに永続メモリを提供します:
- 再起動後も残る — メモリはセッション間で持続
- オフラインで動作 — クラウド不要、APIコール不要、LLM不要
- トークンを節約 — JSONより22%少ないトークン
- スケール — セッションあたり80%少ないツール呼び出し
ステップ1: 重要なコンテキストを保存する
Section titled “ステップ1: 重要なコンテキストを保存する”セッションの終わりに、重要なものを保存します:
memory_remember({ category: "decision", key: "use-postgres", content: "Choose Postgres for ACID compliance and JSON support", tags: "database;architecture"})ステップ2: セッション開始時にリコールする
Section titled “ステップ2: セッション開始時にリコールする”次のセッションの開始時に、即座にコンテキストを取得します:
memory_smart_recall({ intent: "what I was working on" })// BM25+グラフ+品質を組み合わせた関連エントリを返すステップ3: ビルドを続ける
Section titled “ステップ3: ビルドを続ける”エージェントは以下を知っています:
- データベースの選択(Postgres)
- 選んだ理由(ACID準拠)
- 関連する決定(キャッシュにRedis、バリデーションにZod)
什么样的コンテキストを記憶できるか
Section titled “什么样的コンテキストを記憶できるか”アーキテクチャ決定
Section titled “アーキテクチャ決定”memory_remember({ category: "decision", key: "microservices-approach", content: "Use microservices for payment and auth, monolith for core business logic"})memory_remember({ category: "bug", key: "redis-connection-timeout", content: "Redis connection timeout in production — fix was increasing pool size to 20"})コードパターン
Section titled “コードパターン”memory_remember({ category: "pattern", key: "error-handling", content: "Always use custom AppError class, never throw raw Error objects"})プロジェクトナレッジ
Section titled “プロジェクトナレッジ”memory_remember({ category: "knowledge", key: "team-conventions", content: "PR #142 reverted the caching change — don't re-add it without team approval"})役立つメモリ機能
Section titled “役立つメモリ機能”自動タグ推論
Section titled “自動タグ推論”tagsを空にすると、toon-memoryはコンテキストから自動推論します:
memory_remember({ category: "bug", key: "redis-timeout", content: "Redis connection timeout in production"})// タグ自動推論: redis関連エントリの提案
Section titled “関連エントリの提案”保存すると、toon-memoryが関連エントリを見つけます:
memory_remember({ category: "decision", key: "use-zod", content: "Use Zod for validation"})// 🔗 Related: redis-timeout (mentions "validation")品質スコアリング
Section titled “品質スコアリング”各エントリには自動的に品質スコア(0-1)が付与されます:
| 要因 | 重み |
|---|---|
| タグ | 最大0.3 |
| リンク | 最大0.2 |
| コンテキストの長さ | 最大0.3 |
| 新しさ | 最大0.1 |
| 特定性 | 最大0.1 |
高品質なエントリがリコールで優先的に表示されます。
マージ重複排除
Section titled “マージ重複排除”同じキーで保存すると、属性が自動的にマージされます:
// 初回保存memory_remember({ key: "use-zod", content: "Use Zod for validation" })
// 後の保存 — 自動マージmemory_remember({ key: "use-zod", content: "Use Zod — also handles API parsing" })// タグとリンクが結合され、上書きされないマルチセッション調整
Section titled “マルチセッション調整”複数のエージェントセッションを並列で実行している?toon-memoryが調整します:
memory_sessions()// 🧭 Active sessions (2):// • claude @ feature/auth (you)// • opencode @ feature/db// 🔥 Soft conflicts: src/types.ts他のセッションがどのファイルにアクセスしているかを確認し、マージ競合を回避します。
始めましょう
Section titled “始めましょう”npm install -g toon-memorynpx toon-memory # インタラクティブインストーラー次のセッションでエージェントは全てを記憶します。