Skip to content

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

Merged
ethanndickson merged 2 commits into
mainfrom
pdf-handling-3mg5
Jun 2, 2026
Merged

ethanndickson merged 2 commits into
mainfrom
pdf-handling-3mg5

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

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 (cherry-pick of upstream charmbracelet/fantasy#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

Bumps coder/fantasy past coder/fantasy#37 (cherry-pick of upstream
charmbracelet/fantasy#197) so application/pdf FileParts are emitted as
base64 PDF document blocks to Anthropic, and therefore to Bedrock which
wraps the Anthropic provider, instead of being silently dropped. The
user-uploaded PDF now actually reaches Claude.

Add a regression test 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 pin.

Relates to CODAGT-540
@ethanndickson
ethanndickson marked this pull request as ready for review June 2, 2026 02:43
make lint (misspell) flagged the British spelling in the PDF test's
doc comment.
@ethanndickson
ethanndickson merged commit 9fe7558 into main Jun 2, 2026
47 of 50 checks passed
@ethanndickson
ethanndickson deleted the pdf-handling-3mg5 branch June 2, 2026 14:16
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 2, 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