Skip to content

API Reference parrot.advisors.state

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

parrot.advisors.state

View source

Class SelectionHistory

Memento Caretaker: Manages state history for undo/redo.

Stored alongside SelectionState in Redis.

Fields:

Field Type Default Description
snapshots List[Dict[str, Any]]
current_index int -1
max_history int 20

Method SelectionHistory.push

Add a new snapshot (discards any redo history).

push(snapshot: StateSnapshot) -> None

Parameter Type Default Description
snapshot StateSnapshot

Method SelectionHistory.can_undo

Check if undo is possible.

can_undo() -> bool

Returns: bool

Method SelectionHistory.can_redo

Check if redo is possible.

can_redo() -> bool

Returns: bool

Method SelectionHistory.undo

Go back one step, return the previous state.

undo() -> Optional[StateSnapshot]

Returns: Optional[StateSnapshot]

Method SelectionHistory.redo

Go forward one step, return the next state.

redo() -> Optional[StateSnapshot]

Returns: Optional[StateSnapshot]

Method SelectionHistory.get_history_summary

Get human-readable history for display.

get_history_summary() -> List[Dict[str, Any]]

Returns: List[Dict[str, Any]]

Class SelectionPhase

Phases of the product selection wizard.

Class SelectionState

Current state of product selection.

This is what gets stored in Redis and snapshotted for Memento.

Fields:

Field Type Default Description
session_id str
user_id str
catalog_id str 'default'
phase SelectionPhase SelectionPhase.IDLE
criteria Dict[str, Any]
all_product_ids List[str]
candidate_ids List[str]
eliminated Dict[str, str]
questions_asked List[str]
current_question Optional[str] None
pending_questions List[str]
started_at Optional[datetime] None
updated_at datetime
metadata Dict[str, Any]

Attributes:

Attribute Type Description
products_remaining int
products_eliminated int

Method SelectionState.should_recommend

Check if we should move to recommendation phase.

should_recommend() -> bool

Returns: bool

Class StateSnapshot

Memento: Immutable snapshot of SelectionState.

Used for undo/redo functionality.

Parameter Type Default Description
state SelectionState
timestamp datetime datetime.utcnow()
action str ''
question_answered Optional[str] None
answer_given Optional[str] None

Fields:

Field Type Default Description
state SelectionState
timestamp datetime field(default_factory=datetime.utcnow)
action str ''
question_answered Optional[str] None
answer_given Optional[str] None

Method StateSnapshot.from_state

Create snapshot from current state (deep copy).

from_state(state: SelectionState, action: str = '', question: str = None, answer: str = None) -> StateSnapshot

Parameter Type Default Description
state SelectionState
action str ''
question str None
answer str None

Returns: StateSnapshot

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