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
from griptape.structures import Agent agent = Agent() agent.run("My favorite animal is a Liger.") agent.run("What is my favorite animal?")
[02/27/25 20:28:09] INFO PromptTask acc8b8a0a736413791238b1d7c320d4d
Input: My favorite animal is a Liger.
[02/27/25 20:28:11] INFO PromptTask acc8b8a0a736413791238b1d7c320d4d
Output: That's interesting! Ligers are fascinating
creatures. They are a hybrid offspring of a male
lion and a female tiger. Ligers typically inherit
physical and behavioral traits from both parents,
often growing larger than either parent species.
They are known for their unique appearance and are
usually found in captivity, as lions and tigers do
not share the same habitats in the wild. What do
you find most interesting about ligers?
INFO PromptTask acc8b8a0a736413791238b1d7c320d4d
Input: What is my favorite animal?
[02/27/25 20:28:12] INFO PromptTask acc8b8a0a736413791238b1d7c320d4d
Output: Your favorite animal is a liger. 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.