Commit 5c69b8f
feat(memory): add DatabaseMemoryService with SQL backend and scratchpad
Adds a durable, RDBMS-backed memory service that works with any
SQLAlchemy-supported database (SQLite, PostgreSQL, MySQL, MariaDB)
as an alternative to the volatile InMemoryMemoryService.
Key additions:
- DatabaseMemoryService: implements BaseMemoryService with lazy table
creation, idempotent session ingest, and delta event ingestion
- MemorySearchBackend ABC + KeywordSearchBackend: LIKE/ILIKE search
with AND-first → OR-fallback tokenization strategy
- Scratchpad KV store and append-only log for intermediate agent state
- Four agent-callable BaseTool subclasses: scratchpad_get_tool,
scratchpad_set_tool, scratchpad_append_log_tool, scratchpad_get_log_tool
- 38 unit tests covering all methods, tool happy-paths, wrong-service
errors, multi-user isolation, and session scoping
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 6edcb97 commit 5c69b8f
8 files changed
Lines changed: 1855 additions & 0 deletions
File tree
- src/google/adk
- memory
- schemas
- tools
- tests/unittests/memory
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
0 commit comments