Skip to content

API Reference parrot.memory.file

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

parrot.memory.file

View source

Alias ConversationHistory

Re-exported from parrot.memory.abstract.ConversationHistory.

Alias ConversationMemory

Re-exported from parrot.memory.abstract.ConversationMemory.

Alias ConversationTurn

Re-exported from parrot.memory.abstract.ConversationTurn.

Class FileConversationMemory

File-based implementation of conversation memory.

Parameter Type Default Description
base_path str './conversations' Root directory for conversation history files.
token_counter Optional[TokenCounter] None Stage 0.5 counter override (see :class:~parrot.memory.abstract.ConversationMemory).
omission_store Optional[OmissionStore] None Omission-store override; defaults to a :class:FileOmissionStore sharing base_path.
normalize bool True Disables Stage 0 for this instance when False.

Method FileConversationMemory.create_history

Create a new conversation history.

create_history(user_id: str, session_id: str, metadata: Optional[Dict[str, Any]] = None, chatbot_id: Optional[str] = None) -> ConversationHistory

Parameter Type Default Description
user_id str
session_id str
metadata Optional[Dict[str, Any]] None
chatbot_id Optional[str] None

Returns: ConversationHistory

Method FileConversationMemory.get_history

Get a conversation history, re-keying a legacy record if needed.

FEAT-524 unified the storage path to {user}/{chatbot}/{session}.json. Histories written before that live at {user}/{session}.json. When chatbot_id is given and the segmented path holds nothing, the legacy path is read once, copied to the segmented path and returned. The legacy file is deliberately left in place so a rollback still finds it.

get_history(user_id: str, session_id: str, chatbot_id: Optional[str] = None) -> Optional[ConversationHistory]

Parameter Type Default Description
user_id str Owner of the conversation.
session_id str Conversation session.
chatbot_id Optional[str] None Agent path segment. Falsy means "read the legacy path directly" — no re-key is attempted.

Returns: Optional[ConversationHistory] — The history, or None when neither path holds one.

Method FileConversationMemory.update_history

Update a conversation history.

update_history(history: ConversationHistory) -> None

Parameter Type Default Description
history ConversationHistory

Method FileConversationMemory.clear_history

Clear a conversation history.

clear_history(user_id: str, session_id: str, chatbot_id: Optional[str] = None) -> None

Parameter Type Default Description
user_id str
session_id str
chatbot_id Optional[str] None

Method FileConversationMemory.list_sessions

List all session IDs for a user.

list_sessions(user_id: str, chatbot_id: Optional[str] = None) -> List[str]

Parameter Type Default Description
user_id str
chatbot_id Optional[str] None

Returns: List[str]

Method FileConversationMemory.delete_history

Delete a conversation history entirely.

delete_history(user_id: str, session_id: str, chatbot_id: Optional[str] = None) -> bool

Parameter Type Default Description
user_id str
session_id str
chatbot_id Optional[str] None

Returns: bool

Alias FileOmissionStore

Re-exported from parrot.memory.compaction.omission.FileOmissionStore.

Alias OmissionStore

Re-exported from parrot.memory.compaction.omission.OmissionStore.

Alias TokenCounter

Re-exported from parrot.memory.compaction.tokens.TokenCounter.

Alias is_hydration_pending

Re-exported from parrot.memory.abstract.is_hydration_pending.

Alias merge_pending_history

Re-exported from parrot.memory.abstract.merge_pending_history.

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