HistoryHandlerElement

This element is responsible for assembling and managing the chat history and context for downstream elements. It handles incoming messages and tool responses, optionally persists them to a SQLite database, and emits the current context for use by other elements in the flow. The token limits are set upon instantiation, and will determine the size of the context window as well as the amount of messages kept in the history from which that context history is assembled from.

Instantiation

Arguments:

show_tool_responses: bool = False
Whether to include tool response payload views in the context view. persist: bool = False
Whether to persist messages and tool responses to a SQLite database. db_path: str = None
Custom path for the history database file (optional when persist=True). Should be higher than the history_token_limit. history_token_limit: int = 32000
The max number of tokens to keep in the history. context_token_limit: int = 16000
The max number of tokens to include in the context window. tokenizer_model: str = 'gpt-4o'
The tokenizer model to use for token length estimation. (Using tiktoken)

Input Ports

Port Name Payload Type Behavior
message_emit_input MessagePayload Loads the message into history and emits the current context payload.
messages_input MessagePayload | list[MessagePayload] Loads one or more messages into history without emitting.
tool_response_emit_input ToolsResponsePayload Loads the tool response into history and emits the current context payload.
tools_responses_input ToolsResponsePayload | list[ToolsResponsePayload] Loads one or more tool responses into history without emitting.

Output Ports

Port Name Payload Type Behavior
message_history_output List[MessagePayload] Emits a list of MessagePayload representing the current context.

Views

(See here for styling options)

View Name Description Image
context_view Displays a column of message and optional tool response history entries.
Args:
title: str = 'Current History'
The header text shown above the history container.
column_css: list = []
CSS stylesheets for the main column layout.
container_css: list = []
CSS stylesheets for the scrollable context container.
title_css: list = []
CSS stylesheets for the title Markdown pane.
title_visible: bool = True
Whether the title header is visible.
ContextView