Artifact 9c22eafc8b0bb25882d9ba58f55a37b1adb25471448303eaaf88f62e76e6e802:
- File docs/manual/sessions.md — part of check-in [2eaab55528] at 2026-11-22 10:46:48 on branch keel-lapse — keel-lapse: tiers check 5, docs, fault point rename (user: dmestas, size: 5412) [annotate] [blame] [check-ins using]
Sessions
A session is a conversation in the workspace's journal, WORKSPACE/.pic/journal.sqlite. pic
sessions lists them, pic log [ID] shows one's entries, pic name ID NAME names one, and -c or
--session ID continues one in ask, chat, tui and RPC mode.
Several pics in one project
More than one pic can work in a project at the same time, each in its own conversation. While one
runs a long task, start another in a second terminal: pic ask a side question (a new
conversation), continue a different conversation with --session ID, or look at the running one
with pic sessions, pic log ID and pic dump. pic sessions marks a conversation another pic is
working (in use by pid N).
A conversation is worked by one pic at a time. Asking into one that another pic is working is refused:
pic: conversation ab12cd34 is in use by another pic process (pid 4711)
pic cancel KEY is refused the same way while the request's own pic runs it; press Ctrl-C there
(or send that pid SIGINT). pic run finishes the requests nobody is running and says which it left
to their owners. -c continues the conversation changed most recently, which may be the one the
other pic is working; name yours with --session ID.
If a pic is killed, its conversation is free again as soon as its running command has been stopped. The next pic to open the journal settles what it left (durability); nothing another pic is doing is touched.
Two conversations can change the same file. pic does not merge their work; tools says what an edit or write that meets the other's change is told. Upgrading pic to a version with a new journal format needs the other pics in that project closed first; pic says so and changes nothing until they are.
Forking
/fork with no argument opens Pi's "Fork from Message" picker of your earlier messages: Enter
forks the path before the chosen message into a new conversation and puts that message in the
editor. /fork ENTRY forks after an entry (see pic log). On the command line, pic fork ID --at
ENTRY does the same.
Compaction and branch summaries
Compaction and branch summaries take Pi's settings, in Pi's settings.json shape (pic settings
compaction '{"reserveTokens":16384,"keepRecentTokens":20000}'): compaction.enabled (default true;
off stops automatic compaction, overflow recovery included, as in Pi, but not pic compact;
/settings Auto-compact and the RPC command set_auto_compaction set it),
compaction.reserveTokens, compaction.keepRecentTokens,
compaction.modelOverrides["provider/model"], branchSummary.reserveTokens and
branchSummary.skipPrompt. Leaving a branch in /tree asks Pi's "Summarize branch?"; a summary
(pic fork ID --at ENTRY --summarize) is a journaled, priced request, and the new conversation
starts with Pi's branch_summary entry.
The defaults are in settings. pic compact [ID [INSTRUCTIONS]] and
/compact [FOCUS] compact before the next request.
Compacting a conversation you come back to
The provider keeps a conversation's prompt cached for a while (five minutes by default, an hour
with cacheRetention long). Come back later and the next request pays to send the whole
conversation again, so pic compacts it first when it is above 100000 tokens, which costs less: in
a replay of 28 real long sessions it cut the cost of the next three requests by 38% with about the
same results. --lapse off (setting lapseCompaction) turns this off; --lapse-floor sets the
size and --lapse-seconds the cache lifetime pic assumes. Details are in benchmarks.
By default such a compaction makes no summary: pic keeps the newest messages, about
compaction.keepRecentTokens (20000) of them, and drops everything older, so it costs no request
at all. It cuts only where a message or a reply begins, so a tool call always stays with its
result, and the files read and modified are still listed. A SessionStart hook then runs with
source compact, so a tool such as ctx can bring back what matters from the dropped part. Set
lapseMode to summary for Pi's summary instead.
To show what this saves rather than estimate it, pic leaves one such return in ten uncompacted, at
random (setting lapseHoldout, from 0 to 1; 0 never holds one out). pic usage --lapse compares
the cost from each return to the next one in that conversation, compacted against held out, for
each mode in turn (a return held out counts for the mode pic would have compacted in):
cold caches: 41 compacted, 5 held out, 12 under the floor
trim: 41 compacted, 5 held out
cost from each to the next in its session: compacted $0.9120 on average, held out $1.4740
compacted / held out: 0.62 (95% interval 0.48 to 0.81)
saved: $23.04 over 41 compactions (95% interval $11.20 to $31.90)
It says "not enough to compare yet" until each side has five. Because the held-out returns are
chosen at random, the comparison is fair, but it is only as sure as its interval: with few
held-out returns the interval is wide, and a raised lapseHoldout narrows it sooner at the price
of fewer compactions.
Exporting
pic export --html ID writes a conversation as one self-contained HTML page, pic export --pi
writes conversations as Pi session lines, and pic import PATH reads a Pi session back as a new
conversation.