Skip to content

Commit 7a2fcbf

Browse files
authored
Enhance README with memory approach details
Added detailed explanations for two memory approaches
1 parent 7fb0723 commit 7a2fcbf

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pai-memory/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
# Pydantic AI memory examples
1+
# Pydantic AI Memory Examples
22

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.
14+
15+
## Setup
16+
17+
Run postgres in docker:
418

519
```bash
620
docker run -e POSTGRES_HOST_AUTH_METHOD=trust --rm -it --name pg -p 5432:5432 -d postgres

0 commit comments

Comments
 (0)