A pi extension that lets you ask side-questions without those Q&A turns polluting your main conversation context.
/btw <question>
A floating overlay panel opens. It's seeded with a read-only snapshot of the current main conversation so the model has full context to answer your question. The panel supports a full back-and-forth exchange. When you close it, nothing is written back to the main session — the main context remains exactly as it was before you typed /btw.
The side conversation has access to read-only tools — read, grep, find, and ls — so the model can look things up in your codebase to answer your question. The model runs a full agent loop: it can make multiple tool calls in sequence, see their results, and reason further before giving you a final answer.
Write-oriented tools (bash, write, edit, etc.) are explicitly blocked. If the model tries to call a known-but-disallowed tool it gets a targeted error message; truly unknown tools get a generic "not available" response. Either way, your project is never modified.
This means you can ask things like "what does the handleInput method do?" or "find all usages of convertToLlm" and the model will browse your files to give you an informed answer — without any risk of modifying your project.
| Key | Action |
|---|---|
Enter |
Send your question / follow-up |
Shift+Enter |
Insert a newline in the editor |
Esc |
Cancel the current request if thinking, otherwise close the panel |
Ctrl+C |
Copy the last assistant message to clipboard |
↑ / ↓ |
Scroll the log area (1 line) |
PageUp / PageDown |
Scroll the log area (10 lines) |
Install as a pi package:
pi install pi-btwOr copy btw.ts to your pi extensions directory manually:
cp btw.ts ~/.pi/agent/extensions/btw.tsOr, from inside a project, place it in .pi/extensions/btw.ts.
You can also point pi at it directly for testing:
pi -e ./pi-btw/btw.ts-
When you run
/btw <question>, the extension:- Reads the current session branch via
ctx.sessionManager.getBranch() - Converts those messages to LLM format with
convertToLlm() - Opens a floating overlay using
ctx.ui.custom()withoverlay: true(90% width/height, centred)
- Reads the current session branch via
-
Inside the overlay, every LLM call is:
- Passed
contextMessages(the snapshot) +sideMessages(this panel's history) - Given read-only tools (
read,grep,find,ls) created viacreateReadOnlyTools()from pi's SDK - Made via
complete()from@mariozechner/pi-aidirectly — no session involvement - Run in an agent loop: the model can request tools, see results, and continue until it produces a final text response or is aborted
- Passed
-
The main session's
appendMessage,sendMessage, etc. are never called. The overlay is purely display-side; closing it leaves zero traces in the main session.
- pi coding agent (any recent version)
- An API key for your current model (same one the main session uses)