Documentation · zos-telemetry

zos-telemetry — measurement layer.

Session-quality telemetry, derived from the source of zos_telemetry 0.1.0. Working code, June 2026.

zos‑telemetry is the "see what works" layer: it measures how well an AI system is actually serving you — corrections per session, cost, friction — and compares two systems head-to-head. It is content-free by construction: the store holds metrics and short detection markers, and there is literally no field that can hold message text. Python 3.11+ · stdlib only · BUSL-1.1

Status: working code · 28 tests · CI green · BUSL-1.1 · repository private until public launch.

Package zos_telemetry 0.1.0. Storage resolves from an explicit root argument → $ZOS_HOME/telemetry~/.zos/telemetry (telemetry_root() — it does not create the directory; writers do, lazily).

Key concepts

Event capture — zos_telemetry.events

SessionLog(root=None)

Append-only store under the resolved root, with two month-bucketed sinks:

SinkContents
events-YYYY-MM.jsonlone row per event
sessions-YYYY-MM.jsonlone summary row per closed session

Writers are fail-loud (the library raises); wrap calls at integration points where the host process must never block. Sink files are chmod 0600 best-effort.

Event schema

{
  "schema": 1,
  "ts": "2026-06-10T18:00:00Z",
  "session_id": "s1",
  "system": "system_a",
  "context": "work",
  "role": "user",
  "kind": "user_message",
  "model": "model-x",
  "tokens_in": 1200,
  "tokens_out": 300,
  "cost_usd": 0.04,
  "markers": ["corr.strong.2"]
}

kind is free-form; three values carry aggregation semantics: user_message (counts as a user turn; correction detection applies), assistant_message (counts as a turn), anything else (e.g. cost_tick) contributes only tokens/cost. markers is the only detection surface — short, content-free tokens; never message text. Closed-session summary rows add: detector_version, turns, user_turns, corrections, events, first_ts, last_ts, duration_s, ts_closed, and the dominant model (by cost, falling back to frequency).

Correction detector — zos_telemetry.detector

A "correction" is a user turn that reads as the user correcting or redirecting the assistant. Conservative by design; versioned via DETECTOR_VERSION (currently 1).

is_correction(text: str) -> bool correction_markers(text: str) -> list[str] detect_corrections(events) -> list[dict] corrections_per_session(events) -> dict[str, int]

Known limitations (kept, documented): it under-counts; English-only patterns; opener false positives are possible ("No, Tuesday works" answering a question counts — applied symmetrically across systems, comparisons stay fair even when absolute counts drift); questions and approvals containing "right" do not fire; heuristic, not semantic.

Aggregation — zos_telemetry.aggregate

Pure functions; no I/O; recomputed whole each call, so re-running never double-counts.

session_summary(events, session_id=None) -> dict per_day(events) -> list[dict] aggregate_sessions(rows) -> dict[str, dict]

Comparison — zos_telemetry.compare

compare(system_a, system_b, window=None, *, sessions=None, root=None) -> dict to_markdown(report) -> str SMALL_SAMPLE_N = 20

CLI — zos-telemetry

All subcommands accept --root DIR.

zos-telemetry append --session-id S --system NAME --kind KIND
    [--role R] [--context C] [--model M]
    [--tokens-in N] [--tokens-out N] [--cost-usd X] [--ts ISO]
    [--marker TOKEN]... [--mark-stdin]
zos-telemetry close --session-id S          # exit 1 if no events
zos-telemetry sessions                      # JSONL on stdout
zos-telemetry compare SYSTEM_A SYSTEM_B [--window DAYS] [--json]
zos-telemetry --version

--mark-stdin reads the user message on stdin, stores only its correction markers, and discards the text — the supported way to feed the detector from a shell hook without persisting content.

# capture (e.g. from each system's stop hook):
echo "$USER_MESSAGE" | zos-telemetry append \
  --session-id "$SESSION_ID" --system system_a \
  --kind user_message --mark-stdin          # markers stored, text discarded

# close the session into one summary row, then compare:
zos-telemetry close --session-id "$SESSION_ID"
zos-telemetry compare system_a system_b --window 30

Environment variables

VariableEffect
ZOS_HOMEBase directory; storage goes to $ZOS_HOME/telemetry when no explicit root is given. Default base: ~/.zos.

This page mirrors docs/API.md in the zos-telemetry repository, derived from the source at 0.1.0. Companion: platform overview · zos-evals. Questions? Request early access.