openhands.memory.history
ShortTermHistory Objects
class ShortTermHistory(list[Event])
A list of events that represents the short-term memory of the agent.
This class provides methods to retrieve and filter the events in the history of the running agent from the event stream.
get_events_as_list
def get_events_as_list(include_delegates: bool = False) -> list[Event]
Return the history as a list of Event objects.
get_events
def get_events(reverse: bool = False,
include_delegates: bool = False) -> Iterable[Event]
Return the events as a stream of Event objects.
get_last_action
def get_last_action(end_id: int = -1) -> Action | None
Return the last action from the event stream, filtered to exclude unwanted events.
get_last_observation
def get_last_observation(end_id: int = -1) -> Observation | None
Return the last observation from the event stream, filtered to exclude unwanted events.
get_last_user_message
def get_last_user_message() -> str
Return the content of the last user message from the event stream.
get_last_agent_message
def get_last_agent_message() -> str
Return the content of the last agent message from the event stream.
get_last_events
def get_last_events(n: int) -> list[Event]
Return the last n events from the event stream.
get_pairs
def get_pairs() -> list[tuple[Action, Observation]]
Return the history as a list of tuples (action, observation).