jeevesagent.memory.consolidator

LLM-driven fact extraction from episodes.

Given a list of episodes and a FactStore, the consolidator asks a Model to emit a JSON array of {subject, predicate, object, confidence} objects per episode, parses the response, and appends each extracted Fact to the store. The store is then responsible for any supersession / temporal-window bookkeeping.

The default prompt is a no-frills extractor; users with strong opinions about ontology / taxonomy can pass a custom system_prompt= at construction.

Attributes

Classes

Consolidator

Wraps a Model to extract Fact rows from episodes.

Module Contents

class jeevesagent.memory.consolidator.Consolidator(*, model: jeevesagent.core.protocols.Model, system_prompt: str = DEFAULT_SYSTEM_PROMPT, max_facts_per_episode: int = 20)[source]

Wraps a Model to extract Fact rows from episodes.

async consolidate(episodes: collections.abc.Iterable[jeevesagent.core.types.Episode], *, store: jeevesagent.memory.facts.FactStore) list[jeevesagent.core.types.Fact][source]

Process episodes; append extracted facts to store; return the new Fact instances in extraction order.

Uses store.append_many when available so the underlying store can batch the embedder calls (one embed_batch API round-trip instead of N individual embed calls). Falls back to per-fact append for stores that haven’t implemented append_many.

jeevesagent.memory.consolidator.DEFAULT_SYSTEM_PROMPT = Multiline-String
Show Value
"""You extract semantic facts from conversation episodes.

A fact is a stable claim about an entity, expressed as a triple of
(subject, predicate, object). Only extract claims that are likely to
remain true beyond this episode. Skip greetings, transient state,
small talk, and acknowledgements.

You will be shown a single episode. Return a JSON array of facts.
Each fact must have exactly these fields:

* "subject": the entity (e.g. "user", "Alice", "Project Atlas")
* "predicate": the relation (e.g. "name_is", "lives_in", "prefers")
* "object": the value (e.g. "Alice", "Tokyo", "dark mode")
* "confidence": a float between 0.0 and 1.0

Example output:
[{"subject": "user", "predicate": "name_is", "object": "Alice", "confidence": 0.95}]

Return ONLY the JSON array. No prose, no markdown, no code fences.
If there's nothing worth extracting, return an empty array: [].
"""