Skip to main content

te-drift-detector

License: MIT CI Python 3.10+

See how the language, assumptions, and task framing of an AI conversation change as the session grows.

te-drift-detector provides experimental lexical feature-delta telemetry for multi-turn text. It creates lightweight fingerprints, compares later conversation state with an initial baseline, and surfaces raw deltas and hand-set threshold crossings for human review.

It can flag some curated state shifts under user-adjustable rules. It does not establish malicious drift, model compromise, calibrated confidence, or safety severity. Detection efficacy, threshold calibration, and recovery benefit have not been established.

  • Zero required dependencies. The default path uses only the Python standard library.
  • Deterministic by default. With optional embeddings disabled, the same input produces the same lexical measurements.
  • Small and readable. Feature extraction, comparison, and threshold rules are a few hundred lines.

The narrow use case

Long conversations can change in ways that are difficult to inspect turn by turn. te-drift-detector provides experimental telemetry for that inspection: it fingerprints supplied text, measures feature changes relative to a baseline, and labels crossings of its hand-set rules. Those labels are prompts for human investigation, not findings about intent, compromise, or safety.

No production effectiveness result or independently labeled evaluation ships with this release. The bundled synthetic sequences exercise the implementation; they are demo/self-check fixtures generated and scored by the same repository.

Install

PyPI publication has not happened yet. Until the v0.1.1 tag has published successfully, install the current source from GitHub:

pip install git+https://github.com/hermes-labs-ai/te-drift-detector

After that tagged publication is available on PyPI, install the released package instead:

pip install te-drift-detector==0.1.1

Or from source:

git clone https://github.com/hermes-labs-ai/te-drift-detector
cd te-drift-detector
pip install -e ".[dev]"

Quick start

# Analyze a built-in synthetic conversation
te-drift detect --attack-type poisoning

# A built-in normal conversation for comparison
te-drift detect --attack-type normal

# Run the deterministic demo/self-check fixtures
te-drift eval

Analyze a supported session transcript (JSONL, one user or assistant record per turn):

{"type": "user", "message": {"role": "user", "content": "..."}, "timestamp": "2026-07-06T20:00:00Z"}
te-drift session --session-jsonl path/to/session.jsonl
# For long sessions, use a constant-cost sliding window:
te-drift session --session-jsonl path/to/session.jsonl --mode sliding-window --window-size 10

The JSONL adapter currently reads user and assistant records. To analyze other state, normalize it explicitly and use the library interface below.

As a library

from te_drift import TEDriftDetector

turns = [
    ("system", "You are a careful assistant. Validate inputs; security matters."),
    ("system", "[STATE UPDATE] Security requirements changed."),
    ("user", "Summarize the current requirements."),
]
report = TEDriftDetector().run_conversation(turns)
print(report["threat_level"], report["anomalies_detected"])

threat_level and confidence are retained API field names. Their values are uncalibrated heuristic tiers and rule scores; they are not safety severity or a probability that a session is compromised. The tool does not establish malicious drift.

How it works

  1. Feature extraction. Extract lightweight lexical features from cumulative context: facts, entities, sentiment, task framing, authority level, style register, negations, and vocabulary.
  2. Feature deltas. Compare the current fingerprint with the first-turn baseline. The field named velocity_drift is the absolute change in the scalar baseline-distance value since the previous reading; it is not a direct previous-fingerprint distance.
  3. Heuristic crossings. Mark a reading when a hand-set absolute-delta, radial-change, component, or lexical-signature rule crosses its threshold.
  4. Legacy output tiers. Summarize recent crossings as NORMAL, LOW, MEDIUM, HIGH, or CRITICAL. These uncalibrated heuristic tiers are not safety severity.

The default comparison uses set overlap and stays in-process. Optional semantic embeddings are available with TE_DRIFT_EMBED=1:

TE_DRIFT_EMBED=1 te-drift session --session-jsonl path/to/session.jsonl

That setting can make an optional configured network call to TE_DRIFT_OLLAMA_URL (default: http://localhost:11434/api/embeddings) and send the analyzed text to that endpoint. If the endpoint is unavailable, errors, or returns no vector, the implementation silently falls back to lexical set overlap. Reports do not currently expose whether that fallback happened, and embedding quality has not been evaluated. Do not enable it for sensitive text without reviewing and trusting the configured endpoint.

Optional companion workflow

hermes-blind is a separate recovery scaffold. You may inspect this package's telemetry before and after a recovery experiment, but the repositories do not establish that the telemetry identifies when recovery is needed or that either component improves outcomes.

Demo/self-check fixtures

te_drift.evals generates three synthetic state-change sequences and feeds them through the package. This checks deterministic wiring and makes example output easy to inspect. Because the same repository authors both the generators and the rules, these results are not evidence of detection rates, false-positive rates, or generalization.

te-drift eval
te-drift eval --strategy bias_drift --turns 6
te-drift eval --json

The default lexical run crosses at least one heuristic rule for each bundled sequence. Treat that as a self-check only, not an efficacy result.

Limits

  • The feature set is lexical, heuristic, and English-oriented by default.
  • Meaning-preserving changes can produce small deltas; harmless wording changes can produce large ones.
  • Thresholds and the fields named confidence and threat_level are uncalibrated. They do not establish malicious drift and are not safety severity.
  • The session adapter observes user and assistant transcript records, not a general system/scaffold state schema.
  • Optional embeddings can transmit text through a configured endpoint and silently fall back without reporting the active comparison mode.

Development

pip install -e ".[dev]"
pytest
ruff check src tests

License

MIT. See LICENSE.

About Hermes Labs

Hermes Labs builds tools for inspecting AI-system behavior. In this repository, the supported description is experimental lexical feature-delta telemetry; no claim of calibrated safety detection or production effectiveness is implied.

Download files

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

Source Distribution

te_drift_detector-0.1.1.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

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

te_drift_detector-0.1.1-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file te_drift_detector-0.1.1.tar.gz.

File metadata

  • Download URL: te_drift_detector-0.1.1.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for te_drift_detector-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2e54c857f008db00945edf5c199b3cea979b584a81cf41dfdc61b37b1d83ee48
MD5 a9afd21bda2216e2906568901e7e5dba
BLAKE2b-256 f8303045eb0a3e4128074adb68263c0d8bbc52cce68eef5e9eb853686adde629

See more details on using hashes here.

Provenance

The following attestation bundles were made for te_drift_detector-0.1.1.tar.gz:

Publisher: pypi-publish.yml on hermes-labs-ai/te-drift-detector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file te_drift_detector-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for te_drift_detector-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1401f8a1d7aed46a99440beb13a8b1cad98f7aed0bd08d3e655e1cfe2e790c16
MD5 014b302d23c6048e22b7c1b5df6dad1f
BLAKE2b-256 17d38a966fff766ae29ce6bcd04f9c5e0095bdde2f858c7cec70b1bab50e6591

See more details on using hashes here.

Provenance

The following attestation bundles were made for te_drift_detector-0.1.1-py3-none-any.whl:

Publisher: pypi-publish.yml on hermes-labs-ai/te-drift-detector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

Supported by

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