jeevesagent.memory.consolidator
===============================

.. py:module:: jeevesagent.memory.consolidator

.. autoapi-nested-parse::

   LLM-driven fact extraction from episodes.

   Given a list of episodes and a :class:`FactStore`, the consolidator
   asks a :class:`Model` to emit a JSON array of ``{subject, predicate,
   object, confidence}`` objects per episode, parses the response, and
   appends each extracted :class:`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
----------

.. autoapisummary::

   jeevesagent.memory.consolidator.DEFAULT_SYSTEM_PROMPT


Classes
-------

.. autoapisummary::

   jeevesagent.memory.consolidator.Consolidator


Module Contents
---------------

.. py:class:: Consolidator(*, model: jeevesagent.core.protocols.Model, system_prompt: str = DEFAULT_SYSTEM_PROMPT, max_facts_per_episode: int = 20)

   Wraps a :class:`Model` to extract :class:`Fact` rows from episodes.


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


      Process ``episodes``; append extracted facts to ``store``;
      return the new :class:`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``.



.. py:data:: DEFAULT_SYSTEM_PROMPT
   :value: Multiline-String

   .. raw:: html

      <details><summary>Show Value</summary>

   .. code-block:: python

      """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: [].
      """

   .. raw:: html

      </details>



