Temporal context for LLM conversations — time awareness + stale-context detection
Project description
pysince
Temporal context for LLMs — time awareness + stale-context detection, zero AI calls.
pip install pysince
from since import Store, since_time
What it does
LLMs have no sense of time. Ask "what time is it?" and they guess. Ask "what did we talk about 3 hours ago?" and they can't. Context from 5 minutes ago looks the same as context from yesterday.
pysince (imported as since) wraps your LLM calls with a real clock, persistent timestamped memory, and TTL-based staleness detection.
Quick start
from since import Store, since_time
from openai import OpenAI
store = Store("~/.since/chat.db")
client = OpenAI()
@since_time(store=store, timezone="UTC+05:30")
def chat(messages):
return client.chat.completions.create(model="gpt-4o", messages=messages)
# Every message is timestamped automatically
resp = chat(messages=[{"role": "user", "content": "hello"}])
print(resp.choices[0].message.content)
The prompt sent to the model looks like:
system: Every message has a UTC timestamp. The 'Now:' line below is the
current time — use it for all time references. Never guess the time.
user: [Wed Jul 01, 02:36AM] hello
system: Now: Wed Jul 01, 02:36 AM (night)
Session: just started · 1 message
Stale-file detection (for coding agents)
The real killer feature: agents that read files and act on outdated content.
from since.stale_files import stamp_file_read, check_and_invalidate
# Agent reads a file — stamp it
stamp_file_read("config.py", store, "session_1")
# File changes (git pull, manual edit, another tool)
# Next agent turn — stale warning fires automatically
if check_and_invalidate("config.py", store, "session_1"):
# ⚠ Stale: "config.py" appears in the prompt tail
# Agent sees the warning and re-reads
stamp_file_read("config.py", store, "session_1")
The tail block shows:
⚠ Stale: "[FILE READ] config.py (mtime=...)" (read:config.py) — invalidated, 14m old
No daemon, no watcher, no polling — just mtime comparison at the next agent turn.
from since.stale_files import stamp_file_read, check_and_invalidate
How it works
| Component | What it does |
|---|---|
@since_time |
Decorator that wraps any chat function, timestamps every message, adds the clock |
with_time() |
Formats history with absolute timestamps + tail block (Now, gaps, stale warnings) |
Store |
SQLite backend — persistent, thread-safe, WAL mode, zero deps |
stamp_file_read() |
Records a file read as an event with current mtime |
check_and_invalidate() |
Compares stored vs current mtime, invalidates if changed |
timeparse |
Natural language time parser — "3 days ago", "yesterday at 3pm" |
TTL classes
| Class | Decay | Use case |
|---|---|---|
permanent |
Never | User identity, project facts |
slow |
Session age | Normal conversation |
event |
store.invalidate(source_id) |
File reads, tool outputs |
ephemeral |
5 minutes | "ok", "thanks", throwaway messages |
Requirements
- Python 3.10+
- No dependencies (zero — no numpy, no pydantic, no LLM SDK)
Install
pip install pysince
Import as:
from since import Store, since_time
from since.stale_files import stamp_file_read, check_and_invalidate
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 pysince-0.2.0.tar.gz.
File metadata
- Download URL: pysince-0.2.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b1df283da29fdf2a918417cdc550ce0c20372a1784ca4e27a3c9833a002d9a2
|
|
| MD5 |
06cccd9ee2b1c92e87d1a85426a81d21
|
|
| BLAKE2b-256 |
9b44792c32fcd015ba2a85e2efe3d04acd0c5c6ac11a703cd15fa6c5a7697494
|
File details
Details for the file pysince-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pysince-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d38f83352fd008b38094f8324b05ea0749db6c74695047934ce7893d9846ea4
|
|
| MD5 |
f930370f519b6c1594cd4b0878e5a7e8
|
|
| BLAKE2b-256 |
762cb8b855b3da69ee3cbc0aeb0488b1f68f9c5d25b8b63f1762fd927b4bf3b9
|