Skip to main content

agent-sessions

PyPI Tests Python 3.11+ License: MIT

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

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)

Source distribution for agent-sessions 0.2.0
File Size Uploaded
agent_sessions-0.2.0.tar.gz 18.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-sessions 0.2.0
File Interpreter ABI Platform
agent_sessions-0.2.0-py3-none-any.whl Python 3 none any Details

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 log

Release 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 log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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