transforms
autogen.agentchat.contrib.capabilities.transforms.MessageHistoryLimiter
MessageHistoryLimiter
Limits the number of messages considered by an agent for response generation.
This transform keeps only the most recent messages up to the specified maximum number of messages (max_messages).
It trims the conversation history by removing older messages, retaining only the most recent messages.
Name | Description |
---|---|
max_messages | Type: int | None Default: None |
keep_first_message | Type: bool Default: False |
Instance Methods
apply_transform
Truncates the conversation history to the specified maximum number of messages.
This method returns a new list containing the most recent messages up to the specified
maximum number of messages (max_messages). If max_messages is None, it returns the
original list of messages unmodified.
Name | Description |
---|---|
messages | The list of messages representing the conversation history. Type: list[dict[str, typing.Any]] |
Type | Description |
---|---|
list[dict[str, typing.Any]] | List[Dict]: A new list containing the most recent messages up to the specified maximum. |
get_logs
Name | Description |
---|---|
pre_transform_messages | Type: list[dict[str, typing.Any]] |
post_transform_messages | Type: list[dict[str, typing.Any]] |