Skip to content

Allow configuring memory storage strategy per working memory session #55

@abrookins

Description

@abrookins

Currently, we always extract memories from message history in working memory in the same way, but the feature would be more powerful if users could configure its behavior per-session.

Configuration could look like this:

working_memory = await client.get_working_memory(
    session_id=session_id,
    namespace=self._get_namespace(user_id),
    model_name="gpt-4o-mini",
    long_term_memory_strategy=SummaryMemoryStrategy
)

The default strategy is DiscreteMemoryStrategy to match the current default behavior.

The possible strategies could be the following:

class SummaryMemoryStrategy:
    """Summarize all messages in a conversation/thread"""

class DiscreteMemoryStrategy:
    """Extract discrete semantic (factual) and episodic (time-oriented) facts from messages."""

class UserPreferencesMemoryStrategy:
    """Extract user preferences from messages."""

class CustomPreferencesMemoryStrategy:
    """Give the memory server a custom extraction prompt"""

Each class allows configuring options for the memory strategy.

When we look at working memory to extract long-term memory, we then consider the chosen strategy and base extraction behavior on the strategy, instead of always extracting discrete facts (as we currently do).

This is fine for background extraction, but consider how this informs the design of our client's memory tools. In particular, the tool create_long_term_memory does not currently know about or consider working memory. Design backwards-compatible changes that support enforcing/guiding the type of extraction the local LLM will do. The description of the tool will need to carry the information describing how the LLM should extract memory, so it probably makes sense for there to be a new way to derive a long-term memory tool from the working memory session, maybe working_memory.create_long_term_memory_tool()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions