kryth 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.
Potentially problematic release.
This version of kryth might be problematic. Click here for more details.
- kryth-0.1.0/LICENSE +21 -0
- kryth-0.1.0/PKG-INFO +303 -0
- kryth-0.1.0/README.md +276 -0
- kryth-0.1.0/pyproject.toml +62 -0
- kryth-0.1.0/setup.cfg +4 -0
- kryth-0.1.0/src/kryth/__init__.py +31 -0
- kryth-0.1.0/src/kryth/agent/__init__.py +1 -0
- kryth-0.1.0/src/kryth/agent/memory/__init__.py +21 -0
- kryth-0.1.0/src/kryth/agent/memory/controllers.py +415 -0
- kryth-0.1.0/src/kryth.egg-info/PKG-INFO +303 -0
- kryth-0.1.0/src/kryth.egg-info/SOURCES.txt +12 -0
- kryth-0.1.0/src/kryth.egg-info/dependency_links.txt +1 -0
- kryth-0.1.0/src/kryth.egg-info/requires.txt +7 -0
- kryth-0.1.0/src/kryth.egg-info/top_level.txt +1 -0
kryth-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kryth
|
|
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.
|
kryth-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kryth
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI Agent Memory Framework — structured memory layers for LLM-based agents
|
|
5
|
+
Author: Kryth Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: ai,agent,memory,llm,framework
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
23
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
24
|
+
Requires-Dist: ruff>=0.7; extra == "dev"
|
|
25
|
+
Requires-Dist: pre-commit>=4.0; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
<div align="center">
|
|
29
|
+
<br/>
|
|
30
|
+
<h1>🧠 Kryth</h1>
|
|
31
|
+
<p><strong>AI Agent Memory Framework — Structured memory layers for LLM-based agents</strong></p>
|
|
32
|
+
|
|
33
|
+
<br/>
|
|
34
|
+
|
|
35
|
+
<!-- Badges -->
|
|
36
|
+
<p>
|
|
37
|
+
<a href="https://pypi.org/project/kryth/">
|
|
38
|
+
<img src="https://img.shields.io/pypi/v/kryth?style=for-the-badge&logo=pypi&logoColor=white&color=blueviolet" alt="PyPI Version"/>
|
|
39
|
+
</a>
|
|
40
|
+
<a href="https://pypi.org/project/kryth/">
|
|
41
|
+
<img src="https://img.shields.io/pypi/dm/kryth?style=for-the-badge&logo=python&logoColor=white&color=blue" alt="PyPI Downloads"/>
|
|
42
|
+
</a>
|
|
43
|
+
<a href="LICENSE">
|
|
44
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg?style=for-the-badge" alt="MIT License"/>
|
|
45
|
+
</a>
|
|
46
|
+
<a href="https://github.com/navadeep0508/KRYTH-OS">
|
|
47
|
+
<img src="https://img.shields.io/badge/python-3.10%2B-blue?style=for-the-badge&logo=python&logoColor=white" alt="Python 3.10+"/>
|
|
48
|
+
</a>
|
|
49
|
+
<a href="https://github.com/navadeep0508/KRYTH-OS/actions">
|
|
50
|
+
<img src="https://img.shields.io/badge/code%20style-ruff-261230?style=for-the-badge&logo=ruff&logoColor=white" alt="Ruff"/>
|
|
51
|
+
</a>
|
|
52
|
+
<a href="CONTRIBUTING.md">
|
|
53
|
+
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge&logo=github" alt="PRs Welcome"/>
|
|
54
|
+
</a>
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
<br/>
|
|
58
|
+
|
|
59
|
+
<!-- Quick links -->
|
|
60
|
+
<p>
|
|
61
|
+
<a href="#-quick-start">🚀 Quick Start</a> •
|
|
62
|
+
<a href="#-features">✨ Features</a> •
|
|
63
|
+
<a href="#-architecture">🏗️ Architecture</a> •
|
|
64
|
+
<a href="#-installation">📦 Installation</a> •
|
|
65
|
+
<a href="#-contributing">🤝 Contributing</a>
|
|
66
|
+
</p>
|
|
67
|
+
|
|
68
|
+
<br/>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 💡 Why Kryth?
|
|
74
|
+
|
|
75
|
+
LLM-based agents need **memory** — but not just any memory. They need structured, token-efficient, deduplicated memory that fits inside a context window. Kryth gives you:
|
|
76
|
+
|
|
77
|
+
| Without Kryth | With Kryth |
|
|
78
|
+
|---|---|
|
|
79
|
+
| ❌ Bloated, unstructured context | ✅ Token-capped retrieval (~800 tokens) |
|
|
80
|
+
| ❌ Duplicate reads and redundant commands | ✅ Smart duplicate detection & summarization |
|
|
81
|
+
| ❌ Runaway memory growth | ✅ Automatic compression with configurable limits |
|
|
82
|
+
| ❌ Ad-hoc memory management | ✅ Clean, modular controller architecture |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🚀 Quick Start
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from kryth import WriteController, RetrievalController, compute_state_hash
|
|
90
|
+
|
|
91
|
+
# Compute a unique state hash for your project
|
|
92
|
+
state_hash = compute_state_hash(cwd="/path/to/project")
|
|
93
|
+
|
|
94
|
+
# Route knowledge from tool calls into memory
|
|
95
|
+
write_ctrl = WriteController()
|
|
96
|
+
write_ctrl.on_tool_result(
|
|
97
|
+
tool_name="read_file",
|
|
98
|
+
args={"path": "main.py"},
|
|
99
|
+
result="file contents...",
|
|
100
|
+
error=False,
|
|
101
|
+
session_id=1,
|
|
102
|
+
memory_manager=memory_manager, # Your MemoryManager instance
|
|
103
|
+
turn=3,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Retrieve only the most relevant memories for LLM context
|
|
107
|
+
retrieval_ctrl = RetrievalController()
|
|
108
|
+
context_block = retrieval_ctrl.build_prompt_block(
|
|
109
|
+
memory_manager=memory_manager,
|
|
110
|
+
session_id=1,
|
|
111
|
+
user_input="What does the auth module do?",
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
> 💡 **Tip:** Kryth is designed to integrate with your existing `MemoryManager`. See the [full documentation](#) for setup details.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## ✨ Features
|
|
120
|
+
|
|
121
|
+
<table>
|
|
122
|
+
<tr>
|
|
123
|
+
<td width="50%">
|
|
124
|
+
<h3>🧩 <strong>Modular Architecture</strong></h3>
|
|
125
|
+
<p>Each memory concern — writing, retrieval, deduplication, compression — is isolated in its own controller. Mix and match what you need.</p>
|
|
126
|
+
</td>
|
|
127
|
+
<td width="50%">
|
|
128
|
+
<h3>📏 <strong>Token-Aware Retrieval</strong></h3>
|
|
129
|
+
<p>Context injection is <strong>always capped at ~800 tokens</strong>, ensuring your LLM stays focused and never exceeds context limits.</p>
|
|
130
|
+
</td>
|
|
131
|
+
</tr>
|
|
132
|
+
<tr>
|
|
133
|
+
<td width="50%">
|
|
134
|
+
<h3>🎯 <strong>Relevance Ranking</strong></h3>
|
|
135
|
+
<p>Memories are scored and ranked by importance × query relevance, so only the most pertinent information makes it into the prompt.</p>
|
|
136
|
+
</td>
|
|
137
|
+
<td width="50%">
|
|
138
|
+
<h3>🔍 <strong>Smart Duplicate Detection</strong></h3>
|
|
139
|
+
<p>Detects duplicate file reads and command executions — then returns a <em>summary</em> instead of hard-blocking. Never repeat work.</p>
|
|
140
|
+
</td>
|
|
141
|
+
</tr>
|
|
142
|
+
<tr>
|
|
143
|
+
<td width="50%">
|
|
144
|
+
<h3>🧹 <strong>Automatic Compression</strong></h3>
|
|
145
|
+
<p>Prevents unbounded memory growth with configurable limits per memory layer. Set it and forget it.</p>
|
|
146
|
+
</td>
|
|
147
|
+
<td width="50%">
|
|
148
|
+
<h3>🔐 <strong>State Hashing</strong></h3>
|
|
149
|
+
<p>Robust duplicate command detection using git diff, file hashes, and environment variables. Know when state has genuinely changed.</p>
|
|
150
|
+
</td>
|
|
151
|
+
</tr>
|
|
152
|
+
</table>
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 🏗️ Architecture
|
|
157
|
+
|
|
158
|
+
Kryth organizes memory into a clean, layered architecture:
|
|
159
|
+
|
|
160
|
+
```mermaid
|
|
161
|
+
flowchart TB
|
|
162
|
+
subgraph Input["📥 Inputs"]
|
|
163
|
+
TC[Tool Calls]
|
|
164
|
+
UI[User Input]
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
subgraph Controllers["🎮 Controllers"]
|
|
168
|
+
WC[WriteController]
|
|
169
|
+
RD[DuplicateDetector]
|
|
170
|
+
RC[RetrievalController]
|
|
171
|
+
CC[CompressionController]
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
subgraph Memory["💾 Memory Layers"]
|
|
175
|
+
RM[RepoMemory<br/>File contents, symbols]
|
|
176
|
+
EM[ExecutionMemory<br/>Command history]
|
|
177
|
+
EPM[EpisodicMemory<br/>Edits, decisions]
|
|
178
|
+
WM[WorkingMemory<br/>Objective, blockers]
|
|
179
|
+
LTM[LongTermMemory<br/>Summarized insights]
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
TC --> WC
|
|
183
|
+
WC --> RM
|
|
184
|
+
WC --> EM
|
|
185
|
+
WC --> EPM
|
|
186
|
+
WC --> WM
|
|
187
|
+
WC --> RD
|
|
188
|
+
RD -.->|Soft dedup| TC
|
|
189
|
+
|
|
190
|
+
UI --> RC
|
|
191
|
+
RC --> RM
|
|
192
|
+
RC --> EM
|
|
193
|
+
RC --> EPM
|
|
194
|
+
RC --> WM
|
|
195
|
+
RC -.->|Optional| LTM
|
|
196
|
+
|
|
197
|
+
CC --> EPM
|
|
198
|
+
CC --> LTM
|
|
199
|
+
CC --> EM
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Memory Layers
|
|
203
|
+
|
|
204
|
+
| Layer | Purpose | Written By |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| **RepoMemory** | File contents, structure, symbols | `read_file` |
|
|
207
|
+
| **ExecutionMemory** | Command history and results | `run_command` |
|
|
208
|
+
| **EpisodicMemory** | Edits, decisions, findings | `edit_file`, `write_file` |
|
|
209
|
+
| **WorkingMemory** | Current objective and blockers | `set_objective` |
|
|
210
|
+
| **LongTermMemory** | Summarized insights | Compression |
|
|
211
|
+
|
|
212
|
+
### Retrieval Priority
|
|
213
|
+
|
|
214
|
+
The `RetrievalController` builds context blocks in **strict priority order**, ensuring the most critical information is always included:
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
🥇 Current objective (always included)
|
|
218
|
+
🥈 Working memory findings + blockers
|
|
219
|
+
🥉 Top repo memory hits (ranked by importance × relevance)
|
|
220
|
+
Recent command execution results
|
|
221
|
+
Critical episodic findings
|
|
222
|
+
Long-term memory summaries (optional)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## 📦 Installation
|
|
228
|
+
|
|
229
|
+
**Stable release** (recommended):
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
pip install kryth
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Development version**:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
git clone https://github.com/navadeep0508/KRYTH-OS.git
|
|
239
|
+
cd kryth
|
|
240
|
+
pip install -e ".[dev]"
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 🧪 Development
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Set up environment
|
|
249
|
+
python -m venv venv
|
|
250
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
251
|
+
pip install -e ".[dev]"
|
|
252
|
+
|
|
253
|
+
# Install pre-commit hooks
|
|
254
|
+
pre-commit install
|
|
255
|
+
|
|
256
|
+
# Run tests
|
|
257
|
+
pytest
|
|
258
|
+
|
|
259
|
+
# Code quality
|
|
260
|
+
ruff check src/
|
|
261
|
+
mypy src/
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## 🗺️ Roadmap
|
|
267
|
+
|
|
268
|
+
- [x] Core memory controllers (Write, Retrieve, Deduplicate, Compress)
|
|
269
|
+
- [x] Token-capped context retrieval
|
|
270
|
+
- [ ] Integration with popular agent frameworks (LangChain, CrewAI)
|
|
271
|
+
- [ ] Persistent storage backends (SQLite, PostgreSQL, Redis)
|
|
272
|
+
- [ ] Async-first API
|
|
273
|
+
- [ ] Interactive memory dashboard
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 🤝 Contributing
|
|
278
|
+
|
|
279
|
+
Contributions are what make the open source community such an amazing place! Any contributions you make are **greatly appreciated**.
|
|
280
|
+
|
|
281
|
+
- 🐛 Found a bug? [Open an issue](https://github.com/navadeep0508/KRYTH-OS/issues)
|
|
282
|
+
- 💡 Have an idea? [Start a discussion](https://github.com/navadeep0508/KRYTH-OS/discussions)
|
|
283
|
+
- 🔧 Want to contribute? See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 📄 License
|
|
288
|
+
|
|
289
|
+
Distributed under the **MIT License**. See [`LICENSE`](LICENSE) for more information.
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
<div align="center">
|
|
294
|
+
<p>
|
|
295
|
+
Made with ❤️ by <a href="https://github.com/navadeep0508">navadeep0508</a>
|
|
296
|
+
</p>
|
|
297
|
+
<p>
|
|
298
|
+
<a href="https://github.com/navadeep0508/KRYTH-OS">GitHub</a> •
|
|
299
|
+
<a href="https://pypi.org/project/kryth/">PyPI</a> •
|
|
300
|
+
<a href="CHANGELOG.md">Changelog</a> •
|
|
301
|
+
<a href="CODE_OF_CONDUCT.md">Code of Conduct</a>
|
|
302
|
+
</p>
|
|
303
|
+
</div>
|
kryth-0.1.0/README.md
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<br/>
|
|
3
|
+
<h1>🧠 Kryth</h1>
|
|
4
|
+
<p><strong>AI Agent Memory Framework — Structured memory layers for LLM-based agents</strong></p>
|
|
5
|
+
|
|
6
|
+
<br/>
|
|
7
|
+
|
|
8
|
+
<!-- Badges -->
|
|
9
|
+
<p>
|
|
10
|
+
<a href="https://pypi.org/project/kryth/">
|
|
11
|
+
<img src="https://img.shields.io/pypi/v/kryth?style=for-the-badge&logo=pypi&logoColor=white&color=blueviolet" alt="PyPI Version"/>
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://pypi.org/project/kryth/">
|
|
14
|
+
<img src="https://img.shields.io/pypi/dm/kryth?style=for-the-badge&logo=python&logoColor=white&color=blue" alt="PyPI Downloads"/>
|
|
15
|
+
</a>
|
|
16
|
+
<a href="LICENSE">
|
|
17
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg?style=for-the-badge" alt="MIT License"/>
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://github.com/navadeep0508/KRYTH-OS">
|
|
20
|
+
<img src="https://img.shields.io/badge/python-3.10%2B-blue?style=for-the-badge&logo=python&logoColor=white" alt="Python 3.10+"/>
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://github.com/navadeep0508/KRYTH-OS/actions">
|
|
23
|
+
<img src="https://img.shields.io/badge/code%20style-ruff-261230?style=for-the-badge&logo=ruff&logoColor=white" alt="Ruff"/>
|
|
24
|
+
</a>
|
|
25
|
+
<a href="CONTRIBUTING.md">
|
|
26
|
+
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge&logo=github" alt="PRs Welcome"/>
|
|
27
|
+
</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<br/>
|
|
31
|
+
|
|
32
|
+
<!-- Quick links -->
|
|
33
|
+
<p>
|
|
34
|
+
<a href="#-quick-start">🚀 Quick Start</a> •
|
|
35
|
+
<a href="#-features">✨ Features</a> •
|
|
36
|
+
<a href="#-architecture">🏗️ Architecture</a> •
|
|
37
|
+
<a href="#-installation">📦 Installation</a> •
|
|
38
|
+
<a href="#-contributing">🤝 Contributing</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<br/>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 💡 Why Kryth?
|
|
47
|
+
|
|
48
|
+
LLM-based agents need **memory** — but not just any memory. They need structured, token-efficient, deduplicated memory that fits inside a context window. Kryth gives you:
|
|
49
|
+
|
|
50
|
+
| Without Kryth | With Kryth |
|
|
51
|
+
|---|---|
|
|
52
|
+
| ❌ Bloated, unstructured context | ✅ Token-capped retrieval (~800 tokens) |
|
|
53
|
+
| ❌ Duplicate reads and redundant commands | ✅ Smart duplicate detection & summarization |
|
|
54
|
+
| ❌ Runaway memory growth | ✅ Automatic compression with configurable limits |
|
|
55
|
+
| ❌ Ad-hoc memory management | ✅ Clean, modular controller architecture |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🚀 Quick Start
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from kryth import WriteController, RetrievalController, compute_state_hash
|
|
63
|
+
|
|
64
|
+
# Compute a unique state hash for your project
|
|
65
|
+
state_hash = compute_state_hash(cwd="/path/to/project")
|
|
66
|
+
|
|
67
|
+
# Route knowledge from tool calls into memory
|
|
68
|
+
write_ctrl = WriteController()
|
|
69
|
+
write_ctrl.on_tool_result(
|
|
70
|
+
tool_name="read_file",
|
|
71
|
+
args={"path": "main.py"},
|
|
72
|
+
result="file contents...",
|
|
73
|
+
error=False,
|
|
74
|
+
session_id=1,
|
|
75
|
+
memory_manager=memory_manager, # Your MemoryManager instance
|
|
76
|
+
turn=3,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Retrieve only the most relevant memories for LLM context
|
|
80
|
+
retrieval_ctrl = RetrievalController()
|
|
81
|
+
context_block = retrieval_ctrl.build_prompt_block(
|
|
82
|
+
memory_manager=memory_manager,
|
|
83
|
+
session_id=1,
|
|
84
|
+
user_input="What does the auth module do?",
|
|
85
|
+
)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
> 💡 **Tip:** Kryth is designed to integrate with your existing `MemoryManager`. See the [full documentation](#) for setup details.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## ✨ Features
|
|
93
|
+
|
|
94
|
+
<table>
|
|
95
|
+
<tr>
|
|
96
|
+
<td width="50%">
|
|
97
|
+
<h3>🧩 <strong>Modular Architecture</strong></h3>
|
|
98
|
+
<p>Each memory concern — writing, retrieval, deduplication, compression — is isolated in its own controller. Mix and match what you need.</p>
|
|
99
|
+
</td>
|
|
100
|
+
<td width="50%">
|
|
101
|
+
<h3>📏 <strong>Token-Aware Retrieval</strong></h3>
|
|
102
|
+
<p>Context injection is <strong>always capped at ~800 tokens</strong>, ensuring your LLM stays focused and never exceeds context limits.</p>
|
|
103
|
+
</td>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<td width="50%">
|
|
107
|
+
<h3>🎯 <strong>Relevance Ranking</strong></h3>
|
|
108
|
+
<p>Memories are scored and ranked by importance × query relevance, so only the most pertinent information makes it into the prompt.</p>
|
|
109
|
+
</td>
|
|
110
|
+
<td width="50%">
|
|
111
|
+
<h3>🔍 <strong>Smart Duplicate Detection</strong></h3>
|
|
112
|
+
<p>Detects duplicate file reads and command executions — then returns a <em>summary</em> instead of hard-blocking. Never repeat work.</p>
|
|
113
|
+
</td>
|
|
114
|
+
</tr>
|
|
115
|
+
<tr>
|
|
116
|
+
<td width="50%">
|
|
117
|
+
<h3>🧹 <strong>Automatic Compression</strong></h3>
|
|
118
|
+
<p>Prevents unbounded memory growth with configurable limits per memory layer. Set it and forget it.</p>
|
|
119
|
+
</td>
|
|
120
|
+
<td width="50%">
|
|
121
|
+
<h3>🔐 <strong>State Hashing</strong></h3>
|
|
122
|
+
<p>Robust duplicate command detection using git diff, file hashes, and environment variables. Know when state has genuinely changed.</p>
|
|
123
|
+
</td>
|
|
124
|
+
</tr>
|
|
125
|
+
</table>
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🏗️ Architecture
|
|
130
|
+
|
|
131
|
+
Kryth organizes memory into a clean, layered architecture:
|
|
132
|
+
|
|
133
|
+
```mermaid
|
|
134
|
+
flowchart TB
|
|
135
|
+
subgraph Input["📥 Inputs"]
|
|
136
|
+
TC[Tool Calls]
|
|
137
|
+
UI[User Input]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
subgraph Controllers["🎮 Controllers"]
|
|
141
|
+
WC[WriteController]
|
|
142
|
+
RD[DuplicateDetector]
|
|
143
|
+
RC[RetrievalController]
|
|
144
|
+
CC[CompressionController]
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
subgraph Memory["💾 Memory Layers"]
|
|
148
|
+
RM[RepoMemory<br/>File contents, symbols]
|
|
149
|
+
EM[ExecutionMemory<br/>Command history]
|
|
150
|
+
EPM[EpisodicMemory<br/>Edits, decisions]
|
|
151
|
+
WM[WorkingMemory<br/>Objective, blockers]
|
|
152
|
+
LTM[LongTermMemory<br/>Summarized insights]
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
TC --> WC
|
|
156
|
+
WC --> RM
|
|
157
|
+
WC --> EM
|
|
158
|
+
WC --> EPM
|
|
159
|
+
WC --> WM
|
|
160
|
+
WC --> RD
|
|
161
|
+
RD -.->|Soft dedup| TC
|
|
162
|
+
|
|
163
|
+
UI --> RC
|
|
164
|
+
RC --> RM
|
|
165
|
+
RC --> EM
|
|
166
|
+
RC --> EPM
|
|
167
|
+
RC --> WM
|
|
168
|
+
RC -.->|Optional| LTM
|
|
169
|
+
|
|
170
|
+
CC --> EPM
|
|
171
|
+
CC --> LTM
|
|
172
|
+
CC --> EM
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Memory Layers
|
|
176
|
+
|
|
177
|
+
| Layer | Purpose | Written By |
|
|
178
|
+
|---|---|---|
|
|
179
|
+
| **RepoMemory** | File contents, structure, symbols | `read_file` |
|
|
180
|
+
| **ExecutionMemory** | Command history and results | `run_command` |
|
|
181
|
+
| **EpisodicMemory** | Edits, decisions, findings | `edit_file`, `write_file` |
|
|
182
|
+
| **WorkingMemory** | Current objective and blockers | `set_objective` |
|
|
183
|
+
| **LongTermMemory** | Summarized insights | Compression |
|
|
184
|
+
|
|
185
|
+
### Retrieval Priority
|
|
186
|
+
|
|
187
|
+
The `RetrievalController` builds context blocks in **strict priority order**, ensuring the most critical information is always included:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
🥇 Current objective (always included)
|
|
191
|
+
🥈 Working memory findings + blockers
|
|
192
|
+
🥉 Top repo memory hits (ranked by importance × relevance)
|
|
193
|
+
Recent command execution results
|
|
194
|
+
Critical episodic findings
|
|
195
|
+
Long-term memory summaries (optional)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 📦 Installation
|
|
201
|
+
|
|
202
|
+
**Stable release** (recommended):
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
pip install kryth
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Development version**:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
git clone https://github.com/navadeep0508/KRYTH-OS.git
|
|
212
|
+
cd kryth
|
|
213
|
+
pip install -e ".[dev]"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 🧪 Development
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Set up environment
|
|
222
|
+
python -m venv venv
|
|
223
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
224
|
+
pip install -e ".[dev]"
|
|
225
|
+
|
|
226
|
+
# Install pre-commit hooks
|
|
227
|
+
pre-commit install
|
|
228
|
+
|
|
229
|
+
# Run tests
|
|
230
|
+
pytest
|
|
231
|
+
|
|
232
|
+
# Code quality
|
|
233
|
+
ruff check src/
|
|
234
|
+
mypy src/
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 🗺️ Roadmap
|
|
240
|
+
|
|
241
|
+
- [x] Core memory controllers (Write, Retrieve, Deduplicate, Compress)
|
|
242
|
+
- [x] Token-capped context retrieval
|
|
243
|
+
- [ ] Integration with popular agent frameworks (LangChain, CrewAI)
|
|
244
|
+
- [ ] Persistent storage backends (SQLite, PostgreSQL, Redis)
|
|
245
|
+
- [ ] Async-first API
|
|
246
|
+
- [ ] Interactive memory dashboard
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 🤝 Contributing
|
|
251
|
+
|
|
252
|
+
Contributions are what make the open source community such an amazing place! Any contributions you make are **greatly appreciated**.
|
|
253
|
+
|
|
254
|
+
- 🐛 Found a bug? [Open an issue](https://github.com/navadeep0508/KRYTH-OS/issues)
|
|
255
|
+
- 💡 Have an idea? [Start a discussion](https://github.com/navadeep0508/KRYTH-OS/discussions)
|
|
256
|
+
- 🔧 Want to contribute? See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## 📄 License
|
|
261
|
+
|
|
262
|
+
Distributed under the **MIT License**. See [`LICENSE`](LICENSE) for more information.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
<div align="center">
|
|
267
|
+
<p>
|
|
268
|
+
Made with ❤️ by <a href="https://github.com/navadeep0508">navadeep0508</a>
|
|
269
|
+
</p>
|
|
270
|
+
<p>
|
|
271
|
+
<a href="https://github.com/navadeep0508/KRYTH-OS">GitHub</a> •
|
|
272
|
+
<a href="https://pypi.org/project/kryth/">PyPI</a> •
|
|
273
|
+
<a href="CHANGELOG.md">Changelog</a> •
|
|
274
|
+
<a href="CODE_OF_CONDUCT.md">Code of Conduct</a>
|
|
275
|
+
</p>
|
|
276
|
+
</div>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "kryth"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "AI Agent Memory Framework — structured memory layers for LLM-based agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
keywords = ["ai", "agent", "memory", "llm", "framework"]
|
|
13
|
+
|
|
14
|
+
authors = [
|
|
15
|
+
{name = "Kryth Contributors"},
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
dependencies = []
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"pytest>=8.0",
|
|
35
|
+
"pytest-cov>=5.0",
|
|
36
|
+
"mypy>=1.10",
|
|
37
|
+
"ruff>=0.7",
|
|
38
|
+
"pre-commit>=4.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
where = ["src"]
|
|
43
|
+
include = ["kryth*"]
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.package-dir]
|
|
46
|
+
"" = "src"
|
|
47
|
+
|
|
48
|
+
[tool.mypy]
|
|
49
|
+
python_version = "3.10"
|
|
50
|
+
strict = true
|
|
51
|
+
ignore_missing_imports = true
|
|
52
|
+
|
|
53
|
+
[tool.ruff]
|
|
54
|
+
target-version = "py310"
|
|
55
|
+
line-length = 100
|
|
56
|
+
|
|
57
|
+
[tool.ruff.lint]
|
|
58
|
+
select = ["E", "F", "I", "N", "W", "UP", "ANN"]
|
|
59
|
+
|
|
60
|
+
[tool.pytest.ini_options]
|
|
61
|
+
testpaths = ["tests"]
|
|
62
|
+
python_files = ["test_*.py"]
|
kryth-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Kryth — AI Agent Memory Framework.
|
|
2
|
+
|
|
3
|
+
Kryth provides structured memory layers for LLM-based agents, including
|
|
4
|
+
write, retrieval, duplicate detection, and compression controllers.
|
|
5
|
+
|
|
6
|
+
Typical usage::
|
|
7
|
+
|
|
8
|
+
from kryth.agent.memory.controllers import (
|
|
9
|
+
WriteController,
|
|
10
|
+
RetrievalController,
|
|
11
|
+
DuplicateDetector,
|
|
12
|
+
CompressionController,
|
|
13
|
+
compute_state_hash,
|
|
14
|
+
)
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from kryth.agent.memory.controllers import (
|
|
18
|
+
CompressionController,
|
|
19
|
+
DuplicateDetector,
|
|
20
|
+
RetrievalController,
|
|
21
|
+
WriteController,
|
|
22
|
+
compute_state_hash,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"WriteController",
|
|
27
|
+
"RetrievalController",
|
|
28
|
+
"DuplicateDetector",
|
|
29
|
+
"CompressionController",
|
|
30
|
+
"compute_state_hash",
|
|
31
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Agent memory subpackage for Kryth."""
|