Implementation:42 evey Hermes plugins consolidate daily memory
| Knowledge Sources | |
|---|---|
| Domains | Memory_Consolidation, Fact_Extraction, Vector_Embedding |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete tool for nightly memory consolidation that retrieves conversation traces from Langfuse, extracts key facts via LLM, scores importance, updates MEMORY.md, and embeds facts to Qdrant.
Description
The consolidate_daily_memory handler orchestrates a four-stage pipeline:
- Trace Retrieval (_langfuse_query) — queries the Langfuse traces API for the last N hours (default 24), extracting up to 20 trace summaries in
"{name}: {input} -> {output}"format (150-char truncation). Returns["Memory consolidation unavailable"]on error. - Fact Extraction (_extract_facts) — feeds up to 15 trace summaries into the
EXTRACT_PROMPTviacall_llm, which asks the active model for 3-5 key facts in"- [category] fact"format (categories: learned, decided, discovered, created, fixed). Truncated to 3000 chars. - Importance Scoring and Memory Update (_score_fact, _update_memory) — each fact line is scored 1-10 by the LLM via
SCORE_PROMPT; only facts scoring ≥5 are kept. Scored facts are appended to~/.hermes/memories/MEMORY.mdunder a dated## Learned YYYY-MM-DDheader with[importance:N]annotations. When overCHAR_LIMIT = 4200chars, lowest-importance facts are trimmed first. - Vector Embedding (_embed_to_qdrant) — if both
QDRANT_URLandOLLAMA_URLare set, each fact is embedded via Ollama's/api/embeddingsendpoint (model:snowflake-arctic-embed2) and upserted as a Qdrant point (MD5-hashed ID) into theevey-knowledgecollection with payload metadata. Silently skips on error.
The call_llm helper uses ctx.llm.complete with purpose="evey-memory-consolidate" and strips thinking-model reasoning blocks.
Usage
Call this tool daily (typically at 3am cron) or on-demand to consolidate recent conversations into persistent memory. Registered as consolidate_daily_memory on the evey_memory toolset.
Code Reference
Source Location
- Repository: hermes-plugins
- File: evey-memory-consolidate/__init__.py
- Lines: L19-229 (_langfuse_query L95-117, _extract_facts L120-123, _score_fact L126-135, _update_memory L138-170, _embed_to_qdrant L173-201, handler L204-222, schema L76-92)
Signature
def handler(args: dict, **kwargs) -> str:
"""
Args:
args: {hours_back: number - hours of traces to look back (default 24)}
Returns:
JSON: {status: "consolidated"/"empty"/"error",
traces_analyzed, facts_extracted, memory_size}
"""
def _langfuse_query(hours_back: int = 24) -> list[str]:
"""Query Langfuse for trace summaries. Returns list of '{name}: {input} -> {output}' strings."""
def _extract_facts(trace_summaries: list[str]) -> str:
"""Extract 3-5 key facts from trace summaries via LLM. Returns newline-separated facts."""
def _score_fact(fact: str) -> int:
"""Score a fact's importance (1-10) using the active model. Default 5 if parse fails."""
def _update_memory(new_facts: str) -> int:
"""Append scored facts (≥5) to MEMORY.md. Returns updated file size in chars."""
def _embed_to_qdrant(facts: str) -> None:
"""Embed facts via Ollama and upsert to Qdrant. Silently skips if unconfigured."""
def call_llm(prompt: str, max_tokens: int = 200, temperature: float = 0.3) -> str | None:
"""One completion on the user's active model via ctx.llm."""
Import
from evey_memory_consolidate import handler
# Or accessed via Hermes tool call: consolidate_daily_memory
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| hours_back | number | No | Hours of traces to look back (default 24) |
| (env) | various | — | LANGFUSE_HOST, LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, QDRANT_URL (optional), OLLAMA_URL (optional) |
Outputs
| Name | Type | Description |
|---|---|---|
| status | str | "consolidated", "empty", or "error"
|
| traces_analyzed | int | Number of traces processed |
| facts_extracted | str | Raw extracted facts string |
| memory_size | int | Updated MEMORY.md size in characters |
Usage Examples
Daily Consolidation
result = tool_call("consolidate_daily_memory", {})
# {"status":"consolidated","traces_analyzed":15,
# "facts_extracted":"- [learned] qwen35-4b handles simple tasks well\n- [decided] use local model for research_quick\n- [discovered] Langfuse trace limit is 100",
# "memory_size":3200}
Custom Time Window
result = tool_call("consolidate_daily_memory", {"hours_back": 72})
# Consolidates 3 days of traces instead of 24h
Qdrant Embedding (with env config)
# When QDRANT_URL and OLLAMA_URL are set, facts are also embedded:
# - Each fact → Ollama /api/embeddings (snowflake-arctic-embed2)
# - Embedding → Qdrant /collections/evey-knowledge/points (PUT)
# - Payload: {source, type, category, content, date}
Related Pages
Implements Principle
- Principle:42_evey_Hermes_plugins_Trace_Retrieval
- Principle:42_evey_Hermes_plugins_Fact_Extraction
- Principle:42_evey_Hermes_plugins_Importance_Scoring
Requires Environment
- Environment:42_evey_Hermes_plugins_Hermes_Agent_Runtime
- Environment:42_evey_Hermes_plugins_Langfuse
- Environment:42_evey_Hermes_plugins_Qdrant
- Environment:42_evey_Hermes_plugins_Ollama