Conversation Memory

Overview

You can use Conversation Memory to give Gen AI Builder Structures the ability to keep track of the conversation across runs. All structures are created with ConversationMemory by default.

Example

You can disable conversation memory in any structure by setting it to None:

from griptape.structures import Agent

Agent(conversation_memory=None)

Interaction With Structures

Per Structure

By default, Conversation Memory Runs are created for each run of the structure. Gen AI Builder takes the Structure's input_task's input and the output_task's output, storing them in the Run. Tasks that are neither the input task nor the output task are not stored in the Run.

In this example, the improve Task is "forgotten" after the Structure's run is finished. This approach allows you to perform intermediary work within a Structure without it being stored in, and potentially cluttering, Conversation Memory.

Per Task

You can change when Conversation Memory Runs are created by modifying Structure.conversation_memory_strategy from the default per_structure to per_task.

Now, each Task creates a Conversation Memory Run when it runs. This eliminates the need to feed the output of Tasks into each other using context variables like {{ parent_output }} since the output of the previous Task is stored in Conversation Memory and loaded when the next Task runs.

To blend the two approaches, you can disable Conversation Memory on individual tasks by setting PromptTask.conversation_memory to None.

Types of Memory

Gen AI Builder provides several types of Conversation Memory to fit various use-cases.

Conversation Memory

ConversationMemory will keep track of the full task input and output for all runs.

You can set the max_runs parameter to limit how many runs are kept in memory.

Summary Conversation Memory

SummaryConversationMemory will progressively summarize task input and output of runs.

You can choose to offset which runs are summarized with the offset parameter.


Could this page be better? Report a problem or suggest an addition!