This project has been archived by its maintainers, and is no longer receiving any updates.
autourgos-semantic-memory
TF-IDF keyword retrieval memory for Autourgos agents. Combines a short-term message buffer with a TF-IDF keyword index — when the agent asks for context, relevant past messages are retrieved by keyword similarity and prepended, even if they fell outside the short-term window. Zero external dependencies; no embeddings, no vector database required.
from autourgos_semantic_memory import KeywordMemory
from autourgos_agent import Agent
from autourgos_openaichat import OpenAIChatModel
my_llm = OpenAIChatModel(model="gpt-4o-mini")
memory = KeywordMemory(top_k=3)
agent = Agent(llm=my_llm, memory=memory)
Features
KeywordMemory— dual-store: recent messages in a ring buffer + all messages indexed for TF-IDF retrievalKeywordRetriever— standalone TF-IDF retriever, usable on its own or plugged intoKeywordMemory- Zero external dependencies — cosine similarity over TF-IDF weights, computed at query time
- Bounded index — optional
max_documentsFIFO eviction keeps retrieval fast on long-running agents
Table of Contents
Install
pip install autourgos-semantic-memory
Classes
KeywordMemory
from autourgos_semantic_memory import KeywordMemory
from autourgos_agent import Agent
from autourgos_openaichat import OpenAIChatModel
my_llm = OpenAIChatModel(model="gpt-4o-mini")
memory = KeywordMemory(top_k=3) # surface top 3 relevant past messages
agent = Agent(llm=my_llm, memory=memory)
agent.invoke("The server is running on port 8080")
agent.invoke("The database password is hunter2")
# ... many more messages ...
agent.invoke("What port is the server on?")
# → retrieves the port message from the keyword index even if it left the buffer
KeywordRetriever
Standalone TF-IDF retriever. Plug it into KeywordMemory or use directly with your own memory:
from autourgos_semantic_memory import KeywordRetriever
from autourgos_memory import Document
retriever = KeywordRetriever()
retriever.add_document(Document(content="Paris is the capital of France.", source="wiki"))
retriever.add_document(Document(content="Berlin is the capital of Germany.", source="wiki"))
results = retriever.retrieve("What is the capital of France?", top_k=1)
print(results[0].content)
# → "Paris is the capital of France."
Custom Short-Term Store
from autourgos_semantic_memory import KeywordMemory
from autourgos_local_memory import SQLiteMemory
# Use SQLite as the short-term buffer (survives restarts)
memory = KeywordMemory(
short_term=SQLiteMemory(db_path="./data/agent.db"),
top_k=5,
)
Parameters
KeywordMemory
| Parameter | Type | Default | Description |
|---|---|---|---|
short_term |
BaseMemory | RuntimeShortTermMemory(10) |
Short-term buffer shown in full. |
retriever |
BaseRetriever | KeywordRetriever() |
Retriever for past context. |
top_k |
int | 3 |
Max relevant past messages to surface. |
max_documents |
Optional[int] | None |
Max documents kept in the TF-IDF index. When set, the oldest document is dropped (FIFO) once the count would exceed this. None keeps the index unbounded. |
KeywordRetriever
| Parameter | Type | Default | Description |
|---|---|---|---|
max_documents |
Optional[int] | None |
Same FIFO eviction behavior as above, for standalone use. |
How TF-IDF Works Here
- Every message is tokenized (lowercase alphanumeric) and indexed.
- IDF weights are computed at query time — so scores stay accurate as more messages are added.
- Cosine similarity ranks results. Only messages with score > 0 are returned.
- Back-compat aliases:
SimpleSemanticRetriever = KeywordRetriever,HierarchicalSemanticMemory = KeywordMemory.
Cost note: retrieve() recomputes TF-IDF weights across the whole corpus on each call where the index
changed since the last query. This is fine for small-to-medium message stores, but the per-query cost grows
with corpus size. If you expect a long-running agent to accumulate many thousands of documents, set
max_documents to cap the index size and keep retrieval fast.
License
Apache License 2.0, Copyright (c) 2026 Jitin Kumar Sengar
Metadata
Release files for autourgos-semantic-memory 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| autourgos_semantic_memory-2.2.0.tar.gz | 18.1 kB | Without provenance | Details for autourgos_semantic_memory-2.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| autourgos_semantic_memory-2.2.0-py3-none-any.whl | Python 3 | none | any | Details for autourgos_semantic_memory-2.2.0-py3-none-any.whl |
Total release size: 33.1 kB
Release files / autourgos_semantic_memory-2.2.0.tar.gz
| Download URL | autourgos_semantic_memory-2.2.0.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93a5e7e24b085bfe1ea85b564e0fb5ceb0574498d5048431c652960252adcd74
|
|
BLAKE2b-256 checksum How to use checksums |
00e0badaca4e4314df246b0f44d49a392aa9573a98f2c0cff9d2a0dbd4cd425a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / autourgos_semantic_memory-2.2.0-py3-none-any.whl
| Download URL | autourgos_semantic_memory-2.2.0-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5bbe2d842611b4fc22aac3c605810b8d14cbf4d0a50b050cdd69422ce0ea2ba6
|
|
BLAKE2b-256 checksum How to use checksums |
9b0176ab6f764846dbc837103a614ac541a1967177ec8660f1f8bf61c211596e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Security for autourgos-semantic-memory 2.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.