Skip to content

API Reference parrot.memory.compaction.omission

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.memory.compaction.omission

View source

Omission store for per-turn conversation compaction (FEAT-525).

Everything pruned or offloaded from a turn (oversized tool outputs, at write time or at render time) lands here, content-addressed and indexed by turn_id so it can be recovered byte for byte by read_omitted_content (TASK-2829). Owned by the ConversationMemory backend (wired in TASK-2826); this module only defines the store.

Attribute EXPIRED_MESSAGE

Type: str

Class FileOmissionStore

File-backed :class:OmissionStore.

Layout: {base_path}/_omitted/{safe(session_key)}/{content_id}.txt plus an index.json mapping turn_id -> [content_id, ...].

Parameter Type Default Description
base_path Root directory (shared with FileConversationMemory).
ttl Optional[int] None Ignored — the file backend has no expiry mechanism.

Method FileOmissionStore.put

put(session_key: str, content: str, *, turn_id: Optional[str] = None) -> str

Parameter Type Default Description
session_key str
content str
turn_id Optional[str] None

Returns: str

Method FileOmissionStore.get

get(session_key: str, content_id: str) -> Optional[str]

Parameter Type Default Description
session_key str
content_id str

Returns: Optional[str]

Method FileOmissionStore.probe

Answer from the file's existence; the contents are never opened.

probe(session_key: str, content_id: str) -> Optional[bool]

Parameter Type Default Description
session_key str
content_id str

Returns: Optional[bool]

Method FileOmissionStore.list_by_turn

list_by_turn(session_key: str, turn_id: str) -> List[str]

Parameter Type Default Description
session_key str
turn_id str

Returns: List[str]

Method FileOmissionStore.clear

clear(session_key: str) -> None

Parameter Type Default Description
session_key str

Class InMemoryOmissionStore

Process-local, dict-backed :class:OmissionStore.

Parameter Type Default Description
ttl Optional[int] None

Method InMemoryOmissionStore.put

put(session_key: str, content: str, *, turn_id: Optional[str] = None) -> str

Parameter Type Default Description
session_key str
content str
turn_id Optional[str] None

Returns: str

Method InMemoryOmissionStore.get

get(session_key: str, content_id: str) -> Optional[str]

Parameter Type Default Description
session_key str
content_id str

Returns: Optional[str]

Method InMemoryOmissionStore.probe

Answer from key membership alone; never touches the value.

probe(session_key: str, content_id: str) -> Optional[bool]

Parameter Type Default Description
session_key str
content_id str

Returns: Optional[bool]

Method InMemoryOmissionStore.list_by_turn

list_by_turn(session_key: str, turn_id: str) -> List[str]

Parameter Type Default Description
session_key str
turn_id str

Returns: List[str]

Method InMemoryOmissionStore.clear

clear(session_key: str) -> None

Parameter Type Default Description
session_key str

Alias Omission

Re-exported from parrot.memory.compaction.models.Omission.

Class OmissionStore

Content-addressed store for content pruned or offloaded from turns.

Parameter Type Default Description
ttl Optional[int] None Expiry in seconds for stored content. None (default) means no expiry, matching the history's own lack of a TTL.

Method OmissionStore.put

Store content under session_key, indexed by turn_id.

Idempotent: storing the same content twice returns the same id and does not create a duplicate index entry.

put(session_key: str, content: str, *, turn_id: Optional[str] = None) -> str

Parameter Type Default Description
session_key str Opaque scoping key (composed by the memory).
content str The full text to store.
turn_id Optional[str] None When given, indexes the resulting id under this turn.

Returns: str — The content id.

Method OmissionStore.put_many

Store every :class:Omission under its own turn_id (default: loop over :meth:put).

put_many(session_key: str, omissions: Sequence[Omission]) -> None

Parameter Type Default Description
session_key str Opaque scoping key (composed by the memory).
omissions Sequence[Omission] The omissions to flush.

Method OmissionStore.get

Return the stored content for content_id, or None if unknown.

get(session_key: str, content_id: str) -> Optional[str]

Parameter Type Default Description
session_key str Opaque scoping key (composed by the memory).
content_id str The id returned by a previous :meth:put.

Returns: Optional[str] — The stored content, or None when the id is unknown or belongs to a different session.

Method OmissionStore.probe

Report whether content_id is still stored, WITHOUT loading it.

Added by FEAT-538. :meth:get fetches the payload text, so using it to answer "does this still exist?" would drag potentially large omitted content across the wire purely to compute a boolean — and recall does exactly that check, for every omission reference it reports.

Deliberately not abstract: a store written before this method existed keeps working and inherits this default, which answers None (unknown). Unknown is never reported as available — claiming content is present when the store cannot say so would let recall promise recoverable text that may be long gone.

probe(session_key: str, content_id: str) -> Optional[bool]

Parameter Type Default Description
session_key str Opaque scoping key (composed by the memory).
content_id str The id to probe.

Returns: Optional[bool] — True when the content is stored, False when it is known to be absent or expired, and None when this backend cannot answer cheaply.

Method OmissionStore.probe_many

Probe several ids at once (default: loop over :meth:probe).

Backends with a batching primitive should override this; the default keeps the contract satisfiable by any store.

probe_many(session_key: str, content_ids: Sequence[str]) -> Dict[str, Optional[bool]]

Parameter Type Default Description
session_key str Opaque scoping key (composed by the memory).
content_ids Sequence[str] The ids to probe.

Returns: Dict[str, Optional[bool]] — A mapping of id to availability, using :meth:probe's three-valued answer.

Method OmissionStore.list_by_turn

Return the content ids stored for turn_id, in insertion order.

list_by_turn(session_key: str, turn_id: str) -> List[str]

Parameter Type Default Description
session_key str Opaque scoping key (composed by the memory).
turn_id str The turn to look up.

Returns: List[str] — A list of content ids (empty when the turn has none).

Method OmissionStore.clear

Delete every stored content and index entry for session_key.

clear(session_key: str) -> None

Parameter Type Default Description
session_key str Opaque scoping key (composed by the memory).

Class RedisOmissionStore

Redis-backed :class:OmissionStore, sharing an existing async client.

Parameter Type Default Description
redis_client An already-constructed async Redis client (the same one RedisConversation owns — never opens a second connection).
key_prefix str 'conversation' Prefix for the two hashes this store owns.
ttl Optional[int] None Expiry in seconds. None (default) means no expiry.

Method RedisOmissionStore.put

put(session_key: str, content: str, *, turn_id: Optional[str] = None) -> str

Parameter Type Default Description
session_key str
content str
turn_id Optional[str] None

Returns: str

Method RedisOmissionStore.get

get(session_key: str, content_id: str) -> Optional[str]

Parameter Type Default Description
session_key str
content_id str

Returns: Optional[str]

Method RedisOmissionStore.probe

Answer with HEXISTS, which transfers no value.

HGET would pull the whole omitted payload back just to decide a boolean — and omitted payloads are, by construction, the large ones. A key expired by the store's TTL reports False, which is the honest answer: the content is gone.

probe(session_key: str, content_id: str) -> Optional[bool]

Parameter Type Default Description
session_key str
content_id str

Returns: Optional[bool]

Method RedisOmissionStore.probe_many

Batch the probes into one pipeline round trip when possible.

Falls back to the base implementation for clients without pipeline (lightweight doubles, restricted Redis-compatible servers) rather than failing on them.

probe_many(session_key: str, content_ids: Sequence[str]) -> Dict[str, Optional[bool]]

Parameter Type Default Description
session_key str
content_ids Sequence[str]

Returns: Dict[str, Optional[bool]]

Method RedisOmissionStore.list_by_turn

list_by_turn(session_key: str, turn_id: str) -> List[str]

Parameter Type Default Description
session_key str
turn_id str

Returns: List[str]

Method RedisOmissionStore.clear

clear(session_key: str) -> None

Parameter Type Default Description
session_key str

Function content_id

Compute the content-addressed id for a piece of omitted content.

content_id(content: str) -> str

Parameter Type Default Description
content str The full text being offloaded.

Returns: str — "om_" followed by the 16-hex-character blake2b-8 digest of content. Identical content always yields the same id.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally