revert: revert "feat: add image reading support to Read tool" (#605)

This commit is contained in:
Charles Packer
2026-01-20 20:10:02 -08:00
committed by GitHub
parent 828cf0917c
commit 269cbd8fe2
7 changed files with 5 additions and 303 deletions

View File

@@ -158,10 +158,6 @@ import {
subscribe as subscribeToSubagents,
} from "./helpers/subagentState";
import { getRandomThinkingVerb } from "./helpers/thinkingMessages";
import {
clearQueuedToolImages,
getAndClearQueuedToolImages,
} from "./helpers/toolImageRegistry";
import {
isFileEditTool,
isFileWriteTool,
@@ -3250,9 +3246,6 @@ export default function App({
// Lock input for async operation (set before any await to prevent queue processing)
setCommandRunning(true);
// Clear any queued tool images from the previous agent context
clearQueuedToolImages();
const inputCmd = "/agents";
const cmdId = uid("cmd");
@@ -3740,44 +3733,9 @@ export default function App({
// Send all results to server if any
if (allResults.length > 0) {
toolResultsInFlightRef.current = true;
// Check for queued tool images (from Read tool reading image files)
const toolImages = getAndClearQueuedToolImages();
const input: Array<MessageCreate | ApprovalCreate> = [
await processConversation([
{ type: "approval", approvals: allResults },
];
// If there are queued images, add them as a user message
if (toolImages.length > 0) {
const imageContentParts: Array<
| { type: "text"; text: string }
| {
type: "image";
source: { type: "base64"; media_type: string; data: string };
}
> = [];
for (const img of toolImages) {
imageContentParts.push({
type: "text",
text: `<system-reminder>Image read from ${img.filePath} (Read tool call: ${img.toolCallId}):</system-reminder>`,
});
imageContentParts.push({
type: "image",
source: {
type: "base64",
media_type: img.mediaType,
data: img.data,
},
});
}
input.push({
type: "message",
role: "user",
content: imageContentParts as unknown as MessageCreate["content"],
});
}
await processConversation(input);
]);
toolResultsInFlightRef.current = false;
}
} finally {
@@ -4415,9 +4373,6 @@ export default function App({
setCommandRunning(true);
// Clear any queued tool images from the previous conversation
clearQueuedToolImages();
try {
const client = await getClient();
@@ -5643,37 +5598,7 @@ ${gitContext}
}
// Build message content from display value (handles placeholders for text/images)
let contentParts = buildMessageContentFromDisplay(msg);
// Prepend any queued tool images (from Read tool reading image files)
const queuedToolImages = getAndClearQueuedToolImages();
if (queuedToolImages.length > 0) {
const imageParts: Array<
| { type: "text"; text: string }
| {
type: "image";
source: { type: "base64"; media_type: string; data: string };
}
> = [];
for (const img of queuedToolImages) {
// Add system reminder text
imageParts.push({
type: "text",
text: `<system-reminder>Image read from ${img.filePath} (Read tool call: ${img.toolCallId}):</system-reminder>`,
});
// Add image content
imageParts.push({
type: "image",
source: {
type: "base64",
media_type: img.mediaType,
data: img.data,
},
});
}
// Prepend to contentParts
contentParts = [...imageParts, ...contentParts];
}
const contentParts = buildMessageContentFromDisplay(msg);
// Prepend plan mode reminder if in plan mode
const planModeReminder = getPlanModeReminder();

View File

@@ -1,47 +0,0 @@
// Registry for images read by tools that need to be sent in the next user message turn.
// This is needed because tool returns only support string content - we can't return
// image data directly in tool results to the Letta API.
export interface QueuedToolImage {
toolCallId: string;
filePath: string;
data: string; // base64
mediaType: string;
width: number;
height: number;
}
const queuedImages: QueuedToolImage[] = [];
/**
* Queue an image to be sent in the next user message.
* Called by the Read tool when reading an image file.
*/
export function queueToolImage(image: QueuedToolImage): void {
queuedImages.push(image);
}
/**
* Get and clear all queued images.
* Called when building the user message content.
*/
export function getAndClearQueuedToolImages(): QueuedToolImage[] {
const images = [...queuedImages];
queuedImages.length = 0;
return images;
}
/**
* Clear all queued images without returning them.
* Called on conversation/agent switch to prevent memory leaks.
*/
export function clearQueuedToolImages(): void {
queuedImages.length = 0;
}
/**
* Check if there are any queued images.
*/
export function hasQueuedToolImages(): boolean {
return queuedImages.length > 0;
}