You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pai-memory/README.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,20 @@
1
-
# Pydantic AI memory examples
1
+
# Pydantic AI Memory Examples
2
2
3
-
Run postgres in docker with
3
+
Two demos showing different approaches to implementing persistent memory for Pydantic AI agents:
4
+
5
+
## Message History Approach
6
+
### File `with_messages.py`
7
+
Stores complete conversation history as JSON in PostgreSQL. The agent receives all past messages as context automatically, making it remember previous interactions naturally.
8
+
9
+
## Tool-Based Memory Approach
10
+
### File `with_tools.py`
11
+
Provides the agent with `record_memory` and `retrieve_memories` tools. The agent actively decides what information to store and when to retrieve it from the database.
12
+
13
+
**Key difference:** Message history provides full context automatically, while tool-based memory gives the agent selective control over what to remember and recall.
0 commit comments