Roo-Code/src/api/transform/image-cleaning.ts
Daniel 6cfa82f571
Revert to pre-AI-SDK state (January 29, 2026) (#11462)
Revert to pre-AI-SDK state (commit 67e568f6b)

This commit reverts the codebase to the state before AI SDK migration work began.

Target commit: 67e568f6b - refactor: replace fetch_instructions with skill tool and built-in skills (#10913)
Date: January 29, 2026

This removes approximately 152 commits of AI SDK migration work.
A follow-up PR will add back bug fixes and features that are unrelated to AI SDK.

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-13 16:45:18 -05:00

32 lines
1.1 KiB
TypeScript

import { ApiMessage } from "../../core/task-persistence/apiMessages"
import { ApiHandler } from "../index"
/* Removes image blocks from messages if they are not supported by the Api Handler */
export function maybeRemoveImageBlocks(messages: ApiMessage[], apiHandler: ApiHandler): ApiMessage[] {
// Check model capability ONCE instead of for every message
const supportsImages = apiHandler.getModel().info.supportsImages
return messages.map((message) => {
// Handle array content (could contain image blocks).
let { content } = message
if (Array.isArray(content)) {
if (!supportsImages) {
// Convert image blocks to text descriptions.
content = content.map((block) => {
if (block.type === "image") {
// Convert image blocks to text descriptions.
// Note: We can't access the actual image content/url due to API limitations,
// but we can indicate that an image was present in the conversation.
return {
type: "text",
text: "[Referenced image in conversation]",
}
}
return block
})
}
}
return { ...message, content }
})
}