fix: forward user-uploaded PDFs to Anthropic and Bedrock (#25946)

Previously, user-uploaded PDFs were silently dropped by fantasy's
Anthropic provider adapter, so Claude (direct or via Bedrock) only saw
the user's text and replied as if no document had been attached. Other
providers (OpenAI, Gemini, OpenRouter, Vercel) were unaffected.

Bumps `coder/fantasy` past
[coder/fantasy#37](https://github.com/coder/fantasy/pull/37)
(cherry-pick of upstream
[charmbracelet/fantasy#197](https://github.com/charmbracelet/fantasy/pull/197)),
which emits an Anthropic `document` content block with a base64 PDF
source for `fantasy.FilePart{MediaType: "application/pdf"}` and counts
`OfDocument` as user-visible so a PDF-only user message is no longer
culled as empty.

Adds a regression test
(`TestModelFromConfig_AnthropicPDFFilePartReachesProvider`) that drives
a `fantasy.FilePart` through the real Anthropic provider against a
`chattest.NewAnthropic` stub and asserts the outbound request contains a
base64 document block. The test was verified to fail on the previous
fantasy pin (the request leaves with zero messages and `Generate`
returns EOF) and pass on the new one.

Manually verified end-to-end with `./scripts/develop.sh`: uploading a
PDF to a Claude-backed Coder Agents chat now lets the model read it.

Closes CODAGT-540
This commit is contained in:
Ethan
2026-06-03 00:16:01 +10:00
committed by GitHub
parent d2697dc5b0
commit 9fe75587ae
3 changed files with 82 additions and 4 deletions
+6 -2
View File
@@ -90,8 +90,12 @@ replace github.com/spf13/afero => github.com/aslilac/afero v0.0.0-20250403163713
// streams close before their terminal events.
// 9) coder/fantasy#35, preserve Anthropic replay fidelity for signed
// reasoning and provider-executed web_search error results.
// See: https://github.com/coder/fantasy/commits/cfca5fd82c5dd
replace charm.land/fantasy => github.com/coder/fantasy v0.0.0-20260514123132-cfca5fd82c5d
// 10) coder/fantasy#37, cherry-pick of upstream charmbracelet/fantasy#197:
// 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.
// See: https://github.com/coder/fantasy/commits/7d46e640327a
replace charm.land/fantasy => github.com/coder/fantasy v0.0.0-20260602023814-7d46e640327a
// coder/coder uses a fork of charmbracelet's fork of the Anthropic Go SDK
// with performance improvements and Bedrock header cleanup.