Repository navigation
Description
Summary
A Pi extension slash command that completes without starting Pi's main agent run leaves its BB thread active indefinitely. Subsequent input, including a command intended to cancel the extension's background work, remains blocked behind that active turn.
Pi's extension-command contract permits this command shape, so BB should settle the submitted turn after a handled command rather than requiring an agent_end event that will not occur.
Versions and environment
- bb 0.43.0, managed installation
- Pi 0.85.1
- Ubuntu 26.04 LTS (x86_64), Node v22.22.1
- Pi provider in a local project environment
- Source inspection also checked upstream
mainatc024ceac524882b7bf9fbef41c14c4911919de4c
Steps to reproduce
The behavior was observed in an existing BB Pi thread. A clean, standalone reproduction on the latest main has not been run, so the following minimal fixture is unverified.
-
In a project used by a BB Pi thread, load a Pi extension that registers a slash command whose handler completes without starting the main Pi agent run, for example:
pi.registerCommand("return-now", { description: "Return without an agent turn", handler: async (_args, ctx) => { ctx.ui.notify("command handled", "info"); }, });
-
Send
/return-nowto the BB Pi thread. -
Send another prompt or another extension command.
Expected vs actual
Expected: Once Pi has handled /return-now, BB marks that submitted turn complete. The next prompt or extension command can be dispatched normally.
Actual: The BB thread remains active after the command handler returns. A later command is blocked behind the active turn, so it cannot be used to control or cancel the extension's background work.
No public-safe terminal or server-log excerpt was captured for this report; the observed symptom is the persistent active turn and blocked follow-up input.
Evidence
At upstream main commit c024ceac524882b7bf9fbef41c14c4911919de4c, PiRpcSession.prompt() creates a pending run settlement before it sends Pi the RPC prompt request:
bb/plugins/provider-pi/src/bridge/rpc-session.ts
Lines 334 to 359 in c024cea
this.isProcessing = true; const tracked = this.trackPendingInputConsumption("followUp"); const settlement = new Promise<PiPromptRunOutcome>((resolve) => { this.pendingRunSettlements.push({ resolve }); }); const settled = this.dispatchWithTransientAuthRetry( child, { type: "prompt", message: text, ...(images && images.length > 0 ? { images } : {}), streamingBehavior: "followUp", }, NO_REQUEST_TIMEOUT, ).then( async (): Promise<PiPromptRunOutcome | null> => { if (tracked.pending.queuedText !== null) { this.dropRunSettlement(); return null; } this.resolvePendingInputConsumption(tracked.pending); const outcome = await settlement; return outcome; }, (error: unknown): PiPromptRunOutcome | null => { this.isProcessing = false;
The bridge reports the prompt settled only after that settlement resolves:
bb/plugins/provider-pi/src/bridge/bridge.ts
Lines 974 to 992 in c024cea
function startPiPrompt( threadSession: ThreadSession, threadId: string, text: string, images: ImageContent[], ): Promise<void> { const dispatch = threadSession.session.prompt( text, images.length > 0 ? images : undefined, ); void dispatch.settled.then((outcome) => { if (outcome === null) { return; } reportPromptSettled({ ...(outcome.error !== undefined ? { error: outcome.error } : {}), sessionSerial: threadSession.sessionSerial, threadId, });
The pending settlement is resolved in the agent_end event path:
bb/plugins/provider-pi/src/bridge/rpc-session.ts
Lines 547 to 561 in c024cea
if (event.type === "agent_end") { this.deliverInOrder(async () => { const leafId = await this.takeAgentEndLeaf(); if (leafId !== null) { this.lastKnownLeafId = leafId; } this.onEvent({ ...event, ...(this.lastKnownLeafId === null ? {} : { providerCheckpointId: this.lastKnownLeafId }), }); this.settleRun(event); }); return;
Pi documents agent_end as the end of a low-level agent run, while extension commands are a separate API; it also documents command handlers that call ctx.waitForIdle() and then return:
- https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/extensions.md#agent_start--agent_end--agent_settled
- https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/extensions.md#ctxwaitforidle
No public-safe investigation link is available.
Suggested fix
Add an explicit completion path for a Pi RPC prompt that Pi handled as an extension command and that therefore does not produce an agent run. The bridge should resolve the corresponding BB turn without waiting for agent_end. The completion signal should be explicit rather than inferred from timing, so a normal slow-starting agent run is not settled prematurely.
What you ruled out
- This is not caused by
ctx.waitForIdle()itself: Pi documents it for command handlers, and it returns immediately when no agent or compaction run is active. - This is distinct from closed issue Pi extension-triggered turn stays working after agent_end #1633: that issue concerned a valid
agent_endevent rejected by message-schema validation. Here the command intentionally produces no agent run and thus noagent_endevent. - Searches of open and closed issues for
agent_end, Pi extension commands, and Pi bridge command handling found no issue for this no-agent_endcommand-completion path.
Suggested priority and effort
Medium — affects any BB Pi extension whose slash command returns without starting Pi's main agent run. There is no in-thread workaround once the command has been invoked; stopping the thread is the practical recovery.
Checks
- I reproduced the symptom in an existing BB Pi thread and clearly note that a clean reproduction on latest
mainis unverified. - I searched open and closed issues for the same command-completion path.
AGENT GENERATED
Activity
bb-slop-cop commentedon Sep 16, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotClassified as Bug · Medium priority · Medium effort; added
providers,provider-pi, andconfirmed-repro.Reproduction and root-cause report: REPRODUCED, high root-cause confidence. In two clean checkouts of trusted
main, a real Pi command completed with no agent events, but BB’s settlement remained pending. The embedded regression test fails withexpected 'pending' to be 'settled'.BB waits for
agent_end, while Pi acknowledges handled commands without starting an agent run. Tested the repository’s pinned Pi 0.84.0; Pi 0.85.1 and the browser follow-up queue were not exercised.No PR: safely distinguishing command completion from ordinary prompt preflight requires completion-contract/design work outside this rule’s simple-fix limits.
dillonzq commentedon Sep 22, 2026
Reproduced again on current upstream
mainat18960354e462d514c0d6071ba1ed0f8f2acd625cusing a real Pi 0.84.0 subprocess (the repository-pinned dependency), Node 22.23.2, and macOS 27.0. The regression uses an isolated Pi agent directory and a local extension; no model API request or Mane Control installation is needed.The extension registers
/return-now, whose handler only callspi.appendEntry("command-handled", {}). The test calls the actualPiRpcSession.start()andprompt("/return-now"), awaitsdispatch.consumed, and then checksdispatch.settled:Pi successfully acknowledges the command but emits neither
agent_startnoragent_end. The unmodified bridge keeps the settlement pending. This is a subprocess/bridge reproduction, not a fresh full-UI reproduction on main.Separately, the same symptom occurred twice in installed BB 0.43.3 with Pi 0.87.0 and Mane Control 0.1.2. In investigation thread
thr_v5vxuwc38u,/ponytail litewas followed byentry_appendedwithcustomType: "ponytail-mode"anddata: { "mode": "lite" }, then:Stopping and submitting the same command reproduced the failure. This rules out Mane Control as a necessary cause and distinguishes the issue from stalled model inference: the mode change already completed.
Current-main code still creates a settlement and waits after the prompt acknowledgement; the normal settlement path requires
agent_end.I am testing a fix and will link a PR, including checks that ordinary preflight acknowledgements and queued inputs are not treated as completed runs.
cameronm123 commentedon Oct 11, 2026
Related final-settlement contract evidence from installed BB 0.46.0 with Pi 1.1.0. This is source inspection, not a reproduction of premature completion or of this issue's handled-command symptom.
Pi's installed RPC documentation distinguishes the events:
The installed BB Pi bridge resolves pending settlements in the
agent_endpath. The relevant extracted behavior is:The excerpt above omits checkpoint lookup and error propagation for clarity. Separately,
trackProcessingStateclears processing onagent_endwhenwillRetry !== true.The handled-command fix and normal-run completion need distinct contracts. A prompt can complete without an agent run, as demonstrated in this issue. A low-level run can also finish before Pi has settled all continuation work. Checking only
willRetrydoes not cover the documented continuation cases.For Pi versions that expose
agent_settled, please consider making that event the owner of final run completion while retainingagent_endcheckpoints. Bind legacy behavior to an explicit supported version or capability. This report does not claim that current upstream main still has the installed-bundle behavior.Suggested acceptance cases are ordinary completion, retry, overflow recovery, automatic and manual compaction, extension continuation, queued steering and follow-up work, handled input with no run, cancellation, and session shutdown. Each submitted input should produce exactly one final settlement, with no intermediate completion forwarded to automatic judges.
No installed bundle was patched and no live failure injection was performed.
mlegls commentedon Oct 25, 2026
Still occurs on installed BB 0.47.0 with Pi 1.4.0 (Linux). An extension command (`/edit-here`, which only sets in-memory state and calls `pi.appendEntry`) left the thread on Working until it hit `provider_turn_start_timeout` after 120s. Stopping the thread killed the Pi process, so the command's in-memory effect was also lost.
Pi 1.4.0 already reports when no run will follow. The RPC `prompt` reply now carries a `disposition`, emitted from `AgentSession.prompt`'s `preflightResult` callback (`dist/modes/rpc/rpc-mode.js`, `dist/core/agent-session.js`):
When the prompt reply's `data.disposition === "handled"`, the bridge could resolve the settlement immediately instead of waiting for `agent_end`/`agent_settled`. That separates a handled command from a normal preflight acknowledgement without any guessing on BB's side.
Workaround for extension authors until then: have the command start a turn under BB, for example `pi.sendMessage({...}, { triggerTurn: true })`.
mlegls commentedon Nov 13, 2026
Additional input-event case on installed bb 0.48.1: an extension consumes the first prompt with { action: "handled" } and calls pi.sendMessage({ customType, content, display: true }). The thread stayed active with no displayed response for 45 seconds; the Pi transcript retained the custom message. This appears to be the same no-agent-run settlement gap as the slash-command case, with an additional custom-message display symptom.
Versions and environment
Minimal fixture (unverified standalone reduction)
Load this extension in a bb Pi project's .pi/extensions/handled.ts, then send "handled-input-repro":
Expected: display the custom message and settle the input without starting a model run.
Observed in the original extension: no visible message and no idle transition within 45 seconds. Disposable thread thr_urdf59vqwg contained only provisioning and identity events until manual stop; its Pi transcript retained the custom message. No public-safe raw event dump was retained, so this is an observation summary rather than a verbatim log.
Workaround and limits
For our terminal Learn-entry refusal only, writing the refusal to stderr and calling ctx.shutdown() from the handled input makes bb record turn/failed and an Error containing the refusal. That recovers a visible terminal error, not normal completion of a handled prompt. Ordinary handled prompts still need to settle and display their response.
No agent run is intended in this case; waiting for model output cannot resolve it. Please include input-event handlers alongside slash commands when fixing #3792. We saw #6631 closed unmerged; no claim is made here about a fix in current upstream main.
Origin: Common Concept implementation thread thr_8f7ufg5cff; affected disposable thread thr_urdf59vqwg; reporting thread thr_53bf96e8r2. Concept source base for this report: e04f9831c577a081bc7150f818b7b466ef0db28d (not a bb source commit). No new model call or reproduction thread was started for this comment.
mlegls commentedon Nov 24, 2026
Retested the standalone
inputfixture from the earlier comment on BB 0.50.1 (npm install, Linux execution host), with a local scripted Pi model. Settlement works; the displayed custom reply is still missing from the BB conversation..pi/extensions/handled.tsfixture and sendhandled-input-reproas the first prompt. BB recordsturn/started,turn/input/accepted, andturn/completed(status: completed) and returns to idle. The scripted provider received no request on this turn.bb thread log <id> --all --format minimalshows the user's prompt with no response. The first-turn raw event log has no message item. Pi's session contains{"type":"custom_message","customType":"handled-input-repro","display":true,"content":"Handled without starting an agent run"}(project/session metadata omitted).So #7583 fixes the stuck-turn part of this input-handler case in 0.50.1. The remaining result here is a reply retained by Pi but absent from BB's conversation timeline. The observations above are from BB's CLI timeline and event log, not a desktop UI inspection.