Skip to content

Let in-flight plugin tool calls finish when the plugin reloads #7336

Description

@matthiasvongrundherr

The workflow

We run a business-automation plugin whose agent tools perform write operations that take from a few seconds up to several minutes (closing an issue end to end, writing cards, publishing files). Each deploy of the plugin runs bb plugin reload <plugin> while agent threads call these tools at any time, so reloads regularly hit running tool calls. On 2026-11-09 bb reloaded the plugin 23 times, 11 of them while at least one tool call was running. On 2026-11-10 a single reload aborted ten long-running tool calls in ten threads at once.

What happens today

Observed on the latest release, desktop v0.49.0 (7b26cae), macOS 26.6, in Claude Code 2.1.322 and Codex CLI 0.167.0 threads: a reload during a running tool call aborts that call's signal. Our tools honoured the signal like a user stop and quit mid-write. That left half-finished writes and calls whose outcome was unknown, and grandchildren of the killed child processes kept running orphaned. We have not tested main.

From the code at 7b26cae: a reload first loads the new copy, so new calls already go there, and then disposes the old copy in disposePluginInstance (plugin-runtime.ts#L2123-L2173):

  1. stopping.abort() without a reason, then abortPluginToolCallsForPlugin(id, "plugin-disposed") aborts every in-flight tool call of the old copy (plugin-tool-calls.ts#L150-L154).
  2. Services stop, dispose hooks run, and drainInvocations waits at most serviceStopTimeoutMs, 5 s by default (plugin-runtime.ts#L980-L991, #L350).
  3. released.abort() then rejects every caller still waiting with plugin "…" was reloaded or disabled before … finished (plugin-runtime.ts#L884-L932).

What this means for a plugin:

  • Agent tools get the tool-call signal (plugin-tool-calls.ts#L129-L136, plugin-service.ts#L2532-L2543), which the reload aborts with reason plugin-disposed. A tool that does not inspect signal.reason treats the reload as the user's stop.
  • CLI commands get AbortSignal.any([ctx.signal, stopping]) (plugin-service.ts#L2282-L2309, plugin-runtime.ts#L899-L905). On a reload it aborts with the default AbortError, because stopping.abort() passes no reason, so a command cannot tell a reload from a stopped or disconnected caller.
  • Work that needs more than 5 s cannot finish in the old copy and still report its result. The caller gets the generic release error, and a result that completes later has no path back to the thread.

What you would expect

Any of these would solve it. The first is the usual graceful-reload behavior: old workers finish in-flight requests while new requests go to the new copy.

  1. A reload does not abort the old copy's in-flight tool calls. Only disable, uninstall, a thread stop or a thread deletion aborts them. The old copy stays alive until its in-flight calls settle, bounded by a drain timeout the plugin can declare.
  2. If an unbounded drain is not wanted: let a tool detach and deliver its result later, and keep detached results deliverable across a reload. bb already detaches calls that wait for user input, but drops a detached result once a reload or disable has aborted its call (plugin-tool-calls.ts#L33-L37, #L89-L121).
  3. Independently of 1 and 2: abort CLI command signals with the same plugin-disposed reason that tool calls get, so plugins can tell a reload from a stop.

Context and alternatives

Our workaround, not a fix: we treat plugin-disposed, and for CLI commands a reasonless abort followed within 1.5 s by our own background service stopping, as a reload. The work keeps running in the old copy, the caller gets "still running, do not retry" after 4 s, and long results are picked up by the new copy through a status call. A process-wide registry lets a later stop of the same thread still reach work that survived a reload, and a real abort kills the whole process group. It works, but it depends on the current dispose order and the 5 s window.

Not a duplicate of #5969 or #6464: they settle the callers of a disposed copy and tie its work to that copy; this asks to let that work finish. #4432 covered the same plugin-disposed abort for pending interactions, and #5359 covers tool lists of running sessions after a reload. This affects any plugin whose tools write for longer than a few seconds. The investigation behind this request is internal and cannot be linked.

Checks

  • I searched open and closed issues for the same request.
  • If an agent wrote this, the body ends with > AGENT GENERATED.

AGENT GENERATED

Activity

  1. added
    plugins
    on Nov 10, 2026
  2. bb-slop-cop commented on Nov 10, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied Type: Feature · Priority: High · Effort: High · Labels: plugins. All four classifications were missing; no existing values were replaced. Re-read and verified the final Type after the writes.

    Trusted origin/main explicitly cancels old-instance work during disposal, and its lifecycle tests assert cancellation on reload. Graceful draining therefore adds lifecycle behavior rather than restoring an existing guarantee. High priority reflects the reported risk of interrupted writes; high effort reflects the required decisions about draining, resource ownership, cancellation, and result delivery.

    No reproduction report or pull request: this is a feature requiring lifecycle/product decisions, outside the bug-only autopilot path.

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

    plugins

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions