mimir-learn 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.
- mimir_learn-0.1.0/.github/workflows/ci.yml +28 -0
- mimir_learn-0.1.0/.github/workflows/publish.yml +46 -0
- mimir_learn-0.1.0/.gitignore +31 -0
- mimir_learn-0.1.0/LICENSE +21 -0
- mimir_learn-0.1.0/PKG-INFO +226 -0
- mimir_learn-0.1.0/README.md +180 -0
- mimir_learn-0.1.0/pyproject.toml +43 -0
- mimir_learn-0.1.0/src/mimir/__init__.py +19 -0
- mimir_learn-0.1.0/src/mimir/core.py +201 -0
- mimir_learn-0.1.0/src/mimir/embeddings.py +39 -0
- mimir_learn-0.1.0/src/mimir/models.py +89 -0
- mimir_learn-0.1.0/src/mimir/storage/__init__.py +4 -0
- mimir_learn-0.1.0/src/mimir/storage/base.py +52 -0
- mimir_learn-0.1.0/src/mimir/storage/sqlite.py +230 -0
- mimir_learn-0.1.0/tests/test_mimir.py +192 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
- name: Install
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
pip install -e ".[dev]"
|
|
25
|
+
- name: Lint (ruff)
|
|
26
|
+
run: ruff check .
|
|
27
|
+
- name: Test (pytest)
|
|
28
|
+
run: pytest -q
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Publishes when you create a GitHub Release. Uses PyPI Trusted Publishing
|
|
4
|
+
# (OIDC) — no API tokens are stored anywhere.
|
|
5
|
+
on:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
name: Build & test
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- name: Install
|
|
19
|
+
run: |
|
|
20
|
+
python -m pip install --upgrade pip build
|
|
21
|
+
pip install -e ".[dev]"
|
|
22
|
+
- name: Test
|
|
23
|
+
run: pytest -q
|
|
24
|
+
- name: Build distributions
|
|
25
|
+
run: python -m build
|
|
26
|
+
- name: Upload artifacts
|
|
27
|
+
uses: actions/upload-artifact@v4
|
|
28
|
+
with:
|
|
29
|
+
name: dist
|
|
30
|
+
path: dist/
|
|
31
|
+
|
|
32
|
+
publish:
|
|
33
|
+
name: Publish to PyPI
|
|
34
|
+
needs: build
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
environment: pypi
|
|
37
|
+
permissions:
|
|
38
|
+
id-token: write # required for Trusted Publishing (OIDC)
|
|
39
|
+
steps:
|
|
40
|
+
- name: Download distributions
|
|
41
|
+
uses: actions/download-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: dist
|
|
44
|
+
path: dist/
|
|
45
|
+
- name: Publish
|
|
46
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Virtual environments
|
|
2
|
+
.venv/
|
|
3
|
+
venv/
|
|
4
|
+
env/
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*.egg-info/
|
|
10
|
+
build/
|
|
11
|
+
dist/
|
|
12
|
+
.eggs/
|
|
13
|
+
|
|
14
|
+
# Mimir local data
|
|
15
|
+
*.db
|
|
16
|
+
*.db-journal
|
|
17
|
+
*.sqlite
|
|
18
|
+
*.sqlite3
|
|
19
|
+
|
|
20
|
+
# Testing / tooling
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.mypy_cache/
|
|
23
|
+
.ruff_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
htmlcov/
|
|
26
|
+
|
|
27
|
+
# Editor / OS
|
|
28
|
+
.idea/
|
|
29
|
+
.vscode/
|
|
30
|
+
.DS_Store
|
|
31
|
+
Thumbs.db
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AshNicolus
|
|
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,226 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mimir-learn
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Experience-driven memory for autonomous agents — learn from past successes and failures.
|
|
5
|
+
Project-URL: Homepage, https://github.com/AshNicolus/mimir
|
|
6
|
+
Project-URL: Repository, https://github.com/AshNicolus/mimir
|
|
7
|
+
Author: AshNicolus
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 AshNicolus
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Keywords: agents,experience,learning,llm,memory
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
37
|
+
Requires-Python: >=3.11
|
|
38
|
+
Requires-Dist: pydantic>=2.5
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
42
|
+
Provides-Extra: embeddings
|
|
43
|
+
Requires-Dist: numpy>=1.24; extra == 'embeddings'
|
|
44
|
+
Requires-Dist: sentence-transformers>=2.2; extra == 'embeddings'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# Mimir
|
|
48
|
+
|
|
49
|
+
**Experience-driven memory for autonomous agents.** Mimir helps agents learn from their past successes and failures instead of starting from scratch on every task.
|
|
50
|
+
|
|
51
|
+
> Named after Mímir, the keeper of wisdom in Norse mythology.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## The problem
|
|
56
|
+
|
|
57
|
+
Today's agents have memory, but they don't really *learn*.
|
|
58
|
+
|
|
59
|
+
Most frameworks store one of two things:
|
|
60
|
+
|
|
61
|
+
- **Conversation history** (LangGraph memory, buffer memory)
|
|
62
|
+
- **Vector embeddings of documents** (RAG, AGENTS.md, CLAUDE.md)
|
|
63
|
+
|
|
64
|
+
Both let an agent **remember information**. Neither lets it **remember experience**.
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
Task: Fix authentication latency
|
|
68
|
+
Action: Added Redis cache
|
|
69
|
+
Outcome: Success
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A month later, the agent has no meaningful understanding that this strategy worked. It solves the same class of problem from zero, every time.
|
|
73
|
+
|
|
74
|
+
## The idea
|
|
75
|
+
|
|
76
|
+
Instead of storing documents, embeddings, and metadata, Mimir stores **experiences**:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Problem → Action → Outcome → Confidence → Context → Time
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
From a stream of experiences, Mimir reflects, extracts reusable strategies, and recommends actions for new tasks — so the agent gets measurably better over time.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from mimir import Mimir
|
|
86
|
+
|
|
87
|
+
memory = Mimir()
|
|
88
|
+
|
|
89
|
+
# Record what happened
|
|
90
|
+
memory.record(
|
|
91
|
+
task="Fix authentication timeout",
|
|
92
|
+
action="Implemented Redis caching",
|
|
93
|
+
outcome="success",
|
|
94
|
+
score=0.95,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Recall relevant past experience
|
|
98
|
+
past = memory.recall("authentication latency")
|
|
99
|
+
|
|
100
|
+
# Get a recommended strategy with confidence
|
|
101
|
+
strategy = memory.recommend("login timeout")
|
|
102
|
+
# → Strategy: "Redis caching" | confidence: 0.87 | based on 23 successes / 2 failures
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## How it differs from AGENTS.md / CLAUDE.md
|
|
106
|
+
|
|
107
|
+
| | AGENTS.md / CLAUDE.md | Mimir |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| Knowledge type | Static, hand-written rules | Dynamic, learned from outcomes |
|
|
110
|
+
| Updates | Manually edited | Updates itself from results |
|
|
111
|
+
| Example | "Use FastAPI. Use PostgreSQL." | "Redis caching solved auth latency 23/25 times (92%)." |
|
|
112
|
+
| Failures | Not tracked | First-class — agents stop repeating mistakes |
|
|
113
|
+
|
|
114
|
+
AGENTS.md answers *"What should the agent remember?"*
|
|
115
|
+
Mimir answers *"How does an agent accumulate experience and become wiser over time?"*
|
|
116
|
+
|
|
117
|
+
## Design principles
|
|
118
|
+
|
|
119
|
+
Mimir is built as a **modular monolith Python library** — not a microservice swarm, not a managed cloud product. The library is the product.
|
|
120
|
+
|
|
121
|
+
- **No LLM and no web server required for v1.** Storage, retrieval, and ranking come first. Reflection via an LLM is added later, behind an interface.
|
|
122
|
+
- **Pluggable seams.** Storage, embeddings, and the write path are interfaces, so scaling up (SQLite → Postgres → async reflection → Redis cache) is a swap, never a rewrite.
|
|
123
|
+
- **Derived knowledge is rebuildable.** Strategies and reflections are computed from raw experiences and can always be regenerated.
|
|
124
|
+
- **Failures are first-class.** Learning from what *didn't* work is treated as importantly as what did.
|
|
125
|
+
|
|
126
|
+
## Architecture
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
┌────────────────────────────────────────────────────────────┐
|
|
130
|
+
│ Public API Mimir() .record() .recall() .recommend() │
|
|
131
|
+
├────────────────────────────────────────────────────────────┤
|
|
132
|
+
│ Write chokepoint ──► [validation / provenance hook] │ single write path
|
|
133
|
+
├──────────────┬───────────────┬─────────────────────────────┤
|
|
134
|
+
│ Episodic │ Reflection │ Recommendation │
|
|
135
|
+
│ Engine │ Engine │ Engine │
|
|
136
|
+
│ (record/ │ (reflect/ │ (recommend / rank / │
|
|
137
|
+
│ recall) │ extract) │ confidence) │
|
|
138
|
+
├──────────────┴───────────────┴─────────────────────────────┤
|
|
139
|
+
│ Retrieval layer (keyword + optional vector hybrid) │
|
|
140
|
+
├────────────────────────────────────────────────────────────┤
|
|
141
|
+
│ Storage interface SQLite (v1) · Postgres (v2) · … │ pluggable
|
|
142
|
+
├────────────────────────────────────────────────────────────┤
|
|
143
|
+
│ Embedding provider none (default) · local · API │ pluggable
|
|
144
|
+
└────────────────────────────────────────────────────────────┘
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Data model
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
Experience
|
|
151
|
+
id, task, action, outcome (success|failure|partial),
|
|
152
|
+
score (0..1), context (json), embedding (nullable),
|
|
153
|
+
created_at, superseded_by (nullable)
|
|
154
|
+
|
|
155
|
+
Strategy (derived) problem_pattern, recommended_action, confidence,
|
|
156
|
+
success_count, failure_count, source_experience_ids
|
|
157
|
+
Reflection (derived) summary, pattern, supporting_experience_ids, created_at
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Installation
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pip install mimir # (coming soon)
|
|
164
|
+
|
|
165
|
+
# or, for development
|
|
166
|
+
git clone https://github.com/<you>/mimir.git
|
|
167
|
+
cd mimir
|
|
168
|
+
pip install -e ".[dev]"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Requirements:** Python 3.11+. v1 has no required external services — storage is a local SQLite file. Semantic search and reflection are optional extras.
|
|
172
|
+
|
|
173
|
+
## Quick start
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from mimir import Mimir
|
|
177
|
+
|
|
178
|
+
memory = Mimir(db_path="mimir.db")
|
|
179
|
+
|
|
180
|
+
memory.record(
|
|
181
|
+
task="Fix login latency",
|
|
182
|
+
action="Added Redis cache in front of session lookups",
|
|
183
|
+
outcome="success",
|
|
184
|
+
score=0.9,
|
|
185
|
+
context={"service": "auth", "language": "python"},
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
memory.record_failure(
|
|
189
|
+
task="Throttle abusive clients",
|
|
190
|
+
action="Added a fixed-window rate limiter",
|
|
191
|
+
reason="WebSocket traffic wasn't handled — limiter only saw HTTP",
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
for exp in memory.recall("authentication is slow", k=5):
|
|
195
|
+
print(exp.action, exp.outcome, exp.score)
|
|
196
|
+
|
|
197
|
+
print(memory.recommend("login times out under load"))
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Roadmap
|
|
201
|
+
|
|
202
|
+
| Phase | Goal | Status |
|
|
203
|
+
|---|---|---|
|
|
204
|
+
| **1 — Episodic memory** | `record()` / `recall()`, outcome tracking, SQLite backend | 🛠️ In progress |
|
|
205
|
+
| **2 — Failure memory** | `record_failure()`, failures queried separately | Planned |
|
|
206
|
+
| **3 — Reflection engine** | `reflect()` — cluster experiences, synthesize patterns (LLM) | Planned |
|
|
207
|
+
| **4 — Strategy extraction** | Turn experiences into reusable strategies with confidence | Planned |
|
|
208
|
+
| **5 — Recommendation engine** | `recommend()` — rank strategies for a new task | Planned |
|
|
209
|
+
| **6 — Shared org memory** | Multiple agents learn from a shared store | Future |
|
|
210
|
+
|
|
211
|
+
## Scaling path
|
|
212
|
+
|
|
213
|
+
Mimir starts as a single SQLite file and grows by swapping seams — no rewrites:
|
|
214
|
+
|
|
215
|
+
1. **v1** — SQLite, in-process, single agent.
|
|
216
|
+
2. **v2** — Postgres + pgvector backend for concurrent multi-agent writes.
|
|
217
|
+
3. **v3** — extract the (slow, batch) reflection engine into an async worker.
|
|
218
|
+
4. **v4** — Redis cache for hot/recent experiences on the read path.
|
|
219
|
+
|
|
220
|
+
## Status
|
|
221
|
+
|
|
222
|
+
Early development. APIs will change. Not yet published to PyPI. Feedback and ideas welcome.
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
MIT
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Mimir
|
|
2
|
+
|
|
3
|
+
**Experience-driven memory for autonomous agents.** Mimir helps agents learn from their past successes and failures instead of starting from scratch on every task.
|
|
4
|
+
|
|
5
|
+
> Named after Mímir, the keeper of wisdom in Norse mythology.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## The problem
|
|
10
|
+
|
|
11
|
+
Today's agents have memory, but they don't really *learn*.
|
|
12
|
+
|
|
13
|
+
Most frameworks store one of two things:
|
|
14
|
+
|
|
15
|
+
- **Conversation history** (LangGraph memory, buffer memory)
|
|
16
|
+
- **Vector embeddings of documents** (RAG, AGENTS.md, CLAUDE.md)
|
|
17
|
+
|
|
18
|
+
Both let an agent **remember information**. Neither lets it **remember experience**.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Task: Fix authentication latency
|
|
22
|
+
Action: Added Redis cache
|
|
23
|
+
Outcome: Success
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
A month later, the agent has no meaningful understanding that this strategy worked. It solves the same class of problem from zero, every time.
|
|
27
|
+
|
|
28
|
+
## The idea
|
|
29
|
+
|
|
30
|
+
Instead of storing documents, embeddings, and metadata, Mimir stores **experiences**:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Problem → Action → Outcome → Confidence → Context → Time
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
From a stream of experiences, Mimir reflects, extracts reusable strategies, and recommends actions for new tasks — so the agent gets measurably better over time.
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from mimir import Mimir
|
|
40
|
+
|
|
41
|
+
memory = Mimir()
|
|
42
|
+
|
|
43
|
+
# Record what happened
|
|
44
|
+
memory.record(
|
|
45
|
+
task="Fix authentication timeout",
|
|
46
|
+
action="Implemented Redis caching",
|
|
47
|
+
outcome="success",
|
|
48
|
+
score=0.95,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Recall relevant past experience
|
|
52
|
+
past = memory.recall("authentication latency")
|
|
53
|
+
|
|
54
|
+
# Get a recommended strategy with confidence
|
|
55
|
+
strategy = memory.recommend("login timeout")
|
|
56
|
+
# → Strategy: "Redis caching" | confidence: 0.87 | based on 23 successes / 2 failures
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## How it differs from AGENTS.md / CLAUDE.md
|
|
60
|
+
|
|
61
|
+
| | AGENTS.md / CLAUDE.md | Mimir |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| Knowledge type | Static, hand-written rules | Dynamic, learned from outcomes |
|
|
64
|
+
| Updates | Manually edited | Updates itself from results |
|
|
65
|
+
| Example | "Use FastAPI. Use PostgreSQL." | "Redis caching solved auth latency 23/25 times (92%)." |
|
|
66
|
+
| Failures | Not tracked | First-class — agents stop repeating mistakes |
|
|
67
|
+
|
|
68
|
+
AGENTS.md answers *"What should the agent remember?"*
|
|
69
|
+
Mimir answers *"How does an agent accumulate experience and become wiser over time?"*
|
|
70
|
+
|
|
71
|
+
## Design principles
|
|
72
|
+
|
|
73
|
+
Mimir is built as a **modular monolith Python library** — not a microservice swarm, not a managed cloud product. The library is the product.
|
|
74
|
+
|
|
75
|
+
- **No LLM and no web server required for v1.** Storage, retrieval, and ranking come first. Reflection via an LLM is added later, behind an interface.
|
|
76
|
+
- **Pluggable seams.** Storage, embeddings, and the write path are interfaces, so scaling up (SQLite → Postgres → async reflection → Redis cache) is a swap, never a rewrite.
|
|
77
|
+
- **Derived knowledge is rebuildable.** Strategies and reflections are computed from raw experiences and can always be regenerated.
|
|
78
|
+
- **Failures are first-class.** Learning from what *didn't* work is treated as importantly as what did.
|
|
79
|
+
|
|
80
|
+
## Architecture
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
┌────────────────────────────────────────────────────────────┐
|
|
84
|
+
│ Public API Mimir() .record() .recall() .recommend() │
|
|
85
|
+
├────────────────────────────────────────────────────────────┤
|
|
86
|
+
│ Write chokepoint ──► [validation / provenance hook] │ single write path
|
|
87
|
+
├──────────────┬───────────────┬─────────────────────────────┤
|
|
88
|
+
│ Episodic │ Reflection │ Recommendation │
|
|
89
|
+
│ Engine │ Engine │ Engine │
|
|
90
|
+
│ (record/ │ (reflect/ │ (recommend / rank / │
|
|
91
|
+
│ recall) │ extract) │ confidence) │
|
|
92
|
+
├──────────────┴───────────────┴─────────────────────────────┤
|
|
93
|
+
│ Retrieval layer (keyword + optional vector hybrid) │
|
|
94
|
+
├────────────────────────────────────────────────────────────┤
|
|
95
|
+
│ Storage interface SQLite (v1) · Postgres (v2) · … │ pluggable
|
|
96
|
+
├────────────────────────────────────────────────────────────┤
|
|
97
|
+
│ Embedding provider none (default) · local · API │ pluggable
|
|
98
|
+
└────────────────────────────────────────────────────────────┘
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Data model
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Experience
|
|
105
|
+
id, task, action, outcome (success|failure|partial),
|
|
106
|
+
score (0..1), context (json), embedding (nullable),
|
|
107
|
+
created_at, superseded_by (nullable)
|
|
108
|
+
|
|
109
|
+
Strategy (derived) problem_pattern, recommended_action, confidence,
|
|
110
|
+
success_count, failure_count, source_experience_ids
|
|
111
|
+
Reflection (derived) summary, pattern, supporting_experience_ids, created_at
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Installation
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pip install mimir # (coming soon)
|
|
118
|
+
|
|
119
|
+
# or, for development
|
|
120
|
+
git clone https://github.com/<you>/mimir.git
|
|
121
|
+
cd mimir
|
|
122
|
+
pip install -e ".[dev]"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Requirements:** Python 3.11+. v1 has no required external services — storage is a local SQLite file. Semantic search and reflection are optional extras.
|
|
126
|
+
|
|
127
|
+
## Quick start
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from mimir import Mimir
|
|
131
|
+
|
|
132
|
+
memory = Mimir(db_path="mimir.db")
|
|
133
|
+
|
|
134
|
+
memory.record(
|
|
135
|
+
task="Fix login latency",
|
|
136
|
+
action="Added Redis cache in front of session lookups",
|
|
137
|
+
outcome="success",
|
|
138
|
+
score=0.9,
|
|
139
|
+
context={"service": "auth", "language": "python"},
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
memory.record_failure(
|
|
143
|
+
task="Throttle abusive clients",
|
|
144
|
+
action="Added a fixed-window rate limiter",
|
|
145
|
+
reason="WebSocket traffic wasn't handled — limiter only saw HTTP",
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
for exp in memory.recall("authentication is slow", k=5):
|
|
149
|
+
print(exp.action, exp.outcome, exp.score)
|
|
150
|
+
|
|
151
|
+
print(memory.recommend("login times out under load"))
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Roadmap
|
|
155
|
+
|
|
156
|
+
| Phase | Goal | Status |
|
|
157
|
+
|---|---|---|
|
|
158
|
+
| **1 — Episodic memory** | `record()` / `recall()`, outcome tracking, SQLite backend | 🛠️ In progress |
|
|
159
|
+
| **2 — Failure memory** | `record_failure()`, failures queried separately | Planned |
|
|
160
|
+
| **3 — Reflection engine** | `reflect()` — cluster experiences, synthesize patterns (LLM) | Planned |
|
|
161
|
+
| **4 — Strategy extraction** | Turn experiences into reusable strategies with confidence | Planned |
|
|
162
|
+
| **5 — Recommendation engine** | `recommend()` — rank strategies for a new task | Planned |
|
|
163
|
+
| **6 — Shared org memory** | Multiple agents learn from a shared store | Future |
|
|
164
|
+
|
|
165
|
+
## Scaling path
|
|
166
|
+
|
|
167
|
+
Mimir starts as a single SQLite file and grows by swapping seams — no rewrites:
|
|
168
|
+
|
|
169
|
+
1. **v1** — SQLite, in-process, single agent.
|
|
170
|
+
2. **v2** — Postgres + pgvector backend for concurrent multi-agent writes.
|
|
171
|
+
3. **v3** — extract the (slow, batch) reflection engine into an async worker.
|
|
172
|
+
4. **v4** — Redis cache for hot/recent experiences on the read path.
|
|
173
|
+
|
|
174
|
+
## Status
|
|
175
|
+
|
|
176
|
+
Early development. APIs will change. Not yet published to PyPI. Feedback and ideas welcome.
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mimir-learn"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Experience-driven memory for autonomous agents — learn from past successes and failures."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [{ name = "AshNicolus" }]
|
|
13
|
+
keywords = ["agents", "memory", "llm", "experience", "learning"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"pydantic>=2.5",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
dev = ["pytest>=8.0", "ruff>=0.5"]
|
|
28
|
+
# Local semantic search (optional). Keyword recall works without this.
|
|
29
|
+
embeddings = ["sentence-transformers>=2.2", "numpy>=1.24"]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/AshNicolus/mimir"
|
|
33
|
+
Repository = "https://github.com/AshNicolus/mimir"
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/mimir"]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
testpaths = ["tests"]
|
|
40
|
+
|
|
41
|
+
[tool.ruff]
|
|
42
|
+
line-length = 100
|
|
43
|
+
target-version = "py311"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Mimir — experience-driven memory for autonomous agents."""
|
|
2
|
+
|
|
3
|
+
from .core import Mimir
|
|
4
|
+
from .embeddings import Embedder, NullEmbedder
|
|
5
|
+
from .models import Experience, Outcome, Recommendation
|
|
6
|
+
from .storage import SQLiteStorage, Storage
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"Mimir",
|
|
12
|
+
"Experience",
|
|
13
|
+
"Outcome",
|
|
14
|
+
"Recommendation",
|
|
15
|
+
"Storage",
|
|
16
|
+
"SQLiteStorage",
|
|
17
|
+
"Embedder",
|
|
18
|
+
"NullEmbedder",
|
|
19
|
+
]
|