ExtensionContext@piex-dev/btw

btw — Ephemeral Side Questions, Not Remembered

TL;DR

/btw lets you ask a side question with full context; the Q&A never enters the session — like whispering to your neighbor mid-meeting.

Overview

The classic dilemma: you want to ask something related to the current task but not have it "taken seriously". E.g. while debugging you ask "what's this project's Docker base image?" — sending it directly makes the agent treat it as task context, weighing "the user asked about Docker" on every later turn. @piex-dev/btw's answer: the question never goes to the agent. The extension takes a session snapshot, makes a side model call, and shows the answer. Nothing is left in the session.

How it works

Core mechanism: side call. The extension bypasses the agent loop and uses pi-ai's completeSimple for a one-shot request. Since the Q&A never enters the session, "anti-pollution" shifts from runtime filtering to an architectural guarantee: there's nothing to filter.

flow
/btw cmd → resolve model & creds → build snapshot (≤40K chars)
→ completeSimple(model, { systemPrompt, messages })
→ render answer into a Markdown pager (scrollable, interruptible)
→ no write to the session

The snapshot is a compressed summary (only user/assistant messages, toolCall kept as name(args), truncated from the head past 40K chars). A dedicated model can be configured (~/.pi/piex-dev/btw/btw.json) — side questions rarely need a flagship model. Waiting shows a BorderedLoader (Esc aborts), the answer a homegrown Markdown pager (j/k scroll, PgUp/PgDn, Home/End, progress %).

Usage

Install

bash
pi install npm:@piex-dev/btw

Source: extensions/btw

Usage

bash
/btw what's this project's Docker base image?

The answer shows in the pager; after closing, the session is untouched.

Configuration

~/.pi/piex-dev/btw/btw.json:

json
{ "model": "anthropic/claude-haiku-4-5", "thinkingLevel": "low" }

Falls back to the current session model if unset. Config is re-read each question, no /reload needed.

Verify

bash
pi -e ./extensions/btw/src/btw.ts -p "what is 1+1" --no-session

Implementation

~700 lines, single file. Core modules: /btw command, loadCompleteSimple (compatible with pi-ai 0.79 root export and 0.80 /compat subpath), resolveBtwModel (config→current-model fallback + cred check), buildConversationContext (compressed snapshot), completeSideQuestion (AbortSignal), BtwAnswerPager (Markdown scroll reader).

omp btwbtw (piex)
engine-level side callcompleteSimple side call
never writes to sessionsame (architectural guarantee)
Bun runtimeNode.js (pi)

Design notes

ProjectMechanismpiex choice
pi-extensions pi-btwcompleteSimple side call + session snapshot + settings file + loader/pager UIAdopted the overall architecture, keeping piex's arg-less interactive input; pi-ai 0.79/0.80 compat loading reused directly

Changelog

Roadmap

DirectionPlan
Snapshot lacks system prompt & full tool resultsselectively carry by relevance (e.g. always keep the last toolResult full text)
No multi-turn follow-upadd an input line in the pager; follow-up carries the prior turn (still no session write)
Model config hot-updateadd a /btw model quick config command

Version history

VersionDateChanges
0.1.02026-07-19inject + filter architecture: [BTW] question injected into the main agent loop, tools disabled by prompt, later filtered via a context hook guessing "skip next assistant"
0.2.02026-07-21side-call architecture: completeSimple one-shot request + ≤40K session snapshot, Q&A never writes to session; adds btw.json dedicated model/thinking level, interruptible loader, Markdown pager

0.1.0 lesson: "pollute first, clean later" is hard to do strictly in an async message stream — when an assistant reply carries a toolCall sequence the filter guess misaligns and leaks; when the agent is busy, queued messages let the btw marker land on the wrong turn. 0.2.0 switches to "don't produce pollution", and the whole class of boundary issues vanishes.