agent-cerebro 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_cerebro-0.1.0/.gitignore +15 -0
- agent_cerebro-0.1.0/CHANGELOG.md +19 -0
- agent_cerebro-0.1.0/LICENSE +21 -0
- agent_cerebro-0.1.0/PKG-INFO +169 -0
- agent_cerebro-0.1.0/README.md +138 -0
- agent_cerebro-0.1.0/pyproject.toml +48 -0
- agent_cerebro-0.1.0/skill/agent-recall/SKILL.md +69 -0
- agent_cerebro-0.1.0/skill/agent-recall/references/best-practices.md +33 -0
- agent_cerebro-0.1.0/skill/agent-recall/references/categories-guide.md +33 -0
- agent_cerebro-0.1.0/skill/agent-recall/references/memory-directive.md +72 -0
- agent_cerebro-0.1.0/skill/agent-recall/scripts/check.py +21 -0
- agent_cerebro-0.1.0/skill/agent-recall/scripts/search.py +36 -0
- agent_cerebro-0.1.0/skill/agent-recall/scripts/setup.py +21 -0
- agent_cerebro-0.1.0/skill/agent-recall/scripts/store.py +38 -0
- agent_cerebro-0.1.0/src/agentrecall/__init__.py +20 -0
- agent_cerebro-0.1.0/src/agentrecall/__main__.py +4 -0
- agent_cerebro-0.1.0/src/agentrecall/cli.py +291 -0
- agent_cerebro-0.1.0/src/agentrecall/core/__init__.py +1 -0
- agent_cerebro-0.1.0/src/agentrecall/core/embeddings.py +98 -0
- agent_cerebro-0.1.0/src/agentrecall/core/result.py +39 -0
- agent_cerebro-0.1.0/src/agentrecall/core/schema.py +71 -0
- agent_cerebro-0.1.0/src/agentrecall/core/search.py +137 -0
- agent_cerebro-0.1.0/src/agentrecall/core/store.py +124 -0
- agent_cerebro-0.1.0/src/agentrecall/longterm/__init__.py +1 -0
- agent_cerebro-0.1.0/src/agentrecall/longterm/migrate.py +177 -0
- agent_cerebro-0.1.0/src/agentrecall/longterm/search.py +51 -0
- agent_cerebro-0.1.0/src/agentrecall/longterm/store.py +34 -0
- agent_cerebro-0.1.0/src/agentrecall/shortterm/__init__.py +1 -0
- agent_cerebro-0.1.0/src/agentrecall/shortterm/check.py +132 -0
- agent_cerebro-0.1.0/src/agentrecall/shortterm/template.py +22 -0
- agent_cerebro-0.1.0/templates/memory.md.template +13 -0
- agent_cerebro-0.1.0/tests/conftest.py +44 -0
- agent_cerebro-0.1.0/tests/test_check.py +155 -0
- agent_cerebro-0.1.0/tests/test_cli.py +135 -0
- agent_cerebro-0.1.0/tests/test_embeddings.py +87 -0
- agent_cerebro-0.1.0/tests/test_migrate.py +508 -0
- agent_cerebro-0.1.0/tests/test_public_api.py +23 -0
- agent_cerebro-0.1.0/tests/test_schema.py +115 -0
- agent_cerebro-0.1.0/tests/test_search.py +120 -0
- agent_cerebro-0.1.0/tests/test_store.py +144 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.1 (2026-03-12)
|
|
4
|
+
|
|
5
|
+
Renamed PyPI package from `agentrecall` to `agentrecall-memory` (PyPI rejected `agentrecall` as too similar to existing `agent-recall`). Python import name (`from agentrecall import ...`) and CLI commands (`agentrecall store/search/...`) are unchanged.
|
|
6
|
+
|
|
7
|
+
## 0.1.0 (2026-03-11)
|
|
8
|
+
|
|
9
|
+
Initial release (as agentrecall, renamed from agentmemory).
|
|
10
|
+
|
|
11
|
+
- Two-tier memory: short-term markdown files + long-term SQLite with OpenAI embeddings
|
|
12
|
+
- CLI: `agentrecall store/search/list/check/init/migrate`
|
|
13
|
+
- Semantic dedup via cosine similarity (threshold >0.92)
|
|
14
|
+
- Keyword fallback when no OpenAI API key
|
|
15
|
+
- Short-term memory file validation (80-line limit, session log pruning)
|
|
16
|
+
- JSONL to SQLite migration tool
|
|
17
|
+
- Agent Skills packaging (`skill/agent-recall/`)
|
|
18
|
+
- Zero required dependencies (SQLite is stdlib)
|
|
19
|
+
- Full pytest suite
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ultrathink
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-cerebro
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Persistent two-tier memory for AI agents. Short-term markdown + long-term SQLite with semantic search.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ultrathink-art/agentrecall
|
|
6
|
+
Project-URL: Repository, https://github.com/ultrathink-art/agentrecall
|
|
7
|
+
Project-URL: Issues, https://github.com/ultrathink-art/agentrecall/issues
|
|
8
|
+
Author-email: Ultrathink <ceo@ultrathink.art>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai-agents,embeddings,memory,semantic-search,sqlite
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: openai>=1.0; extra == 'all'
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
28
|
+
Provides-Extra: embeddings
|
|
29
|
+
Requires-Dist: openai>=1.0; extra == 'embeddings'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# AgentRecall
|
|
33
|
+
|
|
34
|
+
[](https://pypi.org/project/agentrecall-memory/)
|
|
35
|
+
[](https://pypi.org/project/agentrecall-memory/)
|
|
36
|
+
[](https://opensource.org/licenses/MIT)
|
|
37
|
+
|
|
38
|
+
Persistent two-tier memory for AI agents. Battle-tested across 134 sessions with 10 agent roles.
|
|
39
|
+
|
|
40
|
+
**Short-term** (markdown files, always loaded) + **Long-term** (SQLite + OpenAI embeddings, searched on-demand).
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install agentrecall-memory
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Zero required dependencies. SQLite is Python stdlib.
|
|
49
|
+
|
|
50
|
+
Optional semantic search:
|
|
51
|
+
```bash
|
|
52
|
+
pip install agentrecall-memory[embeddings]
|
|
53
|
+
export OPENAI_API_KEY="sk-..."
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
### CLI
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Initialize
|
|
62
|
+
agentrecall init
|
|
63
|
+
|
|
64
|
+
# Store a memory (auto-dedup via cosine similarity >0.92)
|
|
65
|
+
agentrecall store coder gotchas "kamal app exec spawns new container, use docker exec"
|
|
66
|
+
agentrecall store social exhausted_stories "blue-green deploy order loss" --tags deploy,sqlite
|
|
67
|
+
|
|
68
|
+
# Search (semantic + keyword fallback)
|
|
69
|
+
agentrecall search coder gotchas "kamal file not found"
|
|
70
|
+
|
|
71
|
+
# List categories
|
|
72
|
+
agentrecall list coder
|
|
73
|
+
|
|
74
|
+
# Check health
|
|
75
|
+
agentrecall check --all
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Python API
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from agentrecall import MemoryStore, MemorySearch
|
|
82
|
+
|
|
83
|
+
# Store
|
|
84
|
+
store = MemoryStore()
|
|
85
|
+
store.store("coder", "gotchas", "kamal spawns new container", tags=["kamal", "docker"])
|
|
86
|
+
|
|
87
|
+
# Search
|
|
88
|
+
search = MemorySearch()
|
|
89
|
+
results = search.search("coder", "gotchas", "kamal file not found")
|
|
90
|
+
for text in results:
|
|
91
|
+
print(text)
|
|
92
|
+
|
|
93
|
+
# List categories
|
|
94
|
+
categories = store.list_categories("coder")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## How It Works
|
|
98
|
+
|
|
99
|
+
### Two-Tier Design
|
|
100
|
+
|
|
101
|
+
| Short-term (`memory/<role>.md`) | Long-term (SQLite + embeddings) |
|
|
102
|
+
|---|---|
|
|
103
|
+
| Active learnings, mistakes, feedback | Growing lists (exhausted topics, defect patterns) |
|
|
104
|
+
| Max 80 lines, pruned regularly | Unlimited entries, never pruned |
|
|
105
|
+
| Read in full at session start | Searched on-demand per query |
|
|
106
|
+
|
|
107
|
+
### Semantic Dedup
|
|
108
|
+
|
|
109
|
+
Every `store` call embeds the text via OpenAI `text-embedding-3-small` and checks cosine similarity against all existing entries in the same role/category. Similarity > 0.92 blocks the store (raises `DuplicateError`).
|
|
110
|
+
|
|
111
|
+
Without an API key, falls back to exact text matching.
|
|
112
|
+
|
|
113
|
+
### Search
|
|
114
|
+
|
|
115
|
+
1. Embed the query
|
|
116
|
+
2. Compute cosine similarity against all entries with embeddings
|
|
117
|
+
3. Return entries above threshold (0.75), sorted by similarity
|
|
118
|
+
4. If no embedding matches: keyword fallback (>=50% keyword match)
|
|
119
|
+
5. No API key: keyword-only search
|
|
120
|
+
|
|
121
|
+
### Graceful Degradation
|
|
122
|
+
|
|
123
|
+
Works fully offline without an OpenAI API key:
|
|
124
|
+
- **Store**: exact text dedup (case-insensitive)
|
|
125
|
+
- **Search**: keyword matching (>=50% of query words must appear)
|
|
126
|
+
|
|
127
|
+
## Agent Skills
|
|
128
|
+
|
|
129
|
+
Copy `skill/agent-recall/` into your project's skills directory for use with Claude Code, Codex, Cursor, Copilot, Cline, or Goose.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
cp -r skill/agent-recall/ .claude/skills/agent-recall/
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
Environment variables:
|
|
138
|
+
|
|
139
|
+
| Variable | Default | Description |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| `AGENT_RECALL_HOME` | `~/.agentrecall` | Memory storage directory |
|
|
142
|
+
| `OPENAI_API_KEY` | (none) | OpenAI API key for embeddings |
|
|
143
|
+
| `UT_OPENAI_API_KEY` | (none) | Preferred over `OPENAI_API_KEY` |
|
|
144
|
+
|
|
145
|
+
## CLI Reference
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
agentrecall store <role> <category> "text" [--tags t1,t2] [--db path]
|
|
149
|
+
agentrecall search <role> <category> "query" [--db path]
|
|
150
|
+
agentrecall list <role> [--db path]
|
|
151
|
+
agentrecall check [--fix] [--long-term] [--all] [--dir path] [--db path]
|
|
152
|
+
agentrecall init [--dir path]
|
|
153
|
+
agentrecall migrate [--dry-run] [--rebuild] [--dir path] [--db path]
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Exit codes: `0` = success/found, `1` = not-found/validation-fail, `2` = input error.
|
|
157
|
+
|
|
158
|
+
## Migration from JSONL
|
|
159
|
+
|
|
160
|
+
If you have existing JSONL memory files:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
agentrecall migrate --dir /path/to/memory/
|
|
164
|
+
agentrecall migrate --rebuild # Re-embed entries missing embeddings
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# AgentRecall
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/agentrecall-memory/)
|
|
4
|
+
[](https://pypi.org/project/agentrecall-memory/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Persistent two-tier memory for AI agents. Battle-tested across 134 sessions with 10 agent roles.
|
|
8
|
+
|
|
9
|
+
**Short-term** (markdown files, always loaded) + **Long-term** (SQLite + OpenAI embeddings, searched on-demand).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install agentrecall-memory
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Zero required dependencies. SQLite is Python stdlib.
|
|
18
|
+
|
|
19
|
+
Optional semantic search:
|
|
20
|
+
```bash
|
|
21
|
+
pip install agentrecall-memory[embeddings]
|
|
22
|
+
export OPENAI_API_KEY="sk-..."
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### CLI
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Initialize
|
|
31
|
+
agentrecall init
|
|
32
|
+
|
|
33
|
+
# Store a memory (auto-dedup via cosine similarity >0.92)
|
|
34
|
+
agentrecall store coder gotchas "kamal app exec spawns new container, use docker exec"
|
|
35
|
+
agentrecall store social exhausted_stories "blue-green deploy order loss" --tags deploy,sqlite
|
|
36
|
+
|
|
37
|
+
# Search (semantic + keyword fallback)
|
|
38
|
+
agentrecall search coder gotchas "kamal file not found"
|
|
39
|
+
|
|
40
|
+
# List categories
|
|
41
|
+
agentrecall list coder
|
|
42
|
+
|
|
43
|
+
# Check health
|
|
44
|
+
agentrecall check --all
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Python API
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from agentrecall import MemoryStore, MemorySearch
|
|
51
|
+
|
|
52
|
+
# Store
|
|
53
|
+
store = MemoryStore()
|
|
54
|
+
store.store("coder", "gotchas", "kamal spawns new container", tags=["kamal", "docker"])
|
|
55
|
+
|
|
56
|
+
# Search
|
|
57
|
+
search = MemorySearch()
|
|
58
|
+
results = search.search("coder", "gotchas", "kamal file not found")
|
|
59
|
+
for text in results:
|
|
60
|
+
print(text)
|
|
61
|
+
|
|
62
|
+
# List categories
|
|
63
|
+
categories = store.list_categories("coder")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## How It Works
|
|
67
|
+
|
|
68
|
+
### Two-Tier Design
|
|
69
|
+
|
|
70
|
+
| Short-term (`memory/<role>.md`) | Long-term (SQLite + embeddings) |
|
|
71
|
+
|---|---|
|
|
72
|
+
| Active learnings, mistakes, feedback | Growing lists (exhausted topics, defect patterns) |
|
|
73
|
+
| Max 80 lines, pruned regularly | Unlimited entries, never pruned |
|
|
74
|
+
| Read in full at session start | Searched on-demand per query |
|
|
75
|
+
|
|
76
|
+
### Semantic Dedup
|
|
77
|
+
|
|
78
|
+
Every `store` call embeds the text via OpenAI `text-embedding-3-small` and checks cosine similarity against all existing entries in the same role/category. Similarity > 0.92 blocks the store (raises `DuplicateError`).
|
|
79
|
+
|
|
80
|
+
Without an API key, falls back to exact text matching.
|
|
81
|
+
|
|
82
|
+
### Search
|
|
83
|
+
|
|
84
|
+
1. Embed the query
|
|
85
|
+
2. Compute cosine similarity against all entries with embeddings
|
|
86
|
+
3. Return entries above threshold (0.75), sorted by similarity
|
|
87
|
+
4. If no embedding matches: keyword fallback (>=50% keyword match)
|
|
88
|
+
5. No API key: keyword-only search
|
|
89
|
+
|
|
90
|
+
### Graceful Degradation
|
|
91
|
+
|
|
92
|
+
Works fully offline without an OpenAI API key:
|
|
93
|
+
- **Store**: exact text dedup (case-insensitive)
|
|
94
|
+
- **Search**: keyword matching (>=50% of query words must appear)
|
|
95
|
+
|
|
96
|
+
## Agent Skills
|
|
97
|
+
|
|
98
|
+
Copy `skill/agent-recall/` into your project's skills directory for use with Claude Code, Codex, Cursor, Copilot, Cline, or Goose.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
cp -r skill/agent-recall/ .claude/skills/agent-recall/
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Configuration
|
|
105
|
+
|
|
106
|
+
Environment variables:
|
|
107
|
+
|
|
108
|
+
| Variable | Default | Description |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `AGENT_RECALL_HOME` | `~/.agentrecall` | Memory storage directory |
|
|
111
|
+
| `OPENAI_API_KEY` | (none) | OpenAI API key for embeddings |
|
|
112
|
+
| `UT_OPENAI_API_KEY` | (none) | Preferred over `OPENAI_API_KEY` |
|
|
113
|
+
|
|
114
|
+
## CLI Reference
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
agentrecall store <role> <category> "text" [--tags t1,t2] [--db path]
|
|
118
|
+
agentrecall search <role> <category> "query" [--db path]
|
|
119
|
+
agentrecall list <role> [--db path]
|
|
120
|
+
agentrecall check [--fix] [--long-term] [--all] [--dir path] [--db path]
|
|
121
|
+
agentrecall init [--dir path]
|
|
122
|
+
agentrecall migrate [--dry-run] [--rebuild] [--dir path] [--db path]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Exit codes: `0` = success/found, `1` = not-found/validation-fail, `2` = input error.
|
|
126
|
+
|
|
127
|
+
## Migration from JSONL
|
|
128
|
+
|
|
129
|
+
If you have existing JSONL memory files:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
agentrecall migrate --dir /path/to/memory/
|
|
133
|
+
agentrecall migrate --rebuild # Re-embed entries missing embeddings
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agent-cerebro"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Persistent two-tier memory for AI agents. Short-term markdown + long-term SQLite with semantic search."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Ultrathink", email = "ceo@ultrathink.art" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["ai-agents", "memory", "embeddings", "sqlite", "semantic-search"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Software Development :: Libraries",
|
|
27
|
+
]
|
|
28
|
+
dependencies = []
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
embeddings = ["openai>=1.0"]
|
|
32
|
+
all = ["openai>=1.0"]
|
|
33
|
+
dev = ["pytest>=7.0", "pytest-cov"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/ultrathink-art/agentrecall"
|
|
37
|
+
Repository = "https://github.com/ultrathink-art/agentrecall"
|
|
38
|
+
Issues = "https://github.com/ultrathink-art/agentrecall/issues"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
agentrecall = "agentrecall.cli:main"
|
|
42
|
+
agentmemory = "agentrecall.cli:main"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.wheel]
|
|
45
|
+
packages = ["src/agentrecall"]
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-memory
|
|
3
|
+
description: Persistent two-tier memory for AI agents. Use when storing learnings, searching past work, checking memory health, or following the session start/end memory protocol.
|
|
4
|
+
allowed-tools: Bash(agentrecall *), Bash(python *), Read, Glob
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Agent Recall
|
|
8
|
+
|
|
9
|
+
Persistent two-tier memory for AI agents. Short-term markdown files (always loaded) + long-term SQLite with semantic search (queried on-demand).
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Install (zero required deps — SQLite is stdlib)
|
|
15
|
+
pip install agentrecall-memory
|
|
16
|
+
|
|
17
|
+
# Optional: enable semantic search/dedup
|
|
18
|
+
pip install agentrecall-memory[embeddings]
|
|
19
|
+
export OPENAI_API_KEY="sk-..."
|
|
20
|
+
|
|
21
|
+
# Initialize memory directory
|
|
22
|
+
agentrecall init
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Reference
|
|
26
|
+
|
|
27
|
+
### Store a memory
|
|
28
|
+
```bash
|
|
29
|
+
agentrecall store <role> <category> "text" --tags tag1,tag2
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Search memories
|
|
33
|
+
```bash
|
|
34
|
+
agentrecall search <role> <category> "query"
|
|
35
|
+
# Exit 0 = matches found, exit 1 = no matches
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### List categories
|
|
39
|
+
```bash
|
|
40
|
+
agentrecall list <role>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Check health
|
|
44
|
+
```bash
|
|
45
|
+
agentrecall check # Short-term files
|
|
46
|
+
agentrecall check --long-term # DB health
|
|
47
|
+
agentrecall check --all # Both
|
|
48
|
+
agentrecall check --fix # Auto-prune oversized files
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Protocol
|
|
52
|
+
|
|
53
|
+
1. **Session start**: Read `memory/<role>.md` — your accumulated knowledge
|
|
54
|
+
2. **Before acting**: `agentrecall search <role> <category> "concept"` to check past work
|
|
55
|
+
3. **After acting**: `agentrecall store <role> <category> "what you learned"`
|
|
56
|
+
4. **Session end**: Update `memory/<role>.md` with mistakes/learnings, run `agentrecall check`
|
|
57
|
+
|
|
58
|
+
## References
|
|
59
|
+
|
|
60
|
+
- [Memory Directive](references/memory-directive.md) — full agent protocol
|
|
61
|
+
- [Best Practices](references/best-practices.md) — patterns that work
|
|
62
|
+
- [Categories Guide](references/categories-guide.md) — suggested categories by role
|
|
63
|
+
|
|
64
|
+
## Scripts
|
|
65
|
+
|
|
66
|
+
- `scripts/store.py` — programmatic store
|
|
67
|
+
- `scripts/search.py` — programmatic search
|
|
68
|
+
- `scripts/check.py` — programmatic health check
|
|
69
|
+
- `scripts/setup.py` — initialize for a new project
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Memory Best Practices
|
|
2
|
+
|
|
3
|
+
## Short-Term (markdown files)
|
|
4
|
+
|
|
5
|
+
- **Be specific**: "Run `CI=true bin/rails test` after commit" > "Don't forget tests"
|
|
6
|
+
- **Be honest**: Record mistakes — your memory is working notes, not a performance review
|
|
7
|
+
- **Prune actively**: Every update, scan for stale/duplicate entries and remove them
|
|
8
|
+
- **Don't duplicate docs**: If a rule exists in project docs, reference it, don't copy
|
|
9
|
+
- **Newest first**: Append at TOP of each section so the most relevant info is seen first
|
|
10
|
+
|
|
11
|
+
## Long-Term (SQLite + embeddings)
|
|
12
|
+
|
|
13
|
+
- **Search before acting**: Always check if you've done similar work before
|
|
14
|
+
- **Store after acting**: Record what you did so future sessions can find it
|
|
15
|
+
- **Use tags**: Tags expand searchability (`--tags deploy,sqlite,orders`)
|
|
16
|
+
- **Let dedup work**: If store rejects as duplicate, that's correct behavior — don't force it
|
|
17
|
+
- **Category naming**: Use `snake_case`. Keep categories focused (10-50 entries ideal)
|
|
18
|
+
|
|
19
|
+
## Two-Tier Design
|
|
20
|
+
|
|
21
|
+
| When to use short-term | When to use long-term |
|
|
22
|
+
|---|---|
|
|
23
|
+
| Active lessons you need every session | Growing lists (exhausted topics, known entities) |
|
|
24
|
+
| Recent mistakes to avoid | Historical catalog (past designs, past bugs) |
|
|
25
|
+
| Stakeholder preferences | Reference data searched on-demand |
|
|
26
|
+
|
|
27
|
+
## Anti-Patterns
|
|
28
|
+
|
|
29
|
+
- **Append-only logs**: Memory files that only grow → use long-term storage instead
|
|
30
|
+
- **Copying project docs**: Wastes your 80-line budget on info that exists elsewhere
|
|
31
|
+
- **Vague entries**: "Be careful with deploys" teaches nothing
|
|
32
|
+
- **Stale entries**: Bugs that were fixed, tools that changed → delete them
|
|
33
|
+
- **Duplicate lessons**: Same lesson recorded 3+ times means you're not learning from it
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Suggested Categories by Role
|
|
2
|
+
|
|
3
|
+
Any agent can create categories by storing the first entry. Convention: `snake_case`.
|
|
4
|
+
|
|
5
|
+
| Role | Category | Use |
|
|
6
|
+
|------|----------|-----|
|
|
7
|
+
| social | `exhausted_stories` | Topics/stories already posted |
|
|
8
|
+
| social | `engagement_patterns` | What works on each platform |
|
|
9
|
+
| designer | `rejected_designs` | Concepts rejected and why |
|
|
10
|
+
| designer | `successful_designs` | What sold well and patterns |
|
|
11
|
+
| coder | `fix_attempts` | Past debugging approaches per bug class |
|
|
12
|
+
| coder | `gotchas` | Non-obvious platform/framework traps |
|
|
13
|
+
| qa | `defect_patterns` | Historical defect catalog |
|
|
14
|
+
| operations | `audit_findings` | Systemic issues found and fixes applied |
|
|
15
|
+
| marketing | `published_topics` | Blog/content topics already covered |
|
|
16
|
+
| marketing | `content_performance` | What content drove traffic |
|
|
17
|
+
| security | `vulnerability_patterns` | Recurring vuln types across audits |
|
|
18
|
+
| product | `launch_history` | Products launched and outcomes |
|
|
19
|
+
|
|
20
|
+
## Creating New Categories
|
|
21
|
+
|
|
22
|
+
Just store an entry — the category is created implicitly:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
agentrecall store myagent new_category "first entry in this category"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Category Size Guidelines
|
|
29
|
+
|
|
30
|
+
- **< 10 entries**: Category may be too narrow, consider merging
|
|
31
|
+
- **10-50 entries**: Ideal range for focused, searchable memory
|
|
32
|
+
- **50-200 entries**: Still fine — semantic search handles it well
|
|
33
|
+
- **200+ entries**: Consider splitting into subcategories
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Agent Memory Protocol
|
|
2
|
+
|
|
3
|
+
You have persistent memory across sessions. USE IT.
|
|
4
|
+
|
|
5
|
+
## At Session START
|
|
6
|
+
|
|
7
|
+
Read your memory file: `memory/<your-role>.md`
|
|
8
|
+
|
|
9
|
+
Contains accumulated knowledge — mistakes, learnings, feedback, session log. Treat as your personal notebook.
|
|
10
|
+
|
|
11
|
+
## At Session END
|
|
12
|
+
|
|
13
|
+
Update your memory file. Add entries to relevant sections. Be specific and actionable.
|
|
14
|
+
|
|
15
|
+
Run `agentrecall check` to validate size limits. Use `agentrecall check --fix` if over limit.
|
|
16
|
+
|
|
17
|
+
### What to record
|
|
18
|
+
|
|
19
|
+
**Mistakes** — what went wrong, correct approach, how to avoid next time.
|
|
20
|
+
|
|
21
|
+
**Learnings** — non-obvious discoveries, gotchas, workarounds, patterns that work.
|
|
22
|
+
|
|
23
|
+
**Session Log** — 1-2 lines per session: task ID, what you worked on, outcome.
|
|
24
|
+
|
|
25
|
+
### Format
|
|
26
|
+
|
|
27
|
+
Append new entries at TOP of each section (newest first). Date prefix: `[YYYY-MM-DD]`.
|
|
28
|
+
|
|
29
|
+
### Size limits
|
|
30
|
+
|
|
31
|
+
- Mistakes: max 20 entries
|
|
32
|
+
- Learnings: max 20 entries
|
|
33
|
+
- Session Log: max 15 entries
|
|
34
|
+
- Total file: max 80 lines
|
|
35
|
+
|
|
36
|
+
### Pruning rules
|
|
37
|
+
|
|
38
|
+
- Remove entries duplicated in project instructions
|
|
39
|
+
- Remove stale entries (fixed bugs, removed workarounds)
|
|
40
|
+
- Consolidate duplicate lessons into one entry
|
|
41
|
+
- Use long-term memory (`agentrecall store`) for growing lists
|
|
42
|
+
|
|
43
|
+
## Long-Term Memory
|
|
44
|
+
|
|
45
|
+
For data that grows unboundedly (exhausted topics, known patterns, recurring references).
|
|
46
|
+
|
|
47
|
+
### Search-before-action pattern
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Before creating content that might duplicate past work:
|
|
51
|
+
agentrecall search <role> <category> "<concept keywords>"
|
|
52
|
+
# Exit 0 = matches found → skip/choose different topic
|
|
53
|
+
# Exit 1 = no matches → safe to proceed
|
|
54
|
+
|
|
55
|
+
# After completing work:
|
|
56
|
+
agentrecall store <role> <category> "<what you did>"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Memory File Template
|
|
60
|
+
|
|
61
|
+
```markdown
|
|
62
|
+
# {Role} Agent Memory
|
|
63
|
+
|
|
64
|
+
## Mistakes
|
|
65
|
+
- [2026-03-11] Description of what went wrong and how to avoid it.
|
|
66
|
+
|
|
67
|
+
## Learnings
|
|
68
|
+
- [2026-03-11] Non-obvious discovery specific to your role.
|
|
69
|
+
|
|
70
|
+
## Session Log
|
|
71
|
+
- [2026-03-11] Task/summary of what was done.
|
|
72
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Check memory health (short-term file limits + DB integrity).
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
python check.py [--fix] [--long-term] [--all] [--dir PATH]
|
|
6
|
+
"""
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from agentrecall.cli import main as cli_main
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
args = ["check"] + sys.argv[1:]
|
|
14
|
+
try:
|
|
15
|
+
cli_main(args)
|
|
16
|
+
except SystemExit as e:
|
|
17
|
+
sys.exit(e.code)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if __name__ == "__main__":
|
|
21
|
+
main()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Search long-term agent memory.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
python search.py <role> <category> "query"
|
|
6
|
+
python search.py <role> --list
|
|
7
|
+
"""
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
from agentrecall.longterm.search import run_search, run_list
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main():
|
|
14
|
+
args = sys.argv[1:]
|
|
15
|
+
if len(args) < 2:
|
|
16
|
+
print("Usage: python search.py <role> <category> \"query\"", file=sys.stderr)
|
|
17
|
+
print(" python search.py <role> --list", file=sys.stderr)
|
|
18
|
+
sys.exit(2)
|
|
19
|
+
|
|
20
|
+
role = args[0]
|
|
21
|
+
|
|
22
|
+
if args[1] == "--list":
|
|
23
|
+
sys.exit(run_list(role))
|
|
24
|
+
|
|
25
|
+
if len(args) < 3:
|
|
26
|
+
print("ERROR: query is required", file=sys.stderr)
|
|
27
|
+
sys.exit(2)
|
|
28
|
+
|
|
29
|
+
category = args[1]
|
|
30
|
+
query = " ".join(args[2:])
|
|
31
|
+
|
|
32
|
+
sys.exit(run_search(role, category, query))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == "__main__":
|
|
36
|
+
main()
|