Skip to content

Pi SDK bridge does not expose standard extension UI requests to BB #1668

Closed

Description

@thesobercoder

Summary

BB binds Pi extensions without providing Pi’s ExtensionUIContext.

The current Pi bridge calls:

await session.bindExtensions({
  mode: "rpc",
  abortHandler: ...,
  shutdownHandler: ...,
  onError: ...,
});

It does not pass uiContext.

As a result, ctx.hasUI is false inside Pi extensions.

Standard extension UI calls such as these cannot reach the BB interface:

  • ctx.ui.confirm()
  • ctx.ui.select()
  • ctx.ui.input()
  • ctx.ui.editor()
  • ctx.ui.notify()

Setting mode: "rpc" does not create the extension UI transport when an application embeds Pi through the SDK.

The SDK embedder must provide an ExtensionUIContext.

Related work

Issue #1391 fixed the Pi extension lifecycle by adding bindExtensions().

That fix lets extensions receive events such as session_start and session_shutdown.

However, it does not provide the UI context that extensions use for interactive requests.

This issue tracks that separate integration gap.

Current behavior

A Pi extension can call a standard UI method:

const allowed = await ctx.ui.confirm(
  "Run command?",
  "This command modifies files.",
);

In the normal Pi TUI, the user receives a confirmation dialog.

In BB, the extension has no UI context.

The request cannot appear in BB’s pending-interaction interface.

An extension that checks ctx.hasUI can only fail closed or use its own fallback behavior.

Expected behavior

BB should provide an ExtensionUIContext when it calls session.bindExtensions().

The context should forward portable Pi extension UI requests through BB’s provider-independent interactive-request system.

The expected flow is:

Pi extension calls ctx.ui.confirm()
→ BB ExtensionUIContext creates a correlated bridge request
→ BB creates a pending interaction
→ BB shows the request to the user
→ User responds
→ BB sends the response to the Pi bridge
→ The ExtensionUIContext promise resolves
→ The Pi extension continues

Suggested implementation direction

  1. Implement an ExtensionUIContext adapter in the Pi bridge.
  2. Pass the adapter to session.bindExtensions({ uiContext, ... }).
  3. Send request and response messages through the BB provider bridge protocol.
  4. Map approval-like requests onto BB’s existing pending-interaction system.
  5. Keep a request ID and the applicable session, thread, and turn scope.
  6. Cancel unresolved requests when the session stops or is replaced.
  7. Validate responses before resolving the extension promise.
  8. Define timeout and disconnect behavior that fails closed.

Pi CLI RPC’s extension_ui_request and extension_ui_response messages can serve as a reference.

BB does not need to run the Pi CLI to implement this.

The Pi SDK already provides the required ExtensionUIContext integration point.

Scope

The first implementation should support portable UI methods:

  • confirm
  • select
  • input
  • editor
  • notify, where applicable

TUI-only methods are not part of this request.

In particular, ctx.ui.custom() accepts an executable Pi TUI component factory and cannot be serialized into the BB interface.

Extensions that use ctx.ui.custom() must provide a portable fallback.

Acceptance criteria

  • BB passes an ExtensionUIContext to session.bindExtensions().
  • ctx.hasUI is true for a Pi extension running in BB.
  • A fixture extension can call ctx.ui.confirm() and receive the user’s decision.
  • Supported select, input, and editor requests receive validated responses.
  • Approval-like requests use BB’s existing pending-interaction interface.
  • Stopping or replacing a session cancels all unresolved requests.
  • A response from an old session cannot resolve a request in a new session.
  • A disconnect or timeout fails closed.
  • Tests cover request correlation, user response, cancellation, and session replacement.
  • The implementation does not claim support for ctx.ui.custom().

Current code

The relevant call is in:

packages/agent-runtime/src/pi/bridge/sdk-session.ts

The current implementation calls bindExtensions() with mode: "rpc" but without uiContext.

References

Activity

  1. added
    providers
    provider-pi
    on Aug 18, 2026
  2. ymichael commented on Oct 8, 2026

    @ymichael
    Collaborator

    Fixed by #3228: Pi select/confirm/input/editor extension requests now show up as answerable bb interactions.

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

    provider-piproviders

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions