Skip to content
pi-c Artifact [fc57f874ce]
Login

Artifact [fc57f874ce]

Artifact fc57f874ce866e0e66635b1d574c6a8b8857cd095471a0da2598bb9c9120ea41:


# 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](../dev/durability.md)); nothing
another pic is doing is touched.

Two conversations can change the same file. pic does not merge their work; [tools](tools.md) 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](../reference/settings.md). `pic compact [ID [INSTRUCTIONS]]` and
`/compact [FOCUS]` compact before the next request.

## 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.