Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:42 evey Hermes plugins consolidate daily memory

From Leeroopedia
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:

  1. 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.
  2. Fact Extraction (_extract_facts) — feeds up to 15 trace summaries into the EXTRACT_PROMPT via call_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.
  3. 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.md under a dated ## Learned YYYY-MM-DD header with [importance:N] annotations. When over CHAR_LIMIT = 4200 chars, lowest-importance facts are trimmed first.
  4. Vector Embedding (_embed_to_qdrant) — if both QDRANT_URL and OLLAMA_URL are set, each fact is embedded via Ollama's /api/embeddings endpoint (model: snowflake-arctic-embed2) and upserted as a Qdrant point (MD5-hashed ID) into the evey-knowledge collection 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

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment