/btw Side Question/btw <question> lets the user ask a quick side question without interrupting the current coding task or adding the question/answer to the model-visible main conversation.
This is a sidecar model request, not a normal turn, not a tool call, not a subagent task, and not a workflow activity. It exists for small clarifying questions such as "btw what does this acronym mean?" while the main session is idle or while a long turn is still running.
The important part is not the UI shape. The core pattern is:
/btw cancel only the side request./btw edit files, run commands, call tools, ask permissions, mutate goals, update todo state, or create checkpoints./btw as a hidden continuation mechanism for the main agent./btw answers as target/goal completion evidence./btw a background subagent. Background subagents have task lifecycle, notifications, and child sessions; /btw is a short local answer.ZCODE_* environment variable for this feature. If a later version needs configuration, define it in this spec first./btw <question>:
TurnStarted / user / assistant transcript pair;Empty input returns local usage text:
Usage: /btw <question>
If /btw is submitted before any normal model request exists, runtime falls back to a freshly built context snapshot for the current session. This may miss prompt cache but must still answer.
The side question boundary should live in core runtime because it needs access to model adapter, context builder, message projection, tool contracts, trace context, and event store. Bootstrap and TUI own command parsing and presentation.
TUI / command center
-> ZCodeApp.askSideQuestion()
-> AgentRuntime.askSideQuestion()
-> SideQuestionRuntime
-> latest cache-safe request snapshot
-> model adapter
-> side_question_* session events
The runtime method must not call filesystem, child process, network, config, or provider SDKs directly. Provider I/O still goes through the configured modelAdapter.
After every main model request is built, runtime records an in-memory LatestModelRequestSnapshot:
interface LatestModelRequestSnapshot {
model: ModelRef
messages: ModelMessage[]
tools: ModelToolContract[]
providerOptions?: Record<string, unknown>
traceContext: TraceContext
capturedAt: Date
sourceTurnId?: TurnId
}
This snapshot is a copy, not a live reference into MessageHistory. The goal is to keep the provider-visible prefix byte-stable for prompt caching. It should be captured at the same boundary that emits/logs ModelRequest, before mutable runtime state can advance.
When /btw runs:
LatestModelRequestSnapshot if present.Using the same tool schema preserves cache characteristics. Tools remain impossible to execute because the side-question permission/tool execution path denies every tool call with a stable side_question_tools_denied reason.
The appended message should be provider-visible English and should say:
The exact wording should be centralized as a named constant so tests can assert it remains action-denying.
interface SideQuestionRequest {
question: string
sessionId: SessionId
traceContext?: TraceContext
abortSignal?: AbortSignal
}
interface SideQuestionResult {
sideQuestionId: string
status: "completed" | "failed" | "cancelled"
question: string
answer?: string
error?: string
usage?: ModelUsage
cache?: {
usedSnapshot: boolean
sourceTurnId?: TurnId
cacheReadTokens?: number
cacheWriteTokens?: number
}
}
ZCodeApp should expose:
askSideQuestion(
question: string,
options?: {
abortSignal?: AbortSignal
onEvent?: (event: SessionEvent) => void | Promise<void>
traceContext?: TraceContext
},
): Promise<SideQuestionResult>
This is separate from submitPrompt() so callers cannot accidentally create a normal turn.
Add session events for observability without polluting the conversation transcript:
side_question_startedside_question_completedside_question_failedside_question_cancelledPayloads should include:
sideQuestionIdquestionPreviewanswerPreview or artifact reference when output is largestatususagecache.usedSnapshotsourceTurnIddurationMsThe full question/answer may be persisted in the event store only through the same bounded payload/artifact policy used by tool results. Main MessageHistory must not receive a user or assistant message for /btw.
All events carry the current session traceId. If /btw runs while another turn is active, its spanId must be a sibling of the active turn span, not a child of the active turn's abort scope.
Register /btw as a local command:
/btw <question>
TUI behavior:
/btw in the input as a known slash command.Headless --prompt "/btw ..." may print the side answer and exit with normal command status, but must still avoid creating a normal turn.
ZCode app-server should not broadcast /btw as a normal available command until ZCode protocol clients have a side-result presentation. The structured future surface should be an extension method:
zcode.dev/session/sideQuestion
Request fields: sessionId, question.
Response fields: SideQuestionResult.
ZCode protocol clients that do not implement this extension can keep using normal prompts; they should not receive /btw in command suggestions.
/btw unless the whole session is closing./btw in commands.md.SideQuestionRequest, SideQuestionResult, and side-question events.LatestModelRequestSnapshot when a model request is made.AgentRuntime.askSideQuestion().ZCodeApp.askSideQuestion()./btw <question> through command center.slash_command for P0 to avoid schema churn./btw while runtime.getActiveTurnInfo() returns an active turn.zcode.dev/session/sideQuestion.sessionId and non-empty question./btw in available_commands_update unless client capability negotiation later asks for it./btw with empty args returns usage and does not call the model./btw with args calls askSideQuestion() instead of submitPrompt().MessageHistory and does not emit normal turn lifecycle events./btw does not abort an active normal turn./btw is answering./btw by default.model.lite for /btw; cache reuse argues for main model by default.side_question history kind can be added if UX needs filtering.