Core component for Agent Memory and Task Management
Project description
AgenticCache
This is a Cache file escpecially for Agentic approaches .
agent_core
A Python package for advanced memory management and task queuing, designed for agentic systems, AI development, and high-concurrency applications. It includes hierarchical memory, caching mechanisms, and a priority-based task queue to handle complex, stateful workflows efficiently.
Features
- Hierarchical Memory: Multi-level storage (short-term, working, long-term, context) with prefetching, indexing, and automatic consolidation.
- Caching Systems: LRU cache, FIFO buffers, and TTL-based result caching with background expiration.
- Task Queuing: Priority queue for async coroutines with stats tracking and thread safety.
- Thread-Safe: All operations use reentrant locks for concurrent access.
- Configurable: Extensive config options for capacities, TTLs, thresholds, and more.
- Extensible: Easy to integrate into agent-based systems for memory persistence and event handling.
Installation
Install via pip:
pip install agentic_cache
or from source:
git clone https://github.com/Abinayasankar-co/AgenticCache.git
cd agentic_cache
python setup.py install
Quick Start
import logging
from agent_core import HierarchicalMemory, TaskQueue
# Setup logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Configure and initialize memory
config = {
"short_term_capacity": 200,
"history_size": 500,
"result_cache_ttl": 7200,
"prefetch_enabled": True,
"prefetch_patterns": {"user_data": ["profile", "history"]}
}
memory = HierarchicalMemory(config)
# Store and retrieve data
memory.put("user_id", 12345, namespace="working", persistent=True)
value = memory.get("user_id") # Returns 12345
# Record an event
memory.record_event({"type": "login", "timestamp": time.time()})
# Initialize task queue
queue = TaskQueue(num_workers=3)
queue.start()
# Submit an async task (example coroutine)
async def example_coro(x):
await asyncio.sleep(1)
return x * 2
result = await queue.submit(example_coro, 10) # Returns 20
# Stop queue when done
queue.stop()
Documentation
See USAGE.md for detailed usage and API reference.
Contributing
Pull requests welcome! Please follow standard Python conventions.
License
Apache License
AgenticCache — Usage
This document explains how to install and use the AgenticCache package. It includes instructions for the CLI entry point and programmatic usage.
Install (editable/development)
From the project root (where setup.py lives), install in editable mode:
python -m pip install -e .
To build a wheel and sdist:
python -m pip install build; python -m build
CLI
A console script agentic-cache is provided. After installing the package, run:
agentic-cache --help
Examples:
- Put a key into memory:
agentic-cache memory --put name Alice --namespace working
- Get a key from memory:
agentic-cache memory --get name --namespace working
- Submit a simple numeric task to the queue:
agentic-cache queue --submit 5 --priority 2
Notes: the CLI uses the main() function in AgenticCache/cli.py which instantiates HierarchicalMemory and TaskQueue using default parameters.
Programmatic usage
Import and use the classes directly:
from AgenticCache.memory import HierarchicalMemory
from AgenticCache.task_queue import TaskQueue
# create memory and queue
memory = HierarchicalMemory({
"short_term_capacity": 100,
"history_size": 500,
"result_cache_ttl": 3600,
"prefetch_enabled": True,
"prefetch_patterns": {"user_id": ["profile"]}
})
queue = TaskQueue(num_workers=3)
# store and retrieve
memory.put("key", "value", namespace="working")
print(memory.get("key", namespace="working"))
# submit a coroutine task
async def my_task(x):
await asyncio.sleep(1)
return x * 2
import asyncio
result = asyncio.run(queue.submit(my_task, 7))
print(result)
Notes and caveats
- The package requires Python 3.8+. Ensure your environment meets that requirement.
- If you installed editable (
-e), changes in the source are available immediately. - The CLI and examples assume default constructors from the package files; tune parameters to your needs.
If you need a pyproject.toml or specific dependency pins, add them to the repo or ask me to create them for you.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentic_cache-0.1.0.tar.gz.
File metadata
- Download URL: agentic_cache-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0991fda5dfd964b03c8478f48281fab65837f7c65628120dc6fb459eb039b7f2
|
|
| MD5 |
961d38e0407a26fc8cc8f0dc99b88c0a
|
|
| BLAKE2b-256 |
eb39701ce74b783416adca3a3719c9b550470627c214e8f094f2a76492cc1597
|
File details
Details for the file agentic_cache-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentic_cache-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6925f08738d6f435ba3821cf19c6d5894e870b5b13c266f4f922ae475b7708f
|
|
| MD5 |
95074cf5310b870c1caf9952badf7426
|
|
| BLAKE2b-256 |
b270d324d933f0ff05998f16bf3969d820f95cc037ef09c6430468f276916544
|