A lightweight Python library for preserving useful conversational continuity across separate AI sessions.
Continuity Engine gives AI applications a deterministic persistence layer for information that should survive beyond a single conversation. Instead of relying entirely on a language model to reconstruct previous context, applications can explicitly store continuity information and retrieve it later.
Project status: Early-stage standalone extraction from continuity architecture originally developed for Echo, a local AI assistant. APIs and architecture may evolve.
Most conversational AI sessions begin with little or no awareness of what happened previously.
For assistants that span multiple sessions, useful information can include:
- what the user was working on
- preferences established earlier
- project milestones
- unfinished tasks
- previous decisions
- context needed for the next conversation
Continuity Engine separates persistent application memory from language-model reasoning.
The application explicitly stores structured continuity data. The engine persists that information locally and retrieves it deterministically when a future session needs it.
Version 0.2 includes:
- persistent JSONL storage
- structured
Memoryobjects - automatically generated UUIDs
- timezone-aware UTC timestamps
- richer structured memory fields
- optional session IDs, sources, roles, source text, and metadata
- source timestamps and confidence values
- active/archived status support
- complete memory history
- filtering by type, subtype, status, and session ID
- latest-memory retrieval with filters
- deterministic keyword search
- deterministic relevance ranking with
retrieve() - empty-store handling
- executable continuity demo
- automated unit tests
- no third-party dependencies
Application / AI Assistant
|
v
ContinuityEngine
|
| save()
| history()
| latest()
| search()
| retrieve()
|
+------------------+
| |
v v
JSONLStorage Ranking Logic
|
v
JSONL File
Memory objects move through the engine
as structured continuity records.
The language model is not the database.
Continuity Engine treats persistence and retrieval as application responsibilities, allowing an LLM to focus on reasoning and conversation.
- Python 3.10+
- No external packages required for v0.2
From the repository root:
python -m examples.basic_demoExample output:
=== Session 1 ===
Saved: Next time, remind me that we're working on the memory system.
=== Session 2 ===
Recovered: Next time, remind me that we're working on the memory system.
The demo creates one engine instance, stores continuity information, then creates a new engine instance that retrieves the information from disk.
That simulates continuity across separate AI sessions.
from continuity import ContinuityEngine, Memory
engine = ContinuityEngine("data/memories.jsonl")
engine.save(
Memory(
type="project",
subtype="milestone",
content="Next time, remind me that we're working on the memory system.",
session_id="session-001",
source_role="user",
status="active",
)
)
latest = engine.latest()
if latest:
print(latest.content)Simple deterministic search:
results = engine.search("memory system")
for memory in results:
print(memory.content)Search is case-insensitive and requires every query term to appear in the stored memory's type or content.
Version 0.2 adds deterministic relevance ranking:
results = engine.retrieve("memory system", limit=3)
for memory in results:
print(memory.content)retrieve() scores stored memories using keyword overlap and continuity-oriented signals.
It does not require:
- an LLM
- embeddings
- a vector database
- external APIs
Stored memory history can be filtered by:
typesubtypestatussession_id
Example:
project_memories = engine.history(
type="project",
subtype="milestone",
status="active",
)Filters can also be combined.
latest() supports the same filters:
latest_preference = engine.latest(
type="preference",
status="active",
)When available, source_timestamp is used to determine recency.
If no matching memory exists, latest() returns None.
A Memory can contain:
contenttypesubtypesubjectsession_idsourcesource_timestampsource_rolesource_textconfidencestatussupersedesmetadataidtimestamp
Only content is required.
IDs and timestamps are generated automatically unless explicitly supplied.
Example:
Memory(
type="explicit_memory",
subtype="continuity_phrase",
subject="continuity test",
content="midnight sunflower",
session_id="session-002",
source_role="user",
source_text="The continuity phrase is midnight sunflower",
confidence=1.0,
status="active",
)Version 0.2 keeps the API intentionally small:
engine.save(memory)
engine.history()
engine.latest()
engine.search(query)
engine.retrieve(query, limit=3)Persists a Memory to the JSONL store.
Returns stored memories in insertion order.
Optional filters:
engine.history(
type="project",
subtype="milestone",
status="active",
session_id="session-001",
)Returns the most recent matching memory, or None.
Supports the same filters as history().
Performs simple deterministic keyword matching.
Returns relevant memories ranked by deterministic relevance scoring.
Run the complete test suite from the repository root:
python -m unittest discover -s tests -vThe current suite contains nine tests covering:
- saving and loading memories
- empty-store behavior
- latest-memory retrieval
- complete history retrieval
- deterministic keyword search
- extended structured-memory persistence
- deterministic ranked retrieval
- filtering by memory fields
- filtered latest-memory retrieval
Important continuity information should not depend entirely on whether an LLM reconstructs previous context correctly.
The persistence layer remembers stored information.
The language model reasons about it.
JSONL keeps the implementation portable, human-readable, and easy to debug.
A developer can inspect the continuity store without specialized database tooling.
Version 0.2 improves retrieval without introducing embeddings or vector databases.
This keeps behavior understandable and inspectable while the architecture is still evolving.
Continuity Engine intentionally avoids unnecessary infrastructure in its early versions.
The goal is to establish a reliable continuity layer before adding more advanced retrieval systems.
Continuity Engine originated while developing Echo, a local AI assistant.
Echo needed reliable continuity between separate conversations. Rather than keeping the architecture tied to one application, the reusable persistence and retrieval concepts were extracted into this standalone project.
Version 0.2 expands the standalone engine using retrieval and structured-memory concepts validated inside Echo.
The long-term architecture is:
Continuity Engine
^
|
Echo
Echo becomes an application built on Continuity Engine rather than maintaining a separate duplicate continuity implementation.
This public repository contains no private Echo conversations, identity files, personal memories, credentials, secrets, or application-specific user data.
Near-term work includes:
- completing Echo integration
- retiring duplicate Echo continuity logic
- improving filtering and ranking where useful
- expanding test coverage
Future versions may explore:
- duplicate detection
- configurable ranking strategies
- richer session-level data models
- structured session summaries
- semantic retrieval
- pluggable storage backends
- REST API
- PyPI distribution
- integration examples for local and hosted LLMs
Continuity Engine v0.2 is an early-stage but independently runnable and tested continuity library.
It is not yet intended to be a production-ready memory framework.
This project uses an AI-assisted development workflow.
AI tools have been used for implementation support, debugging, code review, and iteration. The project is also being used as a hands-on study of persistence, retrieval, Python architecture, testing, and AI application design.
MIT License. See LICENSE for details.