---
name: memory-consolidate
description: Strategy for daily memory consolidation, triple extraction, and authority assignment
title: Memory Consolidate
category: core
status: active
metadata:
  triggers:
  - daily memory
  - consolidate memory
  - end of day memory
  - generate memory
  - memory consolidation
  language:
    output_policy: source
    fallback_language: en
    min_detection_chars: 100
    min_confidence: 0.6
---
## Instructions

Run the daily memory consolidation cycle. This is the brain's end-of-day process — turning raw activity into structured knowledge.

### 1. Gather Sources

Collect all activity for the day:
- **User journal** (Thoughts, Decisions, Learnings, Reflections) — highest value
- **Conversations** — extract topics, outcomes, entities mentioned
- **Agent observations** — what you noticed during the day
- **Tasks completed/created** — decisions and progress
- **Email activity** — contacts, topics, commitments

### 2. Extract Knowledge Triples

From the gathered activity, extract structured subject-predicate-object facts. Prioritize:

1. **People relationships** — who works where, who knows whom, reporting lines
2. **Decisions made** — what was decided, by whom, with what reasoning
3. **User preferences** — what the user likes, dislikes, prefers, avoids
4. **Project status changes** — milestones hit, blockers found, deadlines moved
5. **New entities** — people, companies, projects, concepts encountered for the first time

**Name Purity (load-bearing).** Entity names are proper nouns, never sentences or descriptions. Never include a comma followed by a role or descriptor in the name. If a person has a title, emit `(person, has_role, "title")` as a separate triple. **Wrong:** subject=`"Erasmo Zuleta, gobernador de Córdoba"`. **Right:** subject=`"Erasmo Zuleta"`, plus `(erasmo-zuleta, has_role, "gobernador de Córdoba")`. Legitimate comma-bearing names like `"University of California, Berkeley"` stay as written — the test is whether both sides of the comma are proper nouns.

### 3. Assign Authority

Every triple gets an authority level that determines its weight in future recall:

- **explicit** (weight 3.0) — User directly stated this fact in their journal, notes, or conversation. Example: "I work at Acme Corp" written in USER.md.
- **system** (weight 2.0) — Agent observed or synthesized from user activity. Example: extracted from conversation that user met with Sarah Chen.
- **inferred** (weight 1.0) — Derived from co-occurrence or pattern. Example: Sarah and John both mentioned in same meeting context, so they likely know each other.

Authority only upgrades, never downgrades. When user approves a pending memory update, its triples upgrade to explicit.

### 4. Assign Decay Conditions

Every fact has a natural lifespan:

- **never** — Identity facts, core preferences, key relationships. "User's name is Wolf." "User prefers dark mode."
- **when:superseded** — Status facts that get replaced. "Project X status is active." Gets superseded when status changes.
- **after:90d** — Temporal facts. "Met Sarah on 2026-04-05." The meeting happened but fades in relevance.
- **when:unaccessed:60d** — Inferred connections that nobody queries. If nobody asks about it for 60 days, it decays.

### 5. Write Memory + Rebuild Graph

- Write daily memory file with [[wiki-links]] for all entities
- Write pending MEMORY.md updates for user approval
- Triples are automatically extracted and stored in the knowledge graph
- Graph edges are rebuilt with authority-weighted connections

## Rules

- Maximum 30 triples per daily consolidation — quality over quantity
- Never invent facts not present in the source material
- Use consistent predicate vocabulary: works_at, reports_to, knows, prefers, decided, is_a, has_goal, part_of, created, located_in, founded, manages, collaborates_with, interested_in
- Never downgrade authority — explicit stays explicit even if inferred evidence contradicts
- When two triples contradict, keep both but flag the conflict for user resolution
- User-authored content (journal, notes) always gets higher authority than agent observations

## System Prompt

You are the AgntSpace memory engine. Extract structured memory from today's activity.

You will receive a summary of everything that happened today. Your job:
1. Write a daily memory file with clear sections
2. Create [[wiki-links]] for every person, company, project, and key concept mentioned
3. Identify new facts that should go into permanent memory (MEMORY.md)
4. Extract structured knowledge triples (subject-predicate-object)

Rules for [[wiki-links]]:
- Every person name: [[Sarah Chen]], [[John K.]]
- Every company: [[Acme Corp]], [[AgntSpace]]
- Every project: [[B2B Pivot]], [[Q2 Board Deck]]
- Every key concept: [[investor update]], [[product launch]]
- Link generously — more connections = smarter graph

Output format:
```memory
(the daily memory file content with all sections and [[links]])
```

```permanent
(new facts/updates for MEMORY.md, or "no updates" if nothing new)
```

```triples
(JSON array of knowledge triples extracted from today's activity, or "none")
[
  {"subject": "entity name", "subject_type": "entity type", "predicate": "relationship", "object": "entity or value", "object_type": "entity type or literal", "confidence": 0.9, "knowledge_type": "declarative|episodic|procedural|normative|intentional"}
]
{vocab}
```

Note: The `{vocab}` placeholder is dynamically populated at runtime from the loaded ontology YAML (`memory/ontology.yaml`). It injects the current list of valid entity types, predicates with domain/range constraints, and knowledge type definitions. This ensures the extraction prompt always reflects the latest ontology without hardcoding vocabulary.