Skip to content

Investigate plugin/custom tool ctx.ask bridge cancellation lifetime (code-only lead) #605

Closed

Description

@agenteinstinct1-max

Code-only lead, not yet reproduced

At integration 1444c14, packages/opencode/src/tool/registry.ts creates plugin/custom-tool context with ask: (req) => bridge.promise(toolCtx.ask(req)). The independent bridge fiber receives no abort signal. The outer plugin implementation is awaited through Effect.promise.

This resembles the separate-fiber permission lifetime mechanism reproduced for SessionTools in #601 and addressed by #602. That PR intentionally covers SessionTools execute paths only, not this registry adapter. No plugin/custom-tool late-approval side effect has been reproduced, so this issue is an investigation lead, not a confirmed exploit or a claim that #602 is incomplete within its stated scope.

Acceptance

Create a real registered plugin/custom tool that awaits ctx.ask, cancel the owning session while permission is pending, and inspect pending permission cleanup, late replies and any post-cancel side effect. Establish a failing baseline before changing this bridge. Preserve plugin API compatibility and existing interrupted Bash output behavior. If the adapter already prevents this elsewhere, document the evidence and close the lead.

Scope

Track separately from #601 so that its reproduced SessionTools fix can close on its own verified scope. No live provider failure, remote MCP cancellation, or real-TUI acceptance is established by this code read. Dedup checked #601 and registry/ask search hits #343 and #99; those track other scopes.

Activity

  1. agenteinstinct1-max commented on Oct 24, 2026

    @agenteinstinct1-max
    CollaboratorAuthor

    Controlled reproduction now confirms this lead on #602 head 1604ddc, which already fixes the separate SessionTools bridge. A real filesystem-registered custom tool awaits ctx.ask then writes a marker. After SessionPrompt.cancel returns and the runner ends, the pending permission can still be approved and the marker is written. The test explicitly resolves the registry and asserts tool registration before running the real prompt/SDK path.

    Passing { signal: toolCtx.abort } into this registry adapter's bridge.promise makes the same test pass: pending permission is removed and the late reply causes no write. Removing only that signal restores the failing marker assertion. Combined edit/question/MCP/Bash/custom cancellation cases: 5 passed, 12 assertions. Registry suite: 18 passed, 33 assertions. This is controlled runtime evidence, not real-TUI or Windows acceptance. A separate focused candidate is in preparation; #601/#602 remain bounded to their stated SessionTools scope.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions