How to delete pi session history, and what you lose
Each session is a single JSONL file; remove the file, or delete the project folder
pi stores each session as a single JSONL transcript under its agent sessions directory. Configuration, extensions, and MCP server settings live beside it in the same ~/.pi/agent tree, so delete only files inside sessions to keep your settings intact.
Where the sessions are
${PI_CODING_AGENT_SESSION_DIR:-${PI_CODING_AGENT_DIR:-~/.pi/agent}/sessions}/<encoded-project>/<timestamp>_<uuid>.jsonl
By default, transcripts live under ~/.pi/agent/sessions/. Each project has a directory whose name encodes the project path with slashes folded into hyphens (for example, --home-user-project--). Inside that folder, each session is a single JSONL file named with an ISO timestamp and UUID, such as 2026-10-28T12-00-00-000Z_a1b2c3d4-e5f6-7890-abcd-ef1234567890.jsonl. The first line of each file is a session header recording the real cwd.
PI_CODING_AGENT_DIR moves the entire agent directory, while PI_CODING_AGENT_SESSION_DIR moves the session store alone. Setting either environment variable redirects where pi writes and reads transcripts.
How to delete one session
Close pi first so an active session cannot rewrite or append to its transcript. Then remove the session's JSONL file:
rm ~/.pi/agent/sessions/<encoded-project>/<timestamp>_<uuid>.jsonl
The UUID in the file name matches the session ID that pi --session <id> takes. If the project directory contains no other sessions, you can remove the empty project directory as well.
To clear an entire project's session history, remove the project directory:
rm -r ~/.pi/agent/sessions/<encoded-project>
To delete every session across all projects, remove the sessions directory. Do not delete ~/.pi/agent itself: your settings.json, mcp.json, and custom extensions under extensions/ live there and are preserved:
rm -r "${PI_CODING_AGENT_SESSION_DIR:-$HOME/.pi/agent/sessions}"
Delete one session with deja
If deja is installed, run deja last to find the session ID. Preview what will be deleted using --dry-run, then run the deletion:
deja delete <id> --dry-run deja delete <id>
The dry run lists the target file path without touching it. After confirmation, deja removes the JSONL transcript and forgets its own copy from the local index. This cannot be undone. deja refuses deletion if the session file was modified in the last 5 minutes, ensuring active sessions are not removed while in progress.
What you lose
The JSONL transcript holds the complete record of the session: the conversation messages, model switches, thinking adjustments, and tool calls (file reads, writes, edits, and shell commands) along with their results. Once removed, pi --session <id> cannot reopen the session, and pi cannot recover deleted transcripts without a separate backup.
Keeping it searchable instead
deja reads pi transcripts, along with sessions from forty-two other coding agents on your machine, into a single searchable local index:
curl -fsSL https://raw.githubusercontent.com/vshulcz/deja-vu/main/install.sh | sh deja "pi session about the parser fix"
Indexing and search stay entirely on your disk, credentials are automatically stripped, and deja forget removes a session from the index when you want it forgotten without deleting the source file. deja honors PI_CODING_AGENT_DIR and PI_CODING_AGENT_SESSION_DIR; you can also set DEJA_PI_ROOT to point deja at an archived copy or backup of your transcripts.
Where every agent keeps its history · Memory for pi · The pi format
Found this useful? Star deja-vu on GitHub.