asterix-agent 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Aditya Sarade
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,454 @@
1
+ Metadata-Version: 2.4
2
+ Name: asterix-agent
3
+ Version: 0.1.0
4
+ Summary: Stateful AI agents with editable memory blocks and persistent storage
5
+ Author-email: Aditya Sarade <aditya.sarade2003@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/adityasarade/Asterix
8
+ Project-URL: Documentation, https://github.com/adityasarade/Asterix#readme
9
+ Project-URL: Repository, https://github.com/adityasarade/Asterix
10
+ Project-URL: Issues, https://github.com/adityasarade/Asterix/issues
11
+ Keywords: ai,agents,memory,llm,qdrant,stateful
12
+ Classifier: Development Status :: 2 - Pre-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.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: openai>=1.30.0
25
+ Requires-Dist: groq>=0.8.0
26
+ Requires-Dist: qdrant-client>=1.7.0
27
+ Requires-Dist: sentence-transformers>=2.2.2
28
+ Requires-Dist: tiktoken>=0.5.0
29
+ Requires-Dist: pyyaml>=6.0.1
30
+ Requires-Dist: python-dotenv>=1.0.0
31
+ Requires-Dist: pydantic>=2.5.0
32
+ Requires-Dist: httpx>=0.25.0
33
+ Requires-Dist: numpy>=1.24.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
36
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
37
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
38
+ Requires-Dist: black>=23.0.0; extra == "dev"
39
+ Requires-Dist: isort>=5.12.0; extra == "dev"
40
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # Asterix!
44
+
45
+ **Stateful AI agents with editable memory blocks and persistent storage.**
46
+
47
+ > **โš ๏ธ EARLY DEVELOPMENT - NOT READY FOR PRODUCTION YET**
48
+ >
49
+ > This library is under active development.
50
+
51
+ Asterix is a lightweight Python library for building AI agents that can remember, learn, and persist their state across sessions. No servers required - just `pip install` and start building.
52
+
53
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
54
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
+
56
+ ---
57
+
58
+ ## โœจ Features
59
+
60
+ - **๐Ÿง  Editable Memory Blocks** - Agents can read and write their own memory via built-in tools
61
+ - **๐Ÿ’พ Persistent Storage** - State saves across sessions (JSON/SQLite backends)
62
+ - **๐Ÿ” Semantic Search** - Qdrant Cloud integration for long-term memory retrieval
63
+ - **๐Ÿ› ๏ธ Tool System** - Easy decorator pattern for custom capabilities
64
+ - **๐Ÿ”„ Multi-Model Support** - Works with Groq, OpenAI, and extensible to others
65
+ - **๐Ÿ“ฆ No Server Required** - Pure Python library, runs anywhere
66
+
67
+ ---
68
+
69
+ ## ๐Ÿš€ Quick Start
70
+
71
+ ### Installation
72
+
73
+ ```bash
74
+ pip install asterix-agent
75
+ ```
76
+
77
+ Or with UV (faster):
78
+ ```bash
79
+ uv pip install asterix-agent
80
+ ```
81
+
82
+ ### Basic Usage
83
+
84
+ ```python
85
+ from asterix import Agent, BlockConfig
86
+
87
+ # Create an agent with custom memory blocks
88
+ agent = Agent(
89
+ blocks={
90
+ "task": BlockConfig(size=1500, priority=1),
91
+ "notes": BlockConfig(size=1000, priority=2)
92
+ },
93
+ model="groq/llama-3.3-70b-versatile"
94
+ )
95
+
96
+ # Chat with your agent
97
+ response = agent.chat("Hello! Remember that I prefer Python over JavaScript.")
98
+ print(response)
99
+
100
+ # Agent automatically updates its memory
101
+ # Memory persists across conversations
102
+ ```
103
+
104
+ ### Add Custom Tools
105
+
106
+ ```python
107
+ @agent.tool(name="read_file", description="Read a file from disk")
108
+ def read_file(filepath: str) -> str:
109
+ with open(filepath, 'r') as f:
110
+ return f.read()
111
+
112
+ # Now your agent can read files
113
+ response = agent.chat("Read config.yaml and summarize the settings")
114
+ ```
115
+
116
+ ### Save & Load State
117
+
118
+ ```python
119
+ # Save agent state
120
+ agent.save_state()
121
+
122
+ # Later session - load previous state
123
+ agent = Agent.load_state("agent_id")
124
+ agent.chat("What were we discussing?") # Remembers everything!
125
+ ```
126
+
127
+ ---
128
+
129
+ ## ๐Ÿ“š Configuration
130
+
131
+ ### Environment Variables
132
+
133
+ Create a `.env` file in your project root:
134
+
135
+ ```bash
136
+ # LLM Provider (at least one required)
137
+ GROQ_API_KEY=your-groq-api-key
138
+ OPENAI_API_KEY=your-openai-api-key
139
+
140
+ # Vector Storage (required)
141
+ QDRANT_URL=https://your-cluster.cloud.qdrant.io:6333
142
+ QDRANT_API_KEY=your-qdrant-api-key
143
+
144
+ # Optional
145
+ ASTERIX_STATE_DIR=./agent_states
146
+ ASTERIX_LOG_LEVEL=INFO
147
+ ```
148
+
149
+ ### YAML Configuration (Optional)
150
+
151
+ ```yaml
152
+ # agent_config.yaml
153
+ agent:
154
+ model: "groq/llama-3.3-70b-versatile"
155
+ temperature: 0.1
156
+ max_tokens: 1000
157
+ max_heartbeat_steps: 10
158
+
159
+ blocks:
160
+ task:
161
+ size: 1500
162
+ priority: 1
163
+ description: "Current task and progress"
164
+
165
+ notes:
166
+ size: 1000
167
+ priority: 2
168
+ description: "Important notes and reminders"
169
+
170
+ storage:
171
+ qdrant_url: "${QDRANT_URL}"
172
+ qdrant_api_key: "${QDRANT_API_KEY}"
173
+ state_backend: "json"
174
+ state_dir: "./agent_states"
175
+ ```
176
+
177
+ Load from YAML:
178
+ ```python
179
+ agent = Agent.from_yaml("agent_config.yaml")
180
+ ```
181
+
182
+ ---
183
+
184
+ ## ๐Ÿง  Memory System
185
+
186
+ ### Built-in Memory Tools
187
+
188
+ Agents have 5 built-in tools for managing their memory:
189
+
190
+ 1. **`core_memory_append`** - Add content to a memory block
191
+ 2. **`core_memory_replace`** - Replace content in a memory block
192
+ 3. **`archival_memory_insert`** - Store information in Qdrant for long-term retrieval
193
+ 4. **`archival_memory_search`** - Search archived memories semantically
194
+ 5. **`conversation_search`** - Search conversation history
195
+
196
+ These tools are called automatically by the agent when needed.
197
+
198
+ ### Memory Blocks
199
+
200
+ Configure memory blocks with custom sizes and priorities:
201
+
202
+ ```python
203
+ blocks = {
204
+ "task": BlockConfig(
205
+ size=2000, # Max tokens before eviction
206
+ priority=1, # Lower = evicted first
207
+ description="Current task context"
208
+ ),
209
+ "user_prefs": BlockConfig(
210
+ size=500,
211
+ priority=5, # High priority = rarely evicted
212
+ description="User preferences and settings"
213
+ )
214
+ }
215
+ ```
216
+
217
+ ### Automatic Memory Management
218
+
219
+ When a block exceeds its token limit:
220
+ 1. Content is summarized by LLM
221
+ 2. Full content archived in Qdrant
222
+ 3. Block replaced with summary
223
+ 4. Original retrievable via semantic search
224
+
225
+ ---
226
+
227
+ ## ๐Ÿ› ๏ธ Custom Tools
228
+
229
+ Register custom tools using the decorator pattern:
230
+
231
+ ```python
232
+ from asterix import Agent
233
+
234
+ agent = Agent(...)
235
+
236
+ @agent.tool(
237
+ name="execute_shell",
238
+ description="Run a shell command and return output"
239
+ )
240
+ def execute_shell(command: str) -> str:
241
+ import subprocess
242
+ result = subprocess.run(command, shell=True, capture_output=True, text=True)
243
+ return result.stdout
244
+
245
+ @agent.tool(name="search_web")
246
+ def search_web(query: str) -> str:
247
+ # Your web search implementation
248
+ return "Search results..."
249
+
250
+ # Agent can now use these tools
251
+ response = agent.chat("List all Python files in the current directory")
252
+ ```
253
+
254
+ ---
255
+
256
+ ## ๐Ÿ’พ State Persistence
257
+
258
+ ### Save & Load
259
+
260
+ ```python
261
+ # Save agent state to disk
262
+ agent.save_state() # Saves to ./agent_states/{agent_id}.json
263
+
264
+ # Load from disk
265
+ agent = Agent.load_state("agent_id")
266
+
267
+ # Custom state directory
268
+ agent = Agent(..., state_dir="./my_agents")
269
+ agent.save_state()
270
+ ```
271
+
272
+ ### State Backends
273
+
274
+ ```python
275
+ # JSON (default)
276
+ agent = Agent(..., state_backend="json")
277
+
278
+ # SQLite (better for many agents)
279
+ agent = Agent(..., state_backend="sqlite", state_db="agents.db")
280
+
281
+ # Custom backend
282
+ from asterix.storage import StateBackend
283
+
284
+ class RedisBackend(StateBackend):
285
+ def save(self, agent_id: str, state: dict): ...
286
+ def load(self, agent_id: str) -> dict: ...
287
+
288
+ agent = Agent(..., state_backend=RedisBackend())
289
+ ```
290
+
291
+ ---
292
+
293
+ ## ๐Ÿ“– Examples
294
+
295
+ ### CLI Agent with File Operations
296
+
297
+ ```python
298
+ from asterix import Agent, BlockConfig
299
+ import os
300
+
301
+ agent = Agent(
302
+ blocks={
303
+ "current_task": BlockConfig(size=2000, priority=1),
304
+ "file_context": BlockConfig(size=3000, priority=2)
305
+ },
306
+ model="groq/llama-3.3-70b-versatile"
307
+ )
308
+
309
+ @agent.tool(name="list_files")
310
+ def list_files(directory: str = ".") -> str:
311
+ files = os.listdir(directory)
312
+ return "\n".join(files)
313
+
314
+ @agent.tool(name="read_file")
315
+ def read_file(filepath: str) -> str:
316
+ with open(filepath, 'r') as f:
317
+ return f.read()
318
+
319
+ # Use the agent
320
+ agent.chat("List all Python files and review main.py for potential issues")
321
+ ```
322
+
323
+ ### Multi-Agent System
324
+
325
+ ```python
326
+ # Orchestrator agent
327
+ main_agent = Agent(
328
+ agent_id="orchestrator",
329
+ blocks={"plan": BlockConfig(size=1500)},
330
+ model="groq/llama-3.3-70b-versatile"
331
+ )
332
+
333
+ # Specialized agents
334
+ code_reviewer = Agent(
335
+ agent_id="reviewer",
336
+ blocks={"code": BlockConfig(size=3000)},
337
+ model="groq/llama-3.3-70b-versatile"
338
+ )
339
+
340
+ # Coordination
341
+ task = "Review auth.py for security issues"
342
+ plan = main_agent.chat(f"Break down: {task}")
343
+ review = code_reviewer.chat(f"Execute: {plan}")
344
+ summary = main_agent.chat(f"Summarize: {review}")
345
+ ```
346
+
347
+ ---
348
+
349
+ ## ๐Ÿ”ง Advanced Usage
350
+
351
+ ### Direct Memory Access
352
+
353
+ ```python
354
+ # Get all memory blocks
355
+ memory = agent.get_memory()
356
+ print(memory["task"])
357
+
358
+ # Update memory manually
359
+ agent.update_memory("task", "New content")
360
+
361
+ # Search archival memory
362
+ results = agent.search_archival("user preferences", k=5)
363
+ for result in results:
364
+ print(f"Score: {result.score}, Text: {result.summary}")
365
+ ```
366
+
367
+ ### Heartbeat Control (Advanced)
368
+
369
+ ```python
370
+ # Manual heartbeat loop control
371
+ controller = agent.create_heartbeat_controller()
372
+
373
+ for step in controller.run("Complex multi-step task"):
374
+ if step.needs_tool_execution:
375
+ # Custom tool execution logic
376
+ results = my_custom_executor(step.tool_calls)
377
+ controller.submit_tool_results(results)
378
+
379
+ elif step.is_complete:
380
+ response = step.get_response()
381
+ break
382
+ ```
383
+
384
+ ---
385
+
386
+ ## ๐Ÿงช Testing
387
+
388
+ ```bash
389
+ # Install dev dependencies
390
+ pip install -e ".[dev]"
391
+
392
+ # Run tests
393
+ pytest
394
+
395
+ # With coverage
396
+ pytest --cov=asterix --cov-report=html
397
+
398
+ # Run specific test
399
+ pytest tests/test_agent.py::test_memory_tools
400
+ ```
401
+
402
+ ---
403
+
404
+ ## ๐Ÿ“Š Project Status
405
+
406
+ **Current Version:** 0.1.0 (Alpha)
407
+
408
+ **Roadmap:**
409
+ - [x] Core agent implementation
410
+ - [x] Memory tools system
411
+ - [x] State persistence
412
+ - [x] Qdrant integration
413
+ - [ ] Enhanced tool registration
414
+ - [ ] Performance optimizations
415
+ - [ ] Extended documentation
416
+ - [ ] Tutorial series
417
+
418
+ ---
419
+
420
+ ## ๐Ÿค Contributing
421
+
422
+ Contributions are welcome! Please feel free to submit a Pull Request.
423
+
424
+ 1. Fork the repository
425
+ 2. Create your feature branch (`git checkout -b feature/your-feature`)
426
+ 3. Commit your changes (`git commit -m 'Add your feature'`)
427
+ 4. Push to the branch (`git push origin feature/your-feature`)
428
+ 5. Open a Pull Request
429
+
430
+ ---
431
+
432
+ ## ๐Ÿ“„ License
433
+
434
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
435
+
436
+ ---
437
+
438
+ ## ๐Ÿ™ Acknowledgments
439
+
440
+ - Built with [Groq](https://groq.com/) and [OpenAI](https://openai.com/)
441
+ - Vector storage by [Qdrant](https://qdrant.tech/)
442
+ - Inspired by [Letta](https://www.letta.com/)
443
+
444
+ ---
445
+
446
+ ## ๐Ÿ“ž Support
447
+
448
+ - **Issues:** [GitHub Issues](https://github.com/adityasarade/Asterix/issues)
449
+ - **Discussions:** [GitHub Discussions](https://github.com/adityasarade/Asterix/discussions)
450
+ - **Documentation:** [Full Docs](https://github.com/adityasarade/Asterix#readme)
451
+
452
+ ---
453
+
454
+ **So that everyone can build better agents without worrying about memory (Let's hope OpenAI doesn't make this library meaningless)**