agent-sessions
Discover and inspect local AI coding agent sessions (Claude Code, Codex, OpenCode, Pi).
Looking for a ready-made supervision tool? Check out Tether.
Install
pip install agent-sessions
Usage
from agent_sessions import discover_sessions, get_session_detail, RunnerType
# Find all recent sessions
sessions = discover_sessions()
for s in sessions:
print(f"{s.runner_type.value}: {s.directory} ({s.message_count} messages)")
# Filter by agent type
claude_sessions = discover_sessions(runner_type=RunnerType.CLAUDE_CODE)
# Filter by project directory
project_sessions = discover_sessions(directory="/home/user/my-project")
# Load full message history
detail = get_session_detail(sessions[0].id, sessions[0].runner_type)
for msg in detail.messages:
print(f"[{msg.role}] {msg.content[:80]}")
Supported agents
| Agent | Session location | Format |
|---|---|---|
| Claude Code | ~/.claude/projects/ |
JSONL per session |
| Codex | ~/.codex/sessions/ |
JSONL rollout files |
| OpenCode | ~/.local/share/opencode/opencode.db |
SQLite database |
| Pi | ~/.pi/agent/sessions/ |
JSONL per session |
Each provider also detects whether sessions are currently running by inspecting the process table.
Configuration
All providers support environment variables to override default paths:
| Variable | Provider | Default |
|---|---|---|
CLAUDE_HOME |
Claude Code | ~/.claude |
CODEX_HOME |
Codex | ~/.codex |
XDG_DATA_HOME |
OpenCode | ~/.local/share |
PI_SESSIONS_DIR |
Pi | ~/.pi/agent/sessions |
OpenCode uses a centralized database at $XDG_DATA_HOME/opencode/opencode.db (defaults to ~/.local/share/opencode/opencode.db).
Status
Beta. The API may change between minor versions until 1.0.
License
MIT
Metadata
Release files for agent-sessions 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agent_sessions-0.2.0.tar.gz | 18.9 kB | With provenance | Details for agent_sessions-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent_sessions-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for agent_sessions-0.2.0-py3-none-any.whl |
Total release size: 37.6 kB
Release files / agent_sessions-0.2.0.tar.gz
| Download URL | agent_sessions-0.2.0.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36d2b6c97bc5883eb99ed08b43a4334ab6c3e0d6a80ea9bf92bedec766b50327
|
|
BLAKE2b-256 checksum How to use checksums |
342bc23a060bb100678a2a7f46ff1588ecdba33ced7c7ae0af4e3094a6a33c06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.
Transparency logRelease files / agent_sessions-0.2.0-py3-none-any.whl
| Download URL | agent_sessions-0.2.0-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
196bff0ed5a28e038e2949323d7179a5df16b8cb3ee128fb0bbfcededbc36bd6
|
|
BLAKE2b-256 checksum How to use checksums |
5bf063768e5c70504217dee513e24c83e962057baff8e23cf63c5c872f63c9e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.
Transparency logSecurity for agent-sessions 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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for agent_sessions-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 25, 2026.
Transparency logA 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.