feat: add image reading support to Read tool (#614)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-01-20 22:38:33 -08:00
committed by GitHub
parent 1168a83716
commit 5635156b51
10 changed files with 231 additions and 18 deletions

View File

@@ -594,12 +594,30 @@ export const ToolCallMessage = memo(
}
}
// Check if this is a file read tool - show line count summary
// Check if this is a file read tool - show line count or image summary
if (
isFileReadTool(rawName) &&
line.resultOk !== false &&
line.resultText
) {
// Check if this is an image result (starts with "[Image: filename]")
const isImageResult = line.resultText.startsWith("[Image: ");
if (isImageResult) {
return (
<Box flexDirection="row">
<Box width={prefixWidth} flexShrink={0}>
<Text>{prefix}</Text>
</Box>
<Box flexGrow={1} width={contentWidth}>
<Text>
Read <Text bold>1</Text> image
</Text>
</Box>
</Box>
);
}
// Count lines in the result (the content returned by Read tool)
const lineCount = line.resultText.split("\n").length;
return (
@@ -609,7 +627,8 @@ export const ToolCallMessage = memo(
</Box>
<Box flexGrow={1} width={contentWidth}>
<Text>
Read <Text bold>{lineCount}</Text> lines
Read <Text bold>{lineCount}</Text> line
{lineCount !== 1 ? "s" : ""}
</Text>
</Box>
</Box>