Skip to main content

agent-session-analytics

agent-session-analytics ingests the session logs of coding agents into one DuckDB database. It then answers SQL queries that cannot write or run commands. It supports the Claude Code, Codex, Cursor, OMP, and pi harnesses.

The package ships engine primitives only. It has no canned reports. A caller writes its own SQL against the schema.

Install

uv tool install agent-session-analytics
# or
pip install agent-session-analytics

The only runtime dependency is fromargs. The package calls the duckdb command-line tool and does not need the Python duckdb module. Install DuckDB with one of these commands:

uv tool install duckdb-cli
brew install duckdb
mise use -g duckdb
curl https://install.duckdb.org | sh

The package never downloads DuckDB. When duckdb is not on PATH, ingest and sql exit 3 and print these options.

Commands

Every command prints one JSON document on stdout. Every error is one JSON line on stderr: {"error": <message>, "exit_code": <n>}.

Command Result
ingest [--force] Build or refresh the database. A database inside the one-hour freshness window with the current schema version keeps its data.
db-path The resolved database path, as {"path": "<abs path>"}.
sql <query> The rows of one query in DuckDB safe mode.
schema The canonical schema reference.
agent-session-analytics ingest
agent-session-analytics db-path | jq -r .path
agent-session-analytics sql "SELECT harness, count(*) AS sessions FROM sessions GROUP BY harness"

sql opens the database read-only and runs in DuckDB safe mode. Safe mode rejects shell commands, file writes, and reads of files outside the database. A rejected query exits 5.

sql ingests an old or absent default database first. It does not ingest a SESSIONS_DB override. It never queries stale data after a failed ingest.

A consumer that queries the database directly runs duckdb -init /dev/null -readonly <database> -json -c "<sql>", where <database> is the path field of db-path.

Exit codes

Code Meaning
0 Success
2 Bad input
3 The duckdb command is missing
4 Ingest failed or timed out, or the database is missing, unreadable, or has another schema version
5 DuckDB rejects the query, or the query times out

Database path

  • SESSIONS_DB names the database. A relative value joins the current directory. The package does not expand ~ in a set value.
  • Otherwise an absolute XDG_CACHE_HOME selects <cache>/dotfiles/session-analytics/sessions.duckdb. A relative or unset value uses ~/.cache.
  • SESSIONS_DUCKDB_MEMORY_LIMIT sets the DuckDB memory limit, from 16MiB up to but not including 16EiB. The default is 4GB.
  • SESSIONS_DUCKDB_THREADS sets the DuckDB thread count, from 1 to 256. The default is 4.
  • CLAUDE_CONFIG_DIR, CODEX_HOME, and CURSOR_HOME move the log roots.

Ingest writes the transient <db>.tmp and <db>.stage, and a persistent <db>.lock. An fcntl lock serializes ingest runs. Ingest uses umask 077. DuckDB spills large operations to a per-process <db>.spill-<pid>-<token> directory. DuckDB creates it only when a run spills, so a read-only query needs no writable directory. Each process removes its own directory at exit; a killed process can leave one behind, which is safe to delete. The spill cap is 20GB.

Schema version

The database holds a one-row schema_info table with an integer version. The package version of that integer is SCHEMA_VERSION. ingest rebuilds a database whose stored version differs, even inside the freshness window. sql treats a mismatch like a stale database. Only this repository changes the schema.

References

These files ship as package data in agent_session_analytics/references/:

  • canonical-schema.md — tables and columns. agent-session-analytics schema prints it.
  • harness-coverage.md — what each harness log provides.
  • query-conventions.md — rules for writing queries.

Metadata

Release files for agent-session-analytics 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-session-analytics 0.2.0
File Size Uploaded Provenance Actions
agent_session_analytics-0.2.0.tar.gz 61.2 kB Without provenance Details for agent_session_analytics-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agent-session-analytics 0.2.0
File Interpreter ABI Platform Actions
agent_session_analytics-0.2.0-py3-none-any.whl Python 3 none any Details for agent_session_analytics-0.2.0-py3-none-any.whl

Total release size: 107.7 kB

Release files / agent_session_analytics-0.2.0.tar.gz

Download URL agent_session_analytics-0.2.0.tar.gz
Size 61.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8b786fee1d52df33cb3a54c358d1d88880d12b523a9ae59646e2a565eb444fd8
BLAKE2b-256 checksum
How to use checksums
595b82a35bc287eef3e3cdac89584455c230bd1b2d378d77604c4f58971fa029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / agent_session_analytics-0.2.0-py3-none-any.whl

Download URL agent_session_analytics-0.2.0-py3-none-any.whl
Size 46.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42d0b4ecbfa979be32cac832cf8a1bf08fb314daee5e906bb6b373b9be98edb2
BLAKE2b-256 checksum
How to use checksums
20ac3fbfd2d0c6531ffb50562c516fad99ca6c0e674077748fdcc7474884e023
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for agent-session-analytics 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page