Reflection
When an agent has only raw observational memories, it becomes difficult to generalize or draw meaningful inferences. To address this, we introduce a second type of memory: Reflections. These are higher-level, abstract thoughts generated by the agent itself. Since reflections are treated as memory objects, they are included during retrieval alongside basic observations.
Reflections are generated periodically. In our implementation, they are triggered when the cumulative importance score of the most recent events exceeds a defined threshold.
🔄 The Reflection Process:
Trigger Threshold Reached: When the sum of importance scores from recent events exceeds the threshold, the reflection process is initiated.
Generate Abstract Questions: The language model reviews the latest 100 memory entries and synthesizes three high-level questions that capture core patterns or concerns.
Query for Related Memories: Each question is then used as a query to retrieve relevant memory objects from the memory stream (including past reflections).
Extract Insights: For each question, the LLM generates five high-level insights, which represent the reflections.
Store as Reflections: These insights are saved back into the memory stream as new memory objects. They are also linked to the original observations used to generate them, forming a Reflection Tree, where:
Leaf nodes = raw observations
Non-leaf nodes = abstracted thoughts and reflections
Last updated