mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: forward attached filenames to Anthropic chat models (#26051)
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](https://github.com/coder/fantasy/pull/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
This commit is contained in:
@@ -94,7 +94,11 @@ replace github.com/spf13/afero => github.com/aslilac/afero v0.0.0-20250403163713
|
||||
// emit a Base64 PDF document block for application/pdf FileParts on the
|
||||
// Anthropic provider so user-uploaded PDFs actually reach Claude/Bedrock
|
||||
// instead of being silently dropped.
|
||||
// 11) coder/fantasy#39, support Anthropic thinking_display natively.
|
||||
// 11) coder/fantasy#38, forward PDF and text filenames as a sanitized
|
||||
// Anthropic document title so Claude can refer to attachments by
|
||||
// name, and warn on unsupported FilePart media types instead of
|
||||
// silently dropping them.
|
||||
// 12) coder/fantasy#39, support Anthropic thinking_display natively.
|
||||
// See: https://github.com/coder/fantasy/commits/a2a3f2171ec8
|
||||
replace charm.land/fantasy => github.com/coder/fantasy v0.0.0-20260604204802-a2a3f2171ec8
|
||||
|
||||
|
||||
Reference in New Issue
Block a user