Skip to content

Pi: a message sent during an extension-started compaction is steered, rejected, and lost #6379

Closed

Description

@steveafrost

Summary

When a Pi extension starts a compaction on its own (ctx.compact(), for example after a run settles), a message sent to the thread during that compaction is not queued. bb sends it into the compaction turn as a steer, Pi rejects it, and the thread ends in error. The message is lost. I expected it to wait and be delivered once compaction finishes, the way it does during a bb /compact.

Versions and environment

  • bb 0.47.1 (desktop app), and reproduced from source at b6743a3 with pnpm dev
  • macOS 27.0.1
  • Pi 1.4.0, provider pi

Steps to reproduce

  1. Add a Pi extension that calls ctx.compact() on agent_settled and holds session_before_compact for a few seconds, so the compaction window is easy to hit. (I used one that only arms itself when a marker file exists, and returns a custom summary after 12 s.)
  2. Start a Pi thread with a prompt large enough to be compactable (over Pi's keepRecentTokens, ~20k tokens).
  3. Arm the extension and send a follow-up. When that run settles, the extension starts compaction.
  4. While compaction is running, send another message: bb thread tell <thr> "Reply only with: third".

Expected vs actual

Expected: the message is queued (waitingOn: thread-busy) and sent when compaction ends.

Actual: tell returns delivery: sent, mode: steer, then the thread records:

client/turn/rejected  {"reason":"command_failed","message":"Cannot submit a prompt while compaction is in progress. Wait for compaction to finish and retry."}
system/error          {"code":"thread_command_failed","message":"Command turn.submit failed", ...}
provider/error        {"message":"Provider error","detail":"Cannot submit a prompt while compaction is in progress..."}
turn/completed        {"status":"failed"}

Compaction itself still completes 11 s later, but the compaction turn is marked failed and the message is never delivered.

Evidence

  • Pi opens a bb turn for a manual compaction_start (delta-translation.ts#L727), so the server sees an active turn and routes the send to steer.
  • The server only queues sends during compaction when the active turn's request was a bb /compact command (thread-events.ts#L865-L889, used at dispatch-attempt.ts#L495). A compaction the provider started has no bb request, so it is not recognised.
  • Pi's AgentSession.prompt() throws this error whenever a manual compaction is running (extension ctx.compact() or RPC compact). It does not throw during auto-compaction.

What I ruled out

Suggested priority

Hits anyone running an auto-compacting Pi extension (we use one internally that compacts past a token threshold). The user's message is lost and the thread ends in error; the workaround is to resend after compaction.

AGENT GENERATED

Activity

  1. added theissue type on Oct 27, 2026
  2. added
    providers
    threads
    provider-pi
    confirmed-repro
    on Oct 27, 2026
  3. bb-slop-cop commented on Oct 27, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority High · Effort Medium.
    • Labels: providers, threads, provider-pi, confirmed-repro.
    • Report: https://get-bb.github.io/reports/issues/6379.html — REPRODUCED, high root-cause confidence. The corrected regression fails on trusted main in two clean checkouts: sends dispatch instead of waiting during an active provider-owned compaction.
    • Root cause: the compaction wait gate checks bb command requests but misses an open root compaction item in a provider-owned maintenance turn.
    • Fix: Queue sends during provider-owned compaction turns #6381 — ready, not merged; 248 changed text lines across two server files. The regression now passes, all 102 relevant tests pass, and server typecheck/build and diff checks pass.
    • Scope: verified at the public server API with real migrated SQLite; the live Pi extension rejection/message-loss cascade was not run.
  4. added a commit that references this issue on Oct 28, 2026
    7421e65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproprovider-piprovidersthreads

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions