pi-sessions

Manage Pi session state with branch-aware reconstruction and compaction interception.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/dotBeeps/hoard --skill pi-sessions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pi-sessions
Source: https://github.com/dotBeeps/hoard/tree/main/morsels/skills/pi-sessions
Command: npx skills add https://github.com/dotBeeps/hoard --skill pi-sessions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pi-sessions ensures extensions preserve and reconstruct state correctly across branching, forks, and compaction in Pi sessions, preventing state divergence and stale UI or data when the conversation tree changes.

Core Features & Use Cases

  • Branch-aware State Reconstruction: Rebuild in-memory extension state by scanning the current session branch for toolResult and custom entries on session events.
  • Compaction Control & Customization: Intercept, cancel, or replace automatic compaction summaries and manage proactive compaction to protect important context.
  • Extension-only Persistence: Persist UI preferences or bookmarks using custom, non-LLM-visible entries to avoid polluting LLM context while keeping state in the session tree.
  • Use Case: A stateful panel extension can reliably restore its list, preferences, and bookmarks after a user navigates branches, forks a session, or when automatic compaction runs.

Quick Start

Use pi-sessions to reconstruct extension state after a session switch by scanning the branch for toolResult and custom entries and then initialize your UI from the resulting snapshot.

Frequently Asked Questions about pi-sessions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I restore extension state after a Pi session branches or forks?

To restore extension state after a Pi session branches or forks, perform event-driven reconstruction by scanning the current session branch for toolResult and custom entries to rebuild in-memory state and prevent state divergence.

How does Pi session compaction interception work for custom context preservation?

Pi session compaction interception works by allowing extensions to intercept, cancel, or replace automatic compaction summaries, enabling proactive compaction to protect important context during the session lifecycle.

Can I persist extension UI preferences in Pi sessions without polluting LLM context?

Yes, you can persist extension UI preferences or bookmarks without polluting LLM context by using custom, non-LLM-visible entries that keep state in the session tree safely.

What is the best way to manage state lifecycle hooks in Pi conversation trees?

The best way to manage state lifecycle hooks in Pi conversation trees is applying event-driven reconstruction and compaction interception compatible with Pi's session APIs to ensure consistent state across branching.

Why does my extension show stale UI data after automatic compaction runs in Pi?

Extensions show stale UI data after automatic compaction because state is not properly reconstructed; scanning the session branch for custom entries on compaction events restores the correct snapshot.

Does pi-sessions support branch-safe state reconstruction for stateful panel extensions?

Yes, pi-sessions supports branch-safe state reconstruction for stateful panel extensions by reliably restoring lists, preferences, and bookmarks after users navigate branches, fork sessions, or trigger automatic compaction.