haive.core.schema.prebuilt.messages.compatibility¶
Compatibility layer for MessagesState implementations.
This module provides adapter classes and utilities that enable backward compatibility while adding new features from the enhanced MessagesState implementation. It serves as a bridge between the old and new architectures.
Classes¶
Adapter that enables old MessagesState instances to use new features. |
Module Contents¶
- class haive.core.schema.prebuilt.messages.compatibility.MessagesStateAdapter(messages_state)[source]¶
Adapter that enables old MessagesState instances to use new features. with minimal changes to their API.
This adapter wraps an existing MessagesState instance and provides methods that implement the enhanced functionality from the new MessagesState architecture.
Initialize the adapter with an existing MessagesState instance.
- Parameters:
messages_state – The MessagesState instance to adapt
- deduplicate_tool_calls()[source]¶
Remove duplicate tool calls based on tool call ID.
This is useful when the same API call might be made multiple times due to agent or LLM quirks.
- Returns:
Number of duplicates removed
- Return type:
- get_completed_tool_calls()[source]¶
Get all completed tool calls with their responses.
This method matches tool calls in AI messages with their corresponding tool responses.
- Returns:
List of ToolCallInfo objects with tool call details
- Return type:
list[haive.core.schema.prebuilt.messages.utils.ToolCallInfo]
- get_conversation_rounds()[source]¶
Get detailed information about each conversation round.
A conversation round typically consists of a human message, followed by one or more AI responses and possibly tool calls/responses.
- Returns:
List of MessageRound objects with round details
- Return type:
list[haive.core.schema.prebuilt.messages.utils.MessageRound]
- send_tool_calls(node_name='tools')[source]¶
Convert tool calls from the last AI message into Send objects for LangGraph routing.
- Parameters:
node_name (str) – The name of the node to send tool calls to
- Returns:
Either a string (if no tool calls) or a list of Send objects
- Return type: