Skip to content

MemoryStrategyConfiguration

Source code in docs_src/capo_opensearchmemory/types/memory_strategy_configuration.py
class MemoryStrategyConfiguration(TypedDict, closed=True):
    extraction_prompt: NotRequired[
        "capo_opensearchmemory.types.extraction_prompt.ExtractionPrompt"
    ]
    """<p>Instructions that define what a <code>CUSTOM</code> strategy extracts, up to 30,720 characters. Required for a <code>CUSTOM</code> strategy: <code>CreateSpace</code> and <code>UpdateSpace</code> fail with <code>ValidationException</code> if a <code>CUSTOM</code> strategy has none.</p> <p>Only <code>CUSTOM</code> strategies use it. <code>SEMANTIC</code> and <code>SUMMARY</code> strategies always extract with the service's built-in instructions: the service accepts and stores a prompt on them, and <code>GetSpace</code> returns it, but extraction doesn't use it.</p>"""
    extract_every_n_messages: NotRequired[
        "capo_opensearchmemory.types.trigger_every_n_messages.TriggerEveryNMessages"
    ]
    """<p>Extract once this many messages have accumulated, from 1 to 1000. Lower values extract more often, in smaller batches. The default is 12.</p> <p>Messages accumulate until the first of <code>extractEveryNMessages</code>, <code>extractEveryNTokens</code>, and <code>idleTimeoutSeconds</code> is reached. The service then extracts them together in one pass.</p>"""
    extract_every_n_tokens: NotRequired[
        "capo_opensearchmemory.types.token_count.TokenCount"
    ]
    """<p>Extract once this many tokens of conversation have accumulated, from 1 to 80,000, however few messages that takes. Use it to bound how much text one extraction call carries when message sizes vary widely. Omit it to bound a batch only by <code>extractEveryNMessages</code>, <code>idleTimeoutSeconds</code>, and the service's maximum batch size.</p>"""
    idle_timeout_seconds: NotRequired[
        "capo_opensearchmemory.types.idle_timeout_seconds.IdleTimeoutSeconds"
    ]
    """<p>Extract what has accumulated once the conversation has been idle for this many seconds, from 1 to 86,400. The default is 60. This is what extracts the end of a conversation that stops. Raise it when the pauses in your conversations are longer than that, so that one exchange isn't split across several extraction passes.</p>"""
    extraction_seed_top_k: NotRequired[
        "capo_opensearchmemory.types.seed_memory_count.SeedMemoryCount"
    ]
    """<p>How many of the strategy's stored memories that are most relevant to the conversation to include in the extraction prompt, from 0 to 20, to improve extraction and reduce duplicates. If you omit this or set it to 0, the service uses its default (see <code>extractionSeedRecentN</code>). When this and <code>extractionSeedRecentN</code> are both set, the two sets of memories are combined without duplicates.</p>"""
    extraction_seed_recent_n: NotRequired[
        "capo_opensearchmemory.types.seed_memory_count.SeedMemoryCount"
    ]
    """<p>How many of the strategy's most recent stored memories to include in the extraction prompt, from 0 to 20. If you omit this or set it to 0, the service uses its default: no seeding for most strategy types, and the 10 most recent memories for a <code>SUMMARY</code> strategy when neither seed setting is given. When this and <code>extractionSeedTopK</code> are both set, the two sets of memories are combined without duplicates.</p>"""
    consolidation_enabled: NotRequired["bool"]
    """<p>Specifies whether the strategy consolidates memories. With consolidation, each new memory is compared with similar stored memories, and the service adds it, updates a stored memory, or skips it, so duplicate or contradicting facts don't accumulate. Without it, every extracted memory is stored as a new memory, which costs less and keeps a full history.</p> <p>When omitted, the default depends on the strategy's type: on for <code>SEMANTIC</code> and <code>SUMMARY</code>, off for <code>CUSTOM</code>.</p>"""

consolidation_enabled instance-attribute

consolidation_enabled: NotRequired[bool]

Specifies whether the strategy consolidates memories. With consolidation, each new memory is compared with similar stored memories, and the service adds it, updates a stored memory, or skips it, so duplicate or contradicting facts don't accumulate. Without it, every extracted memory is stored as a new memory, which costs less and keeps a full history.

When omitted, the default depends on the strategy's type: on for SEMANTIC and SUMMARY, off for CUSTOM.

extract_every_n_messages instance-attribute

extract_every_n_messages: NotRequired[TriggerEveryNMessages]

Extract once this many messages have accumulated, from 1 to 1000. Lower values extract more often, in smaller batches. The default is 12.

Messages accumulate until the first of extractEveryNMessages, extractEveryNTokens, and idleTimeoutSeconds is reached. The service then extracts them together in one pass.

extract_every_n_tokens instance-attribute

extract_every_n_tokens: NotRequired[TokenCount]

Extract once this many tokens of conversation have accumulated, from 1 to 80,000, however few messages that takes. Use it to bound how much text one extraction call carries when message sizes vary widely. Omit it to bound a batch only by extractEveryNMessages, idleTimeoutSeconds, and the service's maximum batch size.

extraction_prompt instance-attribute

extraction_prompt: NotRequired[ExtractionPrompt]

Instructions that define what a CUSTOM strategy extracts, up to 30,720 characters. Required for a CUSTOM strategy: CreateSpace and UpdateSpace fail with ValidationException if a CUSTOM strategy has none.

Only CUSTOM strategies use it. SEMANTIC and SUMMARY strategies always extract with the service's built-in instructions: the service accepts and stores a prompt on them, and GetSpace returns it, but extraction doesn't use it.

extraction_seed_recent_n instance-attribute

extraction_seed_recent_n: NotRequired[SeedMemoryCount]

How many of the strategy's most recent stored memories to include in the extraction prompt, from 0 to 20. If you omit this or set it to 0, the service uses its default: no seeding for most strategy types, and the 10 most recent memories for a SUMMARY strategy when neither seed setting is given. When this and extractionSeedTopK are both set, the two sets of memories are combined without duplicates.

extraction_seed_top_k instance-attribute

extraction_seed_top_k: NotRequired[SeedMemoryCount]

How many of the strategy's stored memories that are most relevant to the conversation to include in the extraction prompt, from 0 to 20, to improve extraction and reduce duplicates. If you omit this or set it to 0, the service uses its default (see extractionSeedRecentN). When this and extractionSeedRecentN are both set, the two sets of memories are combined without duplicates.

idle_timeout_seconds instance-attribute

idle_timeout_seconds: NotRequired[IdleTimeoutSeconds]

Extract what has accumulated once the conversation has been idle for this many seconds, from 1 to 86,400. The default is 60. This is what extracts the end of a conversation that stops. Raise it when the pauses in your conversations are longer than that, so that one exchange isn't split across several extraction passes.