fix(core): forward PDF prompt attachments (#43799)
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Has been cancelled
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Has been cancelled
nix-hashes / compute-hash (macos-15-intel, x86_64-darwin) (push) Has been cancelled
nix-hashes / compute-hash (macos-latest, aarch64-darwin) (push) Has been cancelled
nix-hashes / update-hashes (push) Has been cancelled
publish / version (push) Has been cancelled
publish / build-cli (push) Has been cancelled
publish / sign-cli-macos (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404 target:linux-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404-arm target:linux-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:macos-26 target:darwin-arm64]) (push) Has been cancelled
publish / sign-cli-windows (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Has been cancelled
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
publish / publish (push) Has been cancelled

This commit is contained in:
Aiden Cline
2026-08-21 01:16:05 -05:00
committed by GitHub
parent d158f2cd39
commit b0ab1e2992
3 changed files with 7 additions and 4 deletions
@@ -67,7 +67,7 @@ const directoryAttachment = (file: FileAttachment): ContentPart => ({
const attachmentContent = (file: FileAttachment): ContentPart[] => {
if (file.mime === "text/plain") return [textAttachment(file)]
if (file.mime === "application/x-directory") return [directoryAttachment(file)]
if (imageMimes.has(file.mime)) {
if (imageMimes.has(file.mime) || file.mime === "application/pdf") {
const location = attachmentLocation(file)
return [...(location === undefined ? [] : [Message.text(`Attached file: ${location}`)]), media(file)]
}
@@ -9,16 +9,18 @@ describe("SessionModelRequest.unsupportedParts", () => {
const messages = unsupportedParts(
[
Message.user([
Message.text("Describe this image"),
Message.text("Describe these files"),
{ type: "media", mediaType: "image/png", data: "aGVsbG8=", filename: "logo.png" },
{ type: "media", mediaType: "application/pdf", data: "JVBERg==", filename: "document.pdf" },
]),
],
capabilities(["text"]),
)
expect(messages[0]?.content).toEqual([
Message.text("Describe this image"),
Message.text("Describe these files"),
Message.text('ERROR: Cannot read "logo.png" (this model does not support image input). Inform the user.'),
Message.text('ERROR: Cannot read "document.pdf" (this model does not support pdf input). Inform the user.'),
])
})
@@ -361,7 +361,7 @@ Recent work
])
})
test("uses materialized image data as provider media and drops unsupported attachments", () => {
test("uses materialized image and PDF data as provider media", () => {
const data = Base64.make("AAECAw==")
const messages = toLLMMessages(
[
@@ -387,6 +387,7 @@ Recent work
expect(messages[0]?.content).toEqual([
{ type: "text", text: "Inspect this image" },
{ type: "media", mediaType: "image/png", data, filename: "image.png" },
{ type: "media", mediaType: "application/pdf", data: "JVBERg==", filename: "document.pdf" },
])
})