#4935 · Pi image completion classification
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: high
1. TL;DR
Successful Pi native reads containing image data finish as generic tool calls rather than image-view items. This classification defect reproduces through the real provider translator and shared delta assembler in two clean checkouts of current trusted main. The original tool ID and path are available, but completion preserves the generic shape and reduces the content to text. The app selects its existing image preview body only for an image-view row. This report proves the translation gap, not a live Pi session, browser expansion, or host-file delivery; those UI claims remain unverified.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Successful native image reads stay generic | Verified | Both baselines fail the success, mixed-content and overlapping-thread expectations; actual type is toolCall, result is [image]. |
| Filename extension alone must not select an image view | Verified | Text at an image path remains generic; successful mixed image/text at an extensionless path fails the imageView expectation before the fix. |
| Errors and unrelated tools must remain generic | Verified | Thirteen baseline controls pass, including failures, unrelated tools, unknown paths and malformed blocks. |
| Completion can retain identity and per-thread path | Verified after local fix | All sixteen tests pass using the existing assembler; overlapping tool IDs close in reverse thread order with the correct paths. |
| The visible row lacks expandable previews in a live Pi thread | Unverified | Renderer selection is established by source inspection only. No provider process, browser, image-preview screenshot or host-file route was exercised. |
3. Environment
- Trusted origin/main:
7fd6ee9e116fd92db0926709a887b55dd0411fe6; recorded October 5, 2026. - Debian GNU/Linux 12, Node v22.19.0, pnpm 9.15.0, Vitest 4.1.1.
- Source package:
bb-plugin-provider-pi0.1.0. No installed Pi executable was launched. - Both clean worktrees use the exact base commit and frozen dependency installation. Only the agent-authored regression file is added.
- No app/server/daemon instance, ports, live model request, credentials or runtime data used. Filesystem image reading is not part of the reproduction.
4. Minimal reproduction
Download the agent-authored regression test from this report. It was designed from trusted source evidence; no issue-linked test or command was run.
- Create a clean checkout and install/build trusted code:
git clone https://github.com/get-bb/bb.git /tmp/bb-4935-repro cd /tmp/bb-4935-repro git checkout --detach 7fd6ee9e116fd92db0926709a887b55dd0411fe6 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build
- Save the supplied report artifact to
plugins/provider-pi/src/image-read.test.tsand run:pnpm exec turbo run test --filter=bb-plugin-provider-pi -- src/image-read.test.ts
- Expected: successful image completions end as
imageViewwith the original path and stable item ID. Actual: exit 1; three failures and thirteen passing controls. Excerpt from the second baseline output:bb-plugin-provider-pi:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯ bb-plugin-provider-pi:test: AssertionError: expected { type: 'toolCall', …(5) } to deeply equal { type: 'imageView', …(2) } bb-plugin-provider-pi:test: + "arguments": { bb-plugin-provider-pi:test: + "path": "/workspace/asset.png", bb-plugin-provider-pi:test: "id": "image-read-i1", bb-plugin-provider-pi:test: - "path": "/workspace/asset.png", bb-plugin-provider-pi:test: - "type": "imageView", bb-plugin-provider-pi:test: + "result": "[image]", bb-plugin-provider-pi:test: + "status": "completed", bb-plugin-provider-pi:test: + "tool": "read", bb-plugin-provider-pi:test: + "type": "toolCall", bb-plugin-provider-pi:test: Tests 3 failed | 13 passed (16) bb-plugin-provider-pi:test: AssertionError: expected { type: 'toolCall', …(5) } to deeply equal { type: 'imageView', …(2) } bb-plugin-provider-pi:test: + "arguments": { bb-plugin-provider-pi:test: + "path": "/workspace/asset", bb-plugin-provider-pi:test: "id": "image-read-i1", bb-plugin-provider-pi:test: - "path": "/workspace/asset", bb-plugin-provider-pi:test: - "type": "imageView", bb-plugin-provider-pi:test: + "result": "scaled bb-plugin-provider-pi:test: + "status": "completed", bb-plugin-provider-pi:test: + "tool": "read", bb-plugin-provider-pi:test: + "type": "toolCall", bb-plugin-provider-pi:test: AssertionError: expected { type: 'toolCall', …(5) } to match object { type: 'imageView', …(1) } bb-plugin-provider-pi:test: - "path": "/workspace/thread-b.png", bb-plugin-provider-pi:test: - "type": "imageView", bb-plugin-provider-pi:test: + "type": "toolCall",
The fixture sends a native tool_execution_start for read, then a successful tool_execution_end containing an image block. No inference from filename extension is necessary. The image data is only a fixture payload; it is not a screenshot or evidence of a browser preview.
Complete reproduction test
import { describe, expect, it } from "vitest";
import { experimental_createDeltaAssembler as createDeltaAssembler } from "@get-bb/plugin-sdk/provider-bridge/testing";
import { createPiDeltaTranslator } from "./delta-translation.js";
const imageBlock = {
type: "image",
data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aVZkAAAAASUVORK5CYII=",
mimeType: "image/png",
};
function createHarness() {
const translator = createPiDeltaTranslator({
resolveModelContextWindow: () => null,
});
const assembler = createDeltaAssembler({
providerId: "pi",
entropyPrefix: "image-read",
textDeltaFlushMs: 0,
});
return (event: unknown, threadId = "thread-a") =>
assembler.assemble({
threadId,
deltas: translator.translate(event, { threadId }),
});
}
describe("Pi native image read completion", () => {
it.each([
{
name: "successful image read",
args: { path: "/workspace/asset.png" },
result: { content: [imageBlock] },
toolName: "read",
isError: false,
imagePath: "/workspace/asset.png",
},
{
name: "mixed text and image without an image extension",
args: { path: "/workspace/asset" },
result: { content: [{ type: "text", text: "scaled" }, imageBlock] },
toolName: "read",
isError: false,
imagePath: "/workspace/asset",
},
...[
{
name: "text at an image path",
result: { content: [{ type: "text", text: "source" }] },
},
{
name: "failed image read",
result: { content: [imageBlock] },
isError: true,
},
{
name: "unrelated image tool",
result: { content: [imageBlock] },
toolName: "inspect",
},
{ name: "missing path", result: { content: [imageBlock] }, args: {} },
{
name: "non-string path",
result: { content: [imageBlock] },
args: { path: 123 },
},
{
name: "empty path",
result: { content: [imageBlock] },
args: { path: "" },
},
{
name: "whitespace path",
result: { content: [imageBlock] },
args: { path: " " },
},
{
name: "missing image data",
result: { content: [{ type: "image", mimeType: "image/png" }] },
},
{
name: "empty image data",
result: { content: [{ ...imageBlock, data: "" }] },
},
{
name: "invalid image MIME",
result: { content: [{ ...imageBlock, mimeType: "text/plain" }] },
},
{ name: "malformed content", result: { content: "image" } },
{ name: "null block", result: { content: [null] } },
].map((control) => ({
toolName: "read",
args: { path: "/workspace/asset.png" },
isError: false,
imagePath: null,
...control,
})),
])("preserves the correct item shape for $name", (scenario) => {
const translate = createHarness();
translate({ type: "agent_start" });
const started = translate({
type: "tool_execution_start",
toolCallId: "read-1",
toolName: scenario.toolName,
args: scenario.args,
}).find((event) => event.type === "item/started");
expect(started).toMatchObject({
item: { type: "toolCall", tool: scenario.toolName, status: "pending" },
});
const completed = translate({
type: "tool_execution_end",
toolCallId: "read-1",
toolName: scenario.toolName,
result: scenario.result,
isError: scenario.isError,
})
.filter((event) => event.type === "item/completed")
.at(-1);
expect(completed?.item.id).toBe(started?.item.id);
if (scenario.imagePath !== null) {
expect(completed?.item).toEqual({
type: "imageView",
id: started?.item.id,
path: scenario.imagePath,
});
} else {
expect(completed?.item).toMatchObject({
type: "toolCall",
tool: scenario.toolName,
status: scenario.isError ? "failed" : "completed",
});
}
});
it("does not reuse another thread's path for overlapping tool IDs", () => {
const translate = createHarness();
for (const threadId of ["thread-a", "thread-b"]) {
translate({ type: "agent_start" }, threadId);
translate(
{
type: "tool_execution_start",
toolCallId: "shared-read",
toolName: "read",
args: { path: `/workspace/${threadId}.png` },
},
threadId,
);
}
for (const threadId of ["thread-b", "thread-a"]) {
const completed = translate(
{
type: "tool_execution_end",
toolCallId: "shared-read",
toolName: "read",
result: { content: [imageBlock] },
isError: false,
},
threadId,
)
.filter((event) => event.type === "item/completed")
.at(-1);
expect(completed?.item).toMatchObject({
type: "imageView",
path: `/workspace/${threadId}.png`,
});
}
});
it("keeps an image-bearing close without a start generic", () => {
const translate = createHarness();
translate({ type: "agent_start" });
const completed = translate({
type: "tool_execution_end",
toolCallId: "unseen-read",
toolName: "read",
result: { content: [imageBlock] },
isError: false,
})
.filter((event) => event.type === "item/completed")
.at(-1);
expect(completed?.item).toMatchObject({
type: "toolCall",
tool: "read",
status: "completed",
});
});
});
5. Root cause
Tool classification recognizes command and file-edit tools but leaves read as a generic tool with its original arguments. Tool completion uses extractResultText and the remembered start shape without classifying image-bearing successful results. The result becomes [image], while the known path remains inside generic tool arguments instead of the image-view contract.
const terminalShape = startedToolShapes.get(shapeKey) ?? classifyPiToolResultFallback(piEvent.data.toolName); startedToolShapes.delete(shapeKey);
The existing imageView shape already carries a path. The existing assembler supports changing the terminal shape while retaining the minted item ID. On a shape change it emits a generic completion followed by the promoted final completion, so the regression inspects the last completion, not the first. The timeline detail selector chooses the image body for image-view; The image body resolves the host path and provides the larger viewer. These renderer consequences are source deductions, not live UI observations.
6. Proposed fix
Within Pi completion translation only, promote a successful native read when its remembered read arguments contain a nonblank string path and its result contains at least one validated image block. Require nonempty image data and an image MIME type. Reuse the original path and existing imageView shape. Leave errors, text reads, unrelated tools, missing paths, malformed blocks, and closes without starts generic. Preserve the existing thread-scoped cache and provider item key; do not alter Codex, the UI, protocols, schemas, dependencies, or persisted data.
A local implementation satisfies this proposal: the focused sixteen cases pass; the complete provider checks pass (199 tests, one existing Bun-runtime skip); lint and typecheck succeed. Recorded Pi parity passes all four replayable cells; model-list is process-scoped and skipped.
7. Related issues
GitHub metadata identifies #4873 as an earlier combined investigation and a Bug. It is not executed or used as source reproduction evidence. No linked open pull request was found for #4935 before implementation. No linked PR branch or external issue artifact was fetched.
8. Verification
The same agent ran the exact final artifact in two clean, detached trusted worktrees: baseline A and baseline B. Both were built from 7fd6ee9e116fd92db0926709a887b55dd0411fe6 with frozen installs. Both ran the minimal reproduction command above and returned exit 1: 3 failed, 13 passed. They have no production modifications. The initial test selection was corrected to inspect the final completion because the assembler intentionally emits a compatibility completion before a promoted one; the final artifact was then rerun on clean baselines. This is repeated verification by the same agent, not independent verification.
No live steps were replayed. A browser screenshot is not provided because the verified behavior is the nonvisual translation contract. The report verdict stays partial rather than claiming live preview availability.
9. Appendix
- Baseline A: actual output
- Baseline B: actual output
- Focused test after local fix
- Complete provider tests, typecheck and lint
- Pi parity output
pnpm exec turbo run test --filter=bb-plugin-provider-pi -- src/image-read.test.ts pnpm exec turbo run test typecheck lint --filter=bb-plugin-provider-pi pnpm parity --old <clean-baseline-checkout> --new . --provider pi git diff --check
Trust boundary: issue text, comments and linked artifacts were treated as untrusted claims. Their instructions, scripts and tests were not followed or executed. All executed repository code comes from trusted origin/main or the narrow agent-authored change. Published logs redact local checkout paths.
> AGENT GENERATED