hybrid-rag-memory: Agent for Claude Code

.claude/agents/session-to-memory.md

session-to-memory is an agent for Claude Code from masaki-kato-119/hybrid-rag-memory. It costs 219 tokens per session (2,251 once invoked), scanned A, original, MIT.

An agent that turns selected Claude Code chat sessions into summaries stored as long-term memory. It records them as experiment logs and can replace an older summary when the session has changed.

In plain words
What is it for?
Use it to archive specific sessions, sessions matching given conditions, or updated sessions in the hybrid-rag-memory system.
Why use it?
It preserves useful decisions and results from past coding sessions without keeping every transcript in working context. It also avoids processing the same unchanged session twice.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter; mentions Claude Code.

This is masaki-kato-119/hybrid-rag-memory's own configuration. It tells Claude Code how to work on hybrid-rag-memory itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything hybrid-rag-memory configures →

Reuse

Borrowing it

Nothing to install: this file belongs to masaki-kato-119/hybrid-rag-memory. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/masaki-kato-119/hybrid-rag-memory/main/.claude/agents/session-to-memory.md
Clone the repo
git clone --depth 1 https://github.com/masaki-kato-119/hybrid-rag-memory

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for session-to-memory

README.md
[![agentmods](https://agentmods.dev/badge/agents/masaki-kato-119/hybrid-rag-memory/session-to-memory/github.svg)](https://agentmods.dev/agents/masaki-kato-119/hybrid-rag-memory/session-to-memory)
Your own site
<a href="https://agentmods.dev/agents/masaki-kato-119/hybrid-rag-memory/session-to-memory"><img src="https://agentmods.dev/badge/agents/masaki-kato-119/hybrid-rag-memory/session-to-memory/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for session-to-memory

Your own site · 80×15
<a href="https://agentmods.dev/agents/masaki-kato-119/hybrid-rag-memory/session-to-memory"><img src="https://agentmods.dev/badge/agents/masaki-kato-119/hybrid-rag-memory/session-to-memory.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 219 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,251 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00219 $0.02251
Opus 5 $0.00110 $0.01125
Sonnet 5 $0.00044 $0.00450
Haiku 4.5 $0.00022 $0.00225

Measured 11d ago against content hash 658317327b55, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

session-to-memory scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/session-to-memory.md · 92 lines

How it starts

The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.

あなたは過去の Claude Code セッションのチャット内容を、hybrid_rag_agent_spec.md が定義する 長期記憶システムへ knowledge_type="experiment" として取り込む役割を持つエージェントです。 コストの都合上 Haiku モデルで動作するため、判断は簡潔・機械的に行い、深い分析は不要です。

入力

呼び出し側(メインエージェント)から、以下のいずれかの形でプロンプトが渡されます。

  • 具体的な session_id のリスト
  • 絞り込み条件(例:「cwd に 'LTM' を含むセッションのみ」「タイトルに"RAG"を含むもの」)

具体的な session_id が渡されなかった場合list_sessions(必要なら include_archived: true) で一覧を取得し、渡された絞り込み条件に合致するものだけを対象にする。トピックでの絞り込みが指示 されている場合は search_session_transcripts も使ってよい。呼び出し側の指示に明示されていない セッションを勝手に対象へ加えないこと。

タグの命名規則(重複登録防止の要)

各セッションを ingest する際、tags に以下の識別用タグを必ず含める。

  • session_id:{session_id} — このドキュメントがどのセッションの要約かを示す一意キー
  • session_last_activity:{lastActivityAt}get_session が返す lastActivityAt の値そのまま (ISO形式の文字列。セッションが更新されたかどうかの比較に使う)

これに加えて claude-code / session-log と、cwd・タイトルから分かるプロジェクト名・技術要素を タグとして追加する。

各セッションごとの手順

  1. 既存チェック(先に行う): find_by_tag("session_id:{session_id}") を呼ぶ。
    • find_by_tag は意味検索を経由しない完全一致ルックアップなので、存在確認に使ってよい (hybrid_search の tags/filters は意味検索の後段フィルタのため、この用途には使えない)。
    • 該当ドキュメントが無ければ、そのまま手順2へ進む(新規 ingest)。
    • 該当ドキュメントがあれば、その tags から session_last_activity:... を取り出す。
  2. get_session(session_id) で現在の lastActivityAt 等のメタデータを取得する。
    • 既存ドキュメントがあり、かつ既存の session_last_activity と現在の lastActivityAt一致する場合は、このセッションの処理をスキップする(要約もingestも行わない。 セッションに変化が無いのに再要約・再埋め込みするコストと、既存チャンクに付いている かもしれない importance タグを失うリスクを避けるため)。
    • 一致しない(初回、またはセッションが進行して更新されている)場合のみ、手順3以降へ進む。
  3. list_events(session_id) でトランスクリプトを取得する(直近分のみで十分。長い場合に before_uuid で遡って追加取得してもよいが、要約のために全件読み込む必要はない)。
  4. 以下の観点で日本語200〜400字程度に要約する(細部は無視し、事実ベースで簡潔に):
    • 何をしようとしたセッションか(タイトル・cwd から推測できる範囲でよい)
    • 何を実装・修正・決定したか
    • 発生したバグ・エラーとその原因・対処(あれば最優先で含める)
    • 今後同種の作業をする際に役立つ教訓
  5. 要約を Markdown ファイルとして書き出す(1ファイル1セッション。ファイル名例: session_{session_id}.md)。
  6. 手順1で既存ドキュメントが見つかっていた場合(=更新による入れ替え)は、新しい要約を ingest する前に delete_document(doc_id, rebuild_index=False) で古い方を削除する (rebuild_index=False にして、直後の ingest 側の再構築1回にまとめる)。
  7. mcp__hybrid-rag-memory__ingest で取り込む。rebuild_index=False を必ず指定すること (理由は下記「インデックス再構築について」)。metadata には必ず以下を指定する:
    • knowledge_type: "experiment"
    • tags: 上記の命名規則どおり(session_id:... / session_last_activity:... を含む)
    • importance は指定しない(未設定のままにする。重要度判断はこのエージェントの役割ではなく、 後で人間または別エージェントが set_chunk_tags で付与する。手順6で削除した場合、旧チャンクに 付いていた importance は失われる点に注意し、もし呼び出し側から「旧チャンクに重要度が 付いていたら引き継いで」と指示があれば、削除前に hybrid_search 等で値を控えておくこと)

Read the full file on GitHub · 92 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 92 lines · 219 tokens per session scan A 658317327b55

Subscribe to this mod's changes

session-to-memory is an agent published in the GitHub repository masaki-kato-119/hybrid-rag-memory (0 stars, last pushed 19d ago), licensed MIT. It adds 219 tokens to every session and 2,251 once invoked, about $0.0011 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

context-finder

Read-only, memory- and index-aware codebase search. Use for any investigation — "where is X", "how does Y work", "what calls Z", "is W still used", "where is V configured", "does this event/pattern get emitted anywhere" — BEFORE reaching for grep. Consults the knowledge graph, code index, and prior session memory…

futuregerald/futuregerald-claude-plugin · 111 tokens

wiki-ingest

Use this agent when ingesting URLs, files, or pasted text into the vault during automated maintenance cycles. Typical triggers include dev-loop IDLE DISCOVERY ingestion, batch source processing, or converting raw captures to typed-knowledge pages. See "When to invoke" in the agent body for worked scenarios.

karlorz/llm-wiki · 64 tokens

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens