← reports

#8023 · Pi child operations lose delegation identity

BugMedium priorityMedium effortprovidersprovider-piGitHub issue

November 22, 2026 · trusted origin/main 796cdcc0f4bf8a55e23664035c54e8db6fe9d272

PARTIALLY REPRODUCED · Root-cause confidence: medium overall; high at the tested translation boundary.

1. TL;DR

Pi child-launch tool events are translated into ordinary tools rather than delegation items. A newly authored diagnostic sends three successful child operations through the actual Pi translator and shared delta assembler: all three start and finish, but their item kind is toolCall. This result repeated in a second clean trusted checkout. The translator has no child-delegation classification or asynchronous child-completion correlation, while the timeline distinguishes tools from delegations. The third-party extension, macOS desktop display, and completion after the initiating tool returns were not executed, so this is not an end-to-end reproduction of the reported workflow.

2. Claims vs findings

ClaimFindingEvidence
Successful child operations become generic tool items.Verified at translator/assembler boundaryThree starts and three successful completions all have kind toolCall in both clean runs.
Each child lacks delegation identity.Verified for synthetic Pi tool lifecycle inputThe diagnostic confirms three separate successful operations before failing the delegation-kind assertion.
The desktop groups these rows as tools.Source-supported, not visually reproducedThe trusted timeline categorizes tool and delegation rows separately. No browser or desktop screenshot was taken.
The third-party extension finishes three parallel children after launch returns.UnverifiedNo extension installation or real model invocation was performed; input is newly authored synthetic data, not an extension recording.
A proposed change fixes the full workflow.UnverifiedLinked closed PR was read statically only. Its branch, tests, and code were never executed.

3. Environment

4. Minimal reproduction

  1. Clone the public target repository and pin the trusted base shown below.
  2. Perform the frozen install and focused dependency build.
  3. Copy the complete inline diagnostic source below into the path shown.
  4. Run the diagnostic; exit 1 is expected on this base. Then run the two existing translator suites as a control.
git clone https://github.com/get-bb/bb.git bb-8023
cd bb-8023
git checkout --detach 796cdcc0f4bf8a55e23664035c54e8db6fe9d272
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=bb-plugin-provider-pi...
# Save the inline diagnostic as plugins/provider-pi/src/issue-8023.repro.test.ts
pnpm exec turbo run test --filter=bb-plugin-provider-pi --force -- src/issue-8023.repro.test.ts
# Existing owner-boundary coverage, excluding the intentional diagnostic failure
pnpm exec turbo run test --filter=bb-plugin-provider-pi -- src/delta-translation.test.ts src/delta-translation.errors.test.ts

Expected: three item/started entries of kind delegation. Actual: three item/started entries of kind toolCall; all three item/completed entries also have kind toolCall and status completed. The counts and successful statuses pass before the identity assertion fails.

{"started":[{"event":"item/started","kind":"toolCall","status":"pending"},{"event":"item/started","kind":"toolCall","status":"pending"},{"event":"item/started","kind":"toolCall","status":"pending"}],"completed":[{"event":"item/completed","kind":"toolCall","status":"completed"},{"event":"item/completed","kind":"toolCall","status":"completed"},{"event":"item/completed","kind":"toolCall","status":"completed"}]}
Expected: ["delegation", "delegation", "delegation"]
Received: ["toolCall", "toolCall", "toolCall"]
Test Files  1 failed (1)
Tests       1 failed (1)

This is a backend event-translation reproduction, not a screenshot of the product. It does not fabricate the extension's asynchronous notification contract or claim a real parallel execution.

Complete diagnostic source
import { expect, it } from "vitest";
import {
  experimental_createDeltaAssembler as createDeltaAssembler,
  type ThreadEvent,
} from "@get-bb/plugin-sdk/provider-bridge/testing";
import { createPiDeltaTranslator } from "./delta-translation.js";

it("preserves successful child operations as distinct delegations", () => {
  const translator = createPiDeltaTranslator({
    resolveModelContextWindow: () => undefined,
  });
  const assembler = createDeltaAssembler({
    providerId: "pi",
    entropyPrefix: "issue-8023",
    textDeltaFlushMs: 0,
  });
  const events: ThreadEvent[] = [];
  const translate = (event: unknown) => {
    events.push(
      ...assembler.assemble({
        threadId: "synthetic-thread",
        deltas: translator.translate(event, { threadId: "synthetic-thread" }),
      }),
    );
  };

  translate({ type: "agent_start" });
  for (const child of [1, 2, 3]) {
    translate({
      type: "tool_execution_start",
      toolCallId: `child-${child}`,
      toolName: "subagent_launch",
      args: { agent: "worker", task: `Inspect synthetic sample ${child}.` },
    });
    translate({
      type: "tool_execution_end",
      toolCallId: `child-${child}`,
      toolName: "subagent_launch",
      result: { content: [{ type: "text", text: `Sample ${child} inspected.` }] },
      isError: false,
    });
  }

  const started = events.filter((event) => event.type === "item/started");
  const completed = events.filter((event) => event.type === "item/completed");
  console.info(
    JSON.stringify({
      started: started.map((event) => ({
        event: event.type,
        kind: event.item.type,
        status: event.item.status,
      })),
      completed: completed.map((event) => ({
        event: event.type,
        kind: event.item.type,
        status: event.item.status,
      })),
    }),
  );
  expect(started).toHaveLength(3);
  expect(completed).toHaveLength(3);
  expect(completed.map((event) => event.item.status)).toEqual([
    "completed",
    "completed",
    "completed",
  ]);
  expect(started.map((event) => event.item.type)).toEqual([
    "delegation",
    "delegation",
    "delegation",
  ]);
});

5. Root cause

classifyPiToolUse recognizes command and file-change tools, then returns a generic tool for every other name. There is no Pi subagent-specific branch. This classification is retained between tool start and tool end; a successful end closes the same generic shape rather than producing child-delegation identity.

    };
  }

  return { type: "tool", tool: toolName, args };
}

The real shared assembler maps this shape to toolCall. That is why success is not enough to produce a delegation.

      case "tool": {
        const toolArguments = toOptionalRecord(shape.args);
        return withParentToolCallId(
          {
            type: "toolCall",
            id: bbItemId,
            ...(shape.server === undefined ? {} : { server: shape.server }),
            tool: shape.tool,
            ...(toolArguments ? { arguments: toolArguments } : {}),
            status: "pending",
            ...(shape.result === undefined ? {} : { result: shape.result }),
            ...(shape.error === undefined ? {} : { error: shape.error }),

The timeline's category selection treats tool and delegation separately. This source path supports the reported grouping consequence, but it was not exercised through a running UI.

The deeper async gap is that custom messages are either dropped or converted to provider input text; they do not correlate a notification to a running child. Correctly modeling the actual extension therefore requires validated child identity, launch receipts, and terminal notifications. The exact third-party shapes remain unverified here.

        if (
          piEvent.data.type === "message_end" ||
          !piEvent.data.message.display
        ) {
          return [];
        }
        const text = extractCustomMessageText(piEvent.data.message.content);
        if (text === undefined) {
          return [];
        }
        return [{ kind: "input.provider", text, ...parentRefField }];

6. Proposed fix and safety gate

Capture a real sanitized extension lifecycle first, including multiple children, launch return, parent turn settlement, child success/failure/cancellation, and late notifications. Validate these external inputs at the Pi boundary. Map each supported child to the existing delegation delta shape with a stable child reference, and use background delegation semantics when the child outlives the initiating tool. Preserve the generic fallback for unknown tools and non-launch management actions.

No automatic production patch or PR: the complete async workflow has not been reproduced under the permitted trusted-code/no-new-dependency constraints. The synthetic test establishes the classification gap but does not establish when a real background child is done. A name-only fix could incorrectly mark launcher completion as child completion. The required faithful pre-fix/post-fix lifecycle regression therefore cannot yet be established; the simple-fix safety gate is not satisfied. No stopped fix was pushed, and no fix branch was created.

7. Linked PR review

PR #8024 — static only

GitHub metadata: closed, unmerged, targeting main; two files, 459 additions and 7 deletions (466 changed text lines). No open PR linking this issue was found at the final check. The untrusted diff adds subagent classification, workflow/child bookkeeping, and notification-to-delegation completion handling, with translator tests. These are the mechanisms missing in the trusted base.

Review limit: notification fields and ordering in that diff are not independent evidence of what the extension emits. In the changed custom-message completion handler, missing child terminal details are treated as failed; whether absence means failure needs a real recording before acceptance. This is an unverified contract risk, not a demonstrated defect. No PR code was copied, checked out, or run. Verdict: not runtime-verified; the closed proposal is not an available landed fix.

8. Related issues

Searches of open and closed issues for Pi subagents returned no other matching Pi delegation bug. #2314 concerns a different provider's subagent transcript links and is not evidence for this extension lifecycle. No duplicate closure was applied.

9. Verification

The same agent repeated the diagnostic in a second clean detached worktree at the exact trusted base, with its own frozen installation and focused dependency build. Only the newly authored diagnostic was copied over; no production source was changed. The second invocation included --force, and Turbo reported zero cached tasks, so this was actual execution rather than replayed test output.

pnpm exec turbo run test --filter=bb-plugin-provider-pi --force -- src/issue-8023.repro.test.ts
Exit: 1
Failure: three delegation kinds expected, three toolCall kinds received.
All three operations were completed successfully before the identity assertion.
Existing translator suites: 2 passed, 112 tests passed.
git diff --check: clean in both investigation checkouts.

Both runs support the same boundary finding. No report correction was needed. They do not upgrade the untested desktop or third-party asynchronous claims to verified. This is a repeat by one investigator, not independent verification.

10. Appendix and evidence

The complete reproduction source and exact expected/actual boundary output are included inline above. Raw execution logs and the diagnostic file are retained locally, not published, following this public report repository's artifact policy.

First run: 1 test failed at the item-kind assertion (exit 1).
Second clean run: 1 test failed at the same assertion (exit 1).
Existing owner suites: 2 test files passed, 112 tests passed (exit 0).
Focused dependency build: 7 tasks successful.
Initial repository-wide build: GitHub plugin failed because SDK dist/process.js and dist/host.js were not built.

Investigation commands also included read-only issue/PR metadata queries, static PR diff inspection, source reads, origin/main fetches, and worktree creation. The initial full build command was pnpm exec turbo run build; its failure is retained above, not represented as a passing full build. The first diagnostic command omitted --force; it executed and failed, and failing task results were not cached. An initial local diagnostic-writing syntax error was corrected before the two retained runs; it is not bug evidence.

Trust note: issue text and linked PR contents were treated solely as untrusted claims. No issue-provided command, JSON prompt, external installation, patch, branch, or test was executed. The diagnostic was authored from trusted Pi event schemas and the existing translator/assembler testing boundary. Public artifacts contain no credentials, home paths, user runtime data, or fabricated screenshots.

> AGENT GENERATED