Files
scientific-agent-skills/skills/pi-agent/references/sessions.md
T
Timothy Kassis ef1b2d8026 Update pi-agent skill to latest Pi docs
Refresh every reference against https://pi.dev/docs/latest and the four
ecosystem package pages, cross-checked with the published npm READMEs.

New reference pages (docs added them; the site nav does not surface them):
- environment-variables.md: PI_* process config, the PI_CODING_AGENT child
  marker, and the session variables injected into the bash tool. The old
  env-var list lived in usage.md, which no longer has that section.
- llama-cpp.md: llama.cpp router setup, /login llama.cpp, /llama.

Notable upstream drift now reflected:
- SDK: ModelRuntime.create() replaces AuthStorage + ModelRegistry;
  createAgentSessionServices/FromServices runtime factory; resolveCliModel
  and resolveModelScopeWithDiagnostics.
- Providers: full 30+ API-key table with env vars and auth.json keys;
  xAI/OpenRouter/Radius subscription logins; provider-scoped env blocks in
  credentials; models-store.json; Bedrock proxy variables.
- New thinking level "max" across settings, CLI, RPC, thinkingLevelMap, and
  the themes' thinkingMax token.
- New commands: /trust, /import, /llama; pi update --all/--models/--self;
  pi config; .pi/SYSTEM.md and APPEND_SYSTEM.md; trust.json.
- RPC: get_entries (with since cursor), get_tree,
  get_available_thinking_levels, agent_settled, bash_execution_update,
  summarization_retry_*, and the extension UI sub-protocol.
- Extensions: expanded from a summary to the real API surface, including
  session-replacement semantics and footguns, withFileMutationQueue,
  terminate, prepareArguments, and dynamic tool loading.
- Session format: retainedTail checkpoints and buildContextEntries().
- Packages: pi-web-access gained source_check and nine search providers and
  dropped code_search, which the old reference still documented;
  pi-mcp-adapter gained six config locations, lazy-keep-alive, the output
  guard, and MCP_STATUS_EVENT; pi-subagents gained the watchdog, profiles,
  modelScope, per-agent memory, the fleet inspector, and RPC v1.

Also fixes escape sequences that had been corrupted in earlier versions:
the Git Bash path in windows.md, the shellCommandPrefix JSON in
shell-aliases.md, and the CSI-u sequences in tmux.md and terminal-setup.md.

Bumps metadata.version to 1.2.
2026-07-26 15:50:24 -07:00

2.9 KiB

Sessions

Source: https://pi.dev/docs/latest/sessions

Pi auto-saves conversations to ~/.pi/agent/sessions/, organized by working directory. Each session is a JSONL tree.

Session Commands

pi -c                  # continue most recent
pi -r                  # browse and select
pi --no-session        # ephemeral, do not save
pi --name "my task"    # display name at startup
pi --session <path|id> # specific file or partial session ID
pi --fork <path|id>    # fork into a new session file

Interactive: /resume, /new, /name <name>, /session (file, ID, message count, tokens, cost), /tree, /fork, /clone, /compact [prompt], /export [file], /share.

Resuming and Deleting

/resume (and pi -r) opens a picker for the current project. Search by typing; Ctrl+P toggles path display, Ctrl+S cycles sort mode, Ctrl+N filters to named sessions, Ctrl+R renames, Ctrl+D deletes with confirmation. Pi uses the trash CLI when available instead of permanently removing files.

Branching with /tree

Sessions are trees: every entry has id and parentId, and the current position is the active leaf. /tree jumps to any previous point and continues from there without creating a new file.

Key Action
↑/↓ Navigate visible entries
←/→ Page up/down
Ctrl+←/→ or Alt+←/→ Fold/unfold or jump between branch segments
Shift+L Set or clear a label on the selected entry
Shift+T Toggle label timestamps
Enter Select entry
Escape / Ctrl+C Cancel
Ctrl+O Cycle filter mode

Filter modes: default, no-tools, user-only, labeled-only, all. Set the default with treeFilterMode.

Selection Behavior

Selecting a user or custom message moves the leaf to that message's parent, puts the message text in the editor, and lets you edit and resubmit — creating a new branch. Selecting an assistant, tool, compaction, or other non-user entry moves the leaf there with an empty editor so you continue from that point. Selecting the root user message resets the leaf to an empty conversation with the original prompt in the editor.

Tree vs Fork vs Clone

/tree /fork /clone
Output Same session file New session file New session file
View Full tree User-message selector Current active branch
Typical use Explore alternatives in place Start a new session from an earlier prompt Duplicate current work before continuing
Summary Optional branch summary None None

Branch Summaries

When /tree switches away from one branch, Pi can summarize the abandoned branch and attach the summary at the new position, preserving context without replaying the branch. When prompted, choose no summary, the default prompt, or custom focus instructions. Internals and extension hooks: references/compaction.md. File format and SessionManager API: references/session-format.md.