← Catalog

pi-session-inspector

Branch-aware, bounded Pi session inspection tool

Package

Install

Install with PiG

pig install npm:pi-session-inspector

Install with Pi

pi install npm:pi-session-inspector
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/session-inspector.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.4.0 (README.md). PiG does not review it.

Pi Session Inspector

pi-session-inspector adds one model-callable Pi extension tool, session_inspect, for bounded, branch-aware inspection of the active session or a historical Pi session selected by exact session ID or .jsonl path. It can also query recorded tool calls across historical sessions.

Install

pi install /absolute/path/to/pi-session-inspector

Reload Pi after installing.

Tests

With Pi 1.5.2 installed and available as pi, run the regression suite through Pi's bundled extension loader:

npm test

The test command does not install or bundle Pi's peer packages.

CI and releases

Pull requests and pushes to main run the regression suite on Pi 1.5.2 and check the npm package contents.

Release Please prepares version/changelog PRs from Conventional Commits. Merging a release PR creates a GitHub release and publishes that version to npm using trusted publishing. Before the first release, enable GitHub Actions PR creation in repository settings and configure the npm package's trusted GitHub publisher as boadij/pi-session-inspector, workflow release.yml, allowing direct npm publish. No npm token is needed.

To retry publication of an existing release, manually run the Release workflow with its vX.Y.Z tag.

Actions

session_inspect supports:

  • summary - session metadata, message/tool counts, errors, token/cost usage, compactions, leaves
  • timeline - bounded compact entry timeline
  • tools - correlated tool calls/results with status
  • errors - tool and assistant errors
  • search - case-insensitive targeted session search
  • branches - leaf/branch overview
  • entry - exact bounded entry inspection

Scopes:

  • branch - current active path, default
  • all - entire session tree
  • context - active branch after Pi's context/compaction rules

By default the tool inspects the active session. session may be an exact session ID from the current Pi project or an explicit .jsonl path. Historical files are parsed and migrated in memory and are never rewritten.

Cross-session tool queries

session_inspect(action="tools", history="project", tool="delegate_agent", sessionLimit=25, limit=20)
  • history="project" searches the active session manager's configured directory and checks session working directories against the active project. Explicitly use history="all-projects" to search local Pi project directories under the Pi agent directory's sessions folder. Bulk discovery does not follow symlinked child directories or files.
  • With history="all-projects", optional cwdPrefixes restricts matches to sessions whose recorded absolute working directory is one of the supplied absolute paths or a descendant. Paths need not exist now. Prefixes match directory boundaries; relative paths are rejected. Excluded sessions do not consume sessionLimit, but header reads count toward the input budget. Filtered queries report coverage.excluded.
  • Historical tool searches include both top-level assistant calls and Pi's persisted nestedCalls on tool results (including Code Mode). Nested records have source="nested", parentCallId, and an entryId referring to the enclosing tool-result entry. Stored statuses may be unfinished; omitted nested arguments are marked argumentsUnavailable when requested.
  • History mode requires action="tools" and a nonempty, exact, case-sensitive tool name. Do not supply session. All recorded branches are searched, including abandoned branches; omit scope or set it to "all". The inspector's own calls are excluded. Omitting history preserves single-session behavior.
  • sessionLimit bounds attempted files (default 25, max 100). limit bounds returned examples (default 20, max 50); the output cap may reduce that further. A call has a 128 MiB input budget. Files too large for bulk scanning are skipped and can still be inspected directly by path.
  • Argument excerpts are omitted by default. Set includeArguments=true to request bounded, redacted excerpts (maxChars still controls excerpt length). Redaction is best-effort and may miss sensitive values. Tool-result bodies are never returned in history mode.

Pass nextCursor back as cursor with the same history scope, tool, session root, and optional cwdPrefixes filter to continue with the remaining files. The cursor is opaque and advances by file, not by example. A page keeps at least one example per matching session it counts as scanned, deferring the next session if necessary. Other calls from a represented session are sampled, not individually paginated. If no sampled example fits even on a page of its own, the file is reported as failed and skipped so the cursor can advance. Pagination is not a snapshot: files added, deleted, or modified between pages can affect coverage. An absent cursor means there is no next page, not that all history was readable.

Each example identifies the session (sessionId, sessionPath, parentSession), assistant entry (entryId), tool call (callId), and any correlated result (resultEntryId). Status ok or error reflects Pi's tool-error flag, not whether the tool accomplished its task. pending means no correlated result was found in the file, not that the tool is still running.

The response reports coverage separately from examples:

FieldMeaning
discoveredSession file candidates found during discovery, including out-of-scope files.
excludedWith cwdPrefixes, files skipped because their recorded cwd was outside the filter. Unreadable headers are failures, not exclusions.
attempted, scanned, failedCandidates attempted, files counted as fully scanned, and file failures on this page. An attempted file deferred at the output boundary is not counted as scanned or failed and is retried on the next page. Failure diagnostics are bounded.
matchingOccurrencesMatching top-level and persisted nested calls in fully scanned files on this page, including copied entries in forks. These are recorded occurrences, not unique executions.
incompleteNestedResultsNumber of scanned tool results whose persisted nested-call metadata is incomplete (when nonzero). Some calls or arguments may be missing even when all session files were scanned.
returned, examplesTruncatedExamples actually emitted, and whether some matches on this page were omitted.
scanCompleteNo remaining candidates, complete discovery, and no failures on this page. Check earlier pages separately.

Unreadable, malformed, changed, or oversized files do not contribute partial match counts. Incomplete discovery or failed files can leave gaps even when every returned match is shown. Historical files remain read-only; older formats are migrated in memory.

Typical agent workflow

session_inspect(action="summary")
session_inspect(action="summary", session="0199...")
session_inspect(action="errors", limit=10)
session_inspect(action="search", query="src/auth.ts", limit=10)
session_inspect(action="entry", entryId="...")

The tool excludes its own session_inspect calls from tool-call statistics and its tool results from tool-result statistics; the assistant messages and usage that produced them remain normal session data. Output is bounded, redacted, and omits thinking blocks and image payloads.