Skip to content

fix: forward attached filenames to Anthropic chat models#26051

Open
ethanndickson wants to merge 1 commit into
mainfrom
pdf-filename-context
Open

fix: forward attached filenames to Anthropic chat models#26051
ethanndickson wants to merge 1 commit into
mainfrom
pdf-filename-context

Conversation

@ethanndickson
Copy link
Copy Markdown
Member

Previously, fantasy's Anthropic provider adapter accepted PDF and text FileParts but dropped the filename on the floor, so Claude (direct or via Bedrock) saw the document bytes without any handle and could not answer questions like "what's in foo.pdf". Other providers (OpenAI, Gemini, OpenRouter, Vercel) already forwarded filenames.

Bumps coder/fantasy past coder/fantasy#38, which sanitizes FilePart.Filename and sets it as the Anthropic DocumentBlockParam.Title for both application/pdf and text/* attachments, and emits a CallWarning for unsupported FilePart media types instead of silently dropping them.

On this side, plumbs the resolved filename through partsToMessageParts so the FilePart literal carries it into the provider. The existing TestModelFromConfig_AnthropicPDFFilePartReachesProvider regression test is extended to assert the outbound Anthropic request includes the sanitized title (quarterly_report.v1.pdf becomes quarterly report v1 pdf).

Closes CODAGT-545

Previously, fantasy's Anthropic provider adapter accepted PDF and text
FileParts but dropped the filename on the floor, so Claude (direct or
via Bedrock) saw the document bytes without any handle and could not
answer questions like "what's in foo.pdf". Other providers (OpenAI,
Gemini, OpenRouter, Vercel) already forwarded filenames.

Bumps coder/fantasy past coder/fantasy#38, which sanitizes
FilePart.Filename and sets it as the Anthropic DocumentBlockParam.Title
for both application/pdf and text/* attachments, and emits a CallWarning
for unsupported FilePart media types instead of silently dropping them.

On this side, plumbs the resolved filename through partsToMessageParts
so the FilePart literal carries it into the provider. The
TestModelFromConfig_AnthropicPDFFilePartReachesProvider regression test
now asserts the outbound Anthropic request includes the sanitized title
("quarterly_report.v1.pdf" becomes "quarterly report v1 pdf").

Closes CODAGT-545
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 4, 2026

CODAGT-545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant