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. The default is 8GB.
  • 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.

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.1.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.1.0
File Size Uploaded Provenance
agent_session_analytics-0.1.0.tar.gz 39.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 71.3 kB

Release files / agent_session_analytics-0.1.0.tar.gz

Download URL agent_session_analytics-0.1.0.tar.gz
Size 39.4 kB
Tags Source
SHA-256 checksum
How to use checksums
50091c377229187fd8403771f9c99fcb78e82df4a6803b59821d5de0743f1f45
BLAKE2b-256 checksum
How to use checksums
7c644059ae0d6a65198d30bee30a93ec69012ef9689e5fae65fae4f70bf7ad7c
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":"24.04","id":"noble","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.1.0-py3-none-any.whl

Download URL agent_session_analytics-0.1.0-py3-none-any.whl
Size 31.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5b7e5afbfd6b9230599138e8477b0384aafdb553e94f6354d1e8eb3e99dbbb4
BLAKE2b-256 checksum
How to use checksums
ceda4aa06df2c8010c7cef85221637628118595967479406418fec629f06e6ac
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":"24.04","id":"noble","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.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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