Skip to content

mnesis.models.config

config

Configuration models for Mnesis sessions and components.

CompactionConfig

Bases: BaseModel

Configuration for the compaction engine.

Everyday knobs::

CompactionConfig(
    auto=True,
    compaction_output_budget=20_000,
    compaction_model="anthropic/claude-haiku-4-5-20251001",
)

Advanced tuning

The following fields control internal compaction behaviour and should only be changed with a thorough understanding of the compaction loop:

  • soft_threshold_fraction — when to start early background compaction
  • max_compaction_rounds — cap on summarise+condense cycles
  • condensation_enabled — whether to merge accumulated summary nodes

auto class-attribute instance-attribute

auto: bool = True

Whether to automatically trigger compaction when overflow is detected.

prune class-attribute instance-attribute

prune: bool = True

Whether to run tool output pruning before compaction.

level2_enabled class-attribute instance-attribute

level2_enabled: bool = True

Whether to attempt Level 2 (aggressive) compaction before falling back to Level 3.

FileConfig

Bases: BaseModel

Configuration for large file handling.

StoreConfig

Bases: BaseModel

Configuration for the SQLite persistence layer.

wal_mode class-attribute instance-attribute

wal_mode: bool = True

Use WAL journal mode for better concurrent read performance.

connection_timeout class-attribute instance-attribute

connection_timeout: float = 30.0

Seconds to wait for the database connection before raising.

OperatorConfig

Bases: BaseModel

Configuration for LLMMap and AgenticMap operators.

SessionConfig

Bases: BaseModel

Configuration for session-level behaviour.

MnesisConfig

Bases: BaseModel

Top-level configuration for an Mnesis session.

All sub-configs have sensible defaults and can be overridden individually.

Example::

config = MnesisConfig(
    compaction=CompactionConfig(
        compaction_output_budget=30_000,
        compaction_model="anthropic/claude-haiku-4-5-20251001",
    ),
    file=FileConfig(inline_threshold=5_000),
)

To override model context/output limits without constructing ModelInfo directly, use model_overrides::

config = MnesisConfig(
    model_overrides={"context_limit": 128_000, "max_output_tokens": 16_384},
)

ModelInfo

Bases: BaseModel

Resolved model metadata used for budget calculations.

from_model_string classmethod

from_model_string(model: str) -> ModelInfo

Create a ModelInfo by heuristically parsing a model string.

Supports litellm-style strings like anthropic/claude-opus-4-6, gpt-4o, openai/gpt-4-turbo, etc.