Skip to main content

Temporal context for LLM conversations — time awareness + stale-context detection

Project description

pysince

MCP server for coding agents: detects stale file reads before your agent acts on outdated content. Zero dependencies.

pip install pysince

What it does

pysince is a local MCP server that stamps every file your agent reads with its mtime and SHA-256 hash. On any subsequent tool call, it compares stored fingerprints against the current file and surfaces all tracked files that have changed — unprompted. The agent does not need to remember to check anything.

Files changed since last read:
  config.json (content changed, mtime changed) read 4m ago (+2 lines)
  alerts.py (content changed, mtime changed) read 3m ago

How it works

Every file the agent reads gets stamped with its current mtime and content hash. On any later MCP call, pysince checks all tracked files: mtime first (fast os.stat), full hash only if mtime moved. No daemon, no polling, no background process. Just a comparison against disk at the next turn.

Setup

Add to your MCP client config:

VS Code (.vscode/mcp.json):

{
  "servers": {
    "pysince": {
      "type": "stdio",
      "command": "pysince-mcp"
    }
  }
}

Claude Code / Cursor / Copilot (.cursor/mcp.json or client settings):

{
  "mcpServers": {
    "pysince": {
      "command": "pysince-mcp"
    }
  }
}

Antigravity (mcp_config.json):

{
  "mcpServers": {
    "pysince": {
      "command": "python",
      "args": ["-m", "since.mcp"]
    }
  }
}

Then add this line to your agent's system instructions:

On the first read of any file, call stamp_file_read. Before editing a file, call check_staleness. When the response lists changed files, re-read them before acting on their contents.

Tools

Tool When to call it Returns
stamp_file_read After reading any file Source ID confirmation
check_staleness Before editing a stamped file Stale status, change reasons (content vs mtime), line delta, read timestamp. Also lists all other tracked files that changed.
session_duration Anytime Session age and message count
invalidate_source Manual override Number of invalidated events

check_staleness never answers only about the one file asked. It reports the full set of tracked files that have drifted, so the agent cannot stay blind to a change it did not think to check.

When to use

Strongest when files change outside the agent's view: another process, a teammate on the same repo, a formatter, a pre-commit hook, a parallel agent, or context that drifted over a long session.

Less useful for quick single-file edits an agent already re-reads on its own. Skip it for throwaway scripts. Reach for it when agents share files, sessions run long, or more than one actor touches the tree.

Chat apps

pysince also provides a @since_time decorator for wrapping LLM chat functions with temporal context: timestamps, session duration tracking, gap detection, and stale context surfacing.

from since import Store, since_time
from openai import OpenAI

store = Store("~/.since/chat.db")
client = OpenAI()

@since_time(store=store, timezone="Asia/Kolkata")
def chat(messages):
    return client.chat.completions.create(model="gpt-4o-mini", messages=messages)

resp = chat(messages=[{"role": "user", "content": "hello"}])
print(resp.choices[0].message.content)

The model receives a time block before each turn:

Now:      Wed Jul 01, 02:36 AM (night)
Session:  9h 2m total, 4m active across 3 sittings, 8 messages
Gap:      6h since the last message

Works with OpenAI, Anthropic, and Gemini response shapes automatically. Pass extract_reply= for other providers.

CLI

pysince enrich <session_id>   # Enrich a session with temporal context
pysince search <session_id>   # Search messages by time range
pysince stats <session_id>    # Show session statistics

Requirements

  • Python 3.10+
  • Zero dependencies

The PyPI name is pysince because since was already taken. The import name and repo name are since.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysince-0.2.8.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysince-0.2.8-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file pysince-0.2.8.tar.gz.

File metadata

  • Download URL: pysince-0.2.8.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for pysince-0.2.8.tar.gz
Algorithm Hash digest
SHA256 603e158edcf3acd0f125f51782744fc77f341b9bf6dba6c15348300f2f276723
MD5 5ee6cd17af15bea6059d3cd7a3645a7b
BLAKE2b-256 9b39275b8774d439b1660294d4f36152eca53025f7fcdbc84be3d3b5a7b5876d

See more details on using hashes here.

File details

Details for the file pysince-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: pysince-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for pysince-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b9ab4351a478aba7bad8ba44961d531f7c79a01509f3b1b79c8a4a397a5cfb38
MD5 11ef8c19987eb43e2acbfbca990bb013
BLAKE2b-256 0eb5f4010a7453b0e50f3c700bac545877e69e78e1a556cda0576e7f9f138b46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page