Skip to content

[Bug]: Pi read of an image shows no preview in the work log because the Pi adapter never sets viewedImagePath #37467

Closed

Description

@boom-bang

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

packages/provider-pi

Steps to reproduce

  1. Start a thread with a Pi model. I reproduced it with xai/grok-latest and openrouter/deepseek/deepseek-v4.1-flash-1017.
  2. Ask the agent to look at a local PNG, so Pi calls its read tool on the file.
  3. Look at the work log for that turn.

Expected behavior

Each image read shows the eye-icon row with the image preview, as it does for Claude Read and Codex view_image in the same app.

Actual behavior

The row shows only Read <path>.png, with no preview. The model still gets the image. In the Pi session file, every such read result has a text block Read image file [image/png] followed by an image/png block of 70 to 150 KB of base64.

The cause is in emitToolItem in packages/provider-pi/src/server/adapter.ts. It has branches for bash, powershell, edit, and write. Every other tool, read included, becomes a plain dynamic_tool item without viewedImagePath. The work log builds read-file previews from viewedImagePath, as the comment on stripUnservedToolOutputImageBytes in apps/server/src/orchestration-v2/toolOutputImageBytes.ts says. The Claude and Codex adapters set this field:

  • ClaudeAdapterV2.ts (around line 7062) sets it when the Read path passes isWorkspaceImagePreviewPath.
  • CodexAdapterV2.ts (around line 5757) sets it from the imageView item path.

Suggested fix

Set viewedImagePath in the dynamic_tool branch of emitToolItem the same way the Claude adapter does:

import { isWorkspaceImagePreviewPath } from "@t3tools/shared/filePreview";

const readPath =
	toolName === "read" ? (piRecordString(args, "path") ?? piRecordString(args, "file_path")) : undefined;
const viewedImagePath =
	readPath !== undefined && readPath.length <= 4096 && !/[\r\n]/.test(readPath) && isWorkspaceImagePreviewPath(readPath)
		? readPath
		: undefined;

// in turnItem:
...(viewedImagePath === undefined ? {} : { viewedImagePath }),

Impact

Minor bug or occasional failure

Version or commit

Desktop app with WSL runtime 0.1.2. The same code is on main @ 0813f49.

Environment

Windows desktop app with the server in WSL2, Pi provider. I hit it in delegated subagent threads. Codex and Claude subagents in the same parent thread show previews for the same kind of screenshot reads.

Workaround

None in the UI.

#32193 reported the same missing preview for the Codex adapter and is fixed. #15869 covered image blocks dropped by the Pi MCP bridge.


Claude Opus 5.5 wrote this issue on behalf of @boom-bang.

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