Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

autourgos-local-memory

Framework: Autourgos Python License: Apache 2.0 Author Contributor Contributor

Disk-backed memory for Autourgos agents. Two classes — a JSON file store and a SQLite store. Memory survives process restarts and can be shared across sessions.

from autourgos_local_memory import SQLiteMemory
from autourgos_agent import Agent
from autourgos_openaichat import OpenAIChatModel

my_llm = OpenAIChatModel(model="gpt-4o-mini")
memory = SQLiteMemory(db_path="./data/agent.db", max_messages=500)
agent  = Agent(llm=my_llm, memory=memory)

Features

  • LocalShortTermMemory — JSON file, atomic write (tmp → replace), file-level lock
  • SQLiteMemory — WAL-mode SQLite, safer than JSON under concurrent writes, efficient for large histories
  • Both implement autourgos_memory.BaseMemory — drop-in for Agent(memory=...)
  • ":memory:" for an ephemeral in-process SQLite database (useful for tests)

Table of Contents


Install

pip install autourgos-local-memory

Classes

LocalShortTermMemory — JSON file

Persists messages as a JSON array. Safe for multiple threads. Uses atomic write (tmp → replace) and a file-level lock to prevent corruption.

from autourgos_local_memory import LocalShortTermMemory
from autourgos_agent import Agent
from autourgos_openaichat import OpenAIChatModel

my_llm = OpenAIChatModel(model="gpt-4o-mini")
memory = LocalShortTermMemory(file_path="./data/session.json", max_messages=50)
agent = Agent(llm=my_llm, memory=memory)
agent.invoke("Remember: my project deadline is Friday")

# Next session — history is loaded from disk automatically
agent2 = Agent(llm=my_llm, memory=LocalShortTermMemory(file_path="./data/session.json"))
agent2.invoke("When is my deadline?")
# → "Your project deadline is Friday."

SQLiteMemory — SQLite database

WAL-mode SQLite. Safer than JSON for concurrent writes — no external lock file needed. Efficient for large histories.

from autourgos_local_memory import SQLiteMemory

memory = SQLiteMemory(db_path="./data/agent.db", max_messages=500)  # None for unlimited
agent = Agent(llm=my_llm, memory=memory)

Use ":memory:" for an ephemeral in-process database:

memory = SQLiteMemory(db_path=":memory:")

SQLiteMemory supports the context-manager protocol, closing its connection automatically:

with SQLiteMemory(db_path="./data/agent.db") as memory:
    agent = Agent(llm=my_llm, memory=memory)
    agent.invoke("Hello!")
# connection is closed here automatically

Parameters

LocalShortTermMemory

Parameter Type Default Description
file_path str "./data/local_memory.json" Path to JSON file. Created if missing.
max_messages int 20 Rolling cap — oldest pruned on each write.
name str "local" Human-readable identifier.
lock_timeout_seconds float 10.0 Seconds to wait for file lock.

SQLiteMemory

Parameter Type Default Description
db_path str "./data/autourgos_memory.db" Path to .db file. ":memory:" for ephemeral.
max_messages int or None 500 Rolling cap. None = unlimited.
name str "sqlite" Human-readable identifier.

Known Limitations

LocalShortTermMemory's file lock is timeout-based (a lock file plus a wait deadline), not an OS-level advisory lock. If one process holds the lock longer than lock_timeout_seconds (e.g. due to slow disk I/O), a second process can end up believing the lock is stale and write concurrently, risking corruption. For high-concurrency multi-process use, prefer SQLiteMemory instead — it uses WAL-mode SQLite, which handles concurrent writers safely without relying on a timeout.


License

Apache License 2.0, Copyright (c) 2026 Jitin Kumar Sengar

Metadata

Release files for autourgos-local-memory 2.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autourgos-local-memory 2.1.1
File Size Uploaded
autourgos_local_memory-2.1.1.tar.gz 18.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autourgos-local-memory 2.1.1
File Interpreter ABI Platform
autourgos_local_memory-2.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.0 kB

Release files / autourgos_local_memory-2.1.1.tar.gz

Download URL autourgos_local_memory-2.1.1.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c9e18babde647367a576712b92a8189a8fd20384f6ff5c1b7ada28c5db5e9490
BLAKE2b-256 checksum
How to use checksums
6aa452bb975d859c1d87d0b6ebc6fbb6243318d85e7585461c3c90fb5ff4f8b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / autourgos_local_memory-2.1.1-py3-none-any.whl

Download URL autourgos_local_memory-2.1.1-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b48ece28c2173c81a4964e272ec0a39cdc6fe26a69d38d340295f0288f31801f
BLAKE2b-256 checksum
How to use checksums
213936d33c692cb6e61e7361130380df7daaba0cb026123f7e02489c6f34ce7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page