Skip to content

Add PDF document support for Messages API (Anthropic Claude models) #307279

Description

@bhavyaus

Summary

Add support for sending PDF documents as content parts in the Messages API, enabling native PDF attachment handling for Anthropic Claude models.

Details

This adds:

  • A new Document content part kind in prompt-tsx for PDF payloads
  • PDF magic byte validation (%PDF / 0x25 0x50 0x44 0x46)
  • Model capability gating via modelSupportsPDFDocuments() (Anthropic-only for now)
  • Conversion to Anthropic DocumentBlockParam in the Messages API layer
  • Conversation history replay support for document content parts
  • Token estimation heuristic for PDF documents (avoids BPE tokenization of large binary payloads)
  • Graceful degradation: unsupported models show an omitted reference with a descriptive message

Implementation

PR: microsoft/vscode-copilot-chat#4473

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions