Skip to content

API Reference parrot.core.events.lifecycle.events.memory

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

parrot.core.events.lifecycle.events.memory

View source

Conversation-memory lifecycle events.

FEAT-525 — Per-Turn Conversation Compaction.

Covers: the deterministic (Stage 0/0.5/1) retention pipeline signaling that it can no longer fit a session's history within its budget.

FEAT-886 adds :class:TurnCompletedEvent, the raw saved-turn payload that is published to the turn bus only (never to EventRegistry).

Class Stage2CompactionNeededEvent

Emitted once per session when deterministic pruning can no longer fit the history.

Emitted from AbstractBot.save_conversation_turn on the first False → True flip of the persisted stage2_needed flag (spec §2 "Component Diagram", read path). Stage 2 (LLM summary turns) is out of scope for this feature; this event is the reserved trigger surface a future summarization stage would subscribe to.

Parameter Type Default Description
agent_name str ''
session_id str ''
history_estimate int 0
available int 0
dropped_turns int 0

Fields:

Field Type Default Description
agent_name str '' Name of the agent whose history overflowed.
session_id str '' The session that needs Stage 2 summarization.
history_estimate int 0 The compacted history's total estimated token size for this round.
available int 0 The bot's context budget's available token count at the time of the flip.
dropped_turns int 0 Number of turns dropped (beyond pruning) in the round that triggered this event.

Class TurnCompletedEvent

One saved conversation turn, raw and pre-normalization (FEAT-886).

Published to the turn bus only; never passed to EventRegistry.emit() — the payload contains conversation content and must not reach the observability fan-out.

Parameter Type Default Description
agent_name str ''
chatbot_id str ''
user_id str ''
session_id str ''
turn Dict[str, Any] dict()
presentation Dict[str, Any] dict()

Fields:

Field Type Default Description
agent_name str '' The agent NAME — the ChatStorage key.
chatbot_id str '' The bot's memory_key_id (explicit chatbot_id or the name).
user_id str '' Owner of the conversation.
session_id str '' Conversation session.
turn Dict[str, Any] field(default_factory=dict) ConversationTurn.to_dict() taken BEFORE add_turn normalization.
presentation Dict[str, Any] field(default_factory=dict) TurnPresentation.model_dump() (output, usage, tenant, ...).

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