@335g/pi-byetheway
v0.0.2
Published
Side conversation space (/btw) that reads the session context and never writes to it.
Readme
pi-byetheway
A side conversation space that reads the session context and never writes to it.
Run /btw mid-session, ask about what you have done so far, and close it without
leaving a trace in the session or in the agent's context. When you do want the
conclusion to survive, ctrl+n reformats the exchange into one message and sends
that to the main session.
Install
pi install npm:@335g/pi-byethewaypi install writes to the user settings (~/.pi/agent/settings.json). Add -l to write to the project settings
(.pi/settings.json) instead.
Usage
/btw— open the space
Keys:
| Key | Action |
|-----|--------|
| Enter | send the question |
| Shift+Enter | newline |
| Esc | stash the space and return to the main editor (state is kept) |
| ctrl+d | close and discard (asks first when there is anything to lose) |
| ctrl+n | hand the exchange to the main session (see below) |
| ctrl+u, PageUp, PageDown, Up/Down on an empty input | scroll the history |
These keys only apply while the btw panel has focus. The hand-off key is ctrl+n rather than the more obvious
ctrl+p because ctrl+p cycles the model in pi's main editor; pressing it there expecting a hand-off would
silently switch the model. ctrl+n is unbound in the main editor, so a stray press does nothing.
While a question is in flight the answer streams in. You can keep typing; Enter is ignored until it finishes.
A failed question is put back into the input so you do not retype it, and the reason
(provider error, empty answer, interrupted) is shown in the body above the input, not only in the footer.
Handing the exchange to the session (ctrl+n)
The point of the space is that nothing leaks into the main session by accident, so the hand-off is explicit:
ctrl+nasks for a focus.1-4insert a preset (Conclusion and evidence,Decision and reason,Open questions,Rejected options). You can edit the text or type any other focus instead. Empty means the default focus.Enterrewrites the whole exchange into one message and shows it.- The preview is editable.
Entersends it as a user turn;Escgoes back;ctrl+rreformats.
5 skips the rewrite and previews the raw transcript, which is the escape hatch for when the rewrite misses.
The rewrite prompt says: write in the first person, keep attribution for the other side's proposals
("an alternative was ..."), and output only the message body. Attribution matters — without it the main agent
reads someone else's suggestion as your own decision.
What is and is not sent
- Nothing is written to the session file. There are no
appendEntrycalls and no messages. - The main agent's context is untouched until you press
Enterin the preview. - The btw request carries the messages the main agent would have sent (the session branch with compaction applied),
plus the exchange so far. It carries no tool definitions, so the record is flattened to text:
a tool result becomes
[read の出力] ..., and a tool call inside a turn that also has prose becomes[read]. A turn that consists of nothing but tool calls is dropped, because keeping it would leave a[bash]line per call and read as an example of answering with a tool call. Images are replaced with(画像は省略). On a long session that turns ~250 messages into ~35 without losing any prose. - Because that prefix is identical to the main session's, providers with prefix caching usually charge the context at the cached rate. A long uncompacted session still means a large request per turn.
Limitations
- The btw agent cannot read files or run commands; it only reasons over the session context. Read-only tools
(
read,grep,find,ls) are the planned next step. - Because the session transcript contains tool calls, a model can try to call a tool even though none are offered. The btw system prompt forbids that explicitly. When a reply comes back empty (the usual symptom of a refused tool call), the panel reports it as an error and puts the question back in the input.
- The context is a snapshot taken when
/btwopens. Work done in the main session after that is not included. Reopening the space after a stash keeps the same snapshot. - A stashed space is dropped when the session is replaced.
Development
node packages/pi-byetheway/selfcheck.tsRuns both self-checks: the context projection (tool-call and tool-result flattening, image dropping,
same-role merging, assistant metadata preservation) and the pi-facing surface (registered command/
shortcut/event, and that the private ModelRuntime.stream keeps its receiver).
