Skip to content

fix: forward attached filenames to Anthropic chat models#26051

Merged
ethanndickson merged 1 commit into
mainfrom
pdf-filename-context
Jun 10, 2026
Merged

fix: forward attached filenames to Anthropic chat models#26051
ethanndickson merged 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

@linear-code

linear-code Bot commented Jun 4, 2026

Copy link
Copy Markdown

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
@ethanndickson ethanndickson force-pushed the pdf-filename-context branch from b0d55c3 to a9547a1 Compare June 9, 2026 13:20
@ethanndickson ethanndickson merged commit deb6eec into main Jun 10, 2026
28 checks passed
@ethanndickson ethanndickson deleted the pdf-filename-context branch June 10, 2026 01:37
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants