Issue #3590963: Bump SDK constraint and drop method_exists defensive check
Phase 2 of the Anthropic provider native-SDK work (#3590963): prompt
caching admin UI + PDF document input. Builds on Phase 1 (#3572402,
merged in d1e078a1). Targets 1.3.x; fast-forward mergeable.
What this delivers
Prompt caching
- Admin UI: "Enable prompt caching" toggle, TTL selector (5m / 1h),
cache-diagnostics opt-in —
#states-gated in the provider settings form. - System prompt sent as a typed
TextBlockParamwithcache_controlwhen caching is on (caching a bare string is a no-op — the breakpoint must sit on a content block). - 1h TTL attaches the
extended-cache-ttl-2025-04-11beta header via per-requestRequestOptions::extraHeaders. cache_creation_input_tokenssurfaced throughChatOutput::getMetadata()['cache_creation_tokens'].
PDF input
buildMessageContent()detectsapplication/pdffiles on aChatMessageand emits a typedDocumentBlockParam+Base64PDFSource.getConfiguredModels()gains ananthropic:pdf_inputcapability filter.
SDK + infrastructure
- Composer constraint
^0.16→>=0.16,<1.0(tested on v0.23.0). - Module-local
phpunit.xml.distwith scoped<source>coverage.
Commits
faebdccSDK constraint bump + drop redundantmethod_existsguard7c3de9cPDF input — capability filter + document blocks87b662cCaching UI + TTL + beta opt-in + cache_creation reportingdfd9fbfCache the system prompt as a typed block (live-test fix)8548859Review fixes —buildCacheControlhelper + PDF caution doc28b2479Module-localphpunit.xml.distwith scoped coverage8f84ed7Iterator + helper unit tests — coverage 36% → 47%
Verification
- PHPUnit: 82 tests / 148 assertions / 0 failures
- PHPCS (Drupal + DrupalPractice): clean on
src/andtests/ - PHPStan level 8: clean
- Live end-to-end on a real key (DDEV): cache write/hit, 1h TTL beta header, PDF round-trip on Sonnet 4.5 / Opus 4.7 / Haiku 4.5 — all pass. Details in the issue comments.
Not in scope
- PDF upload UI — Phase 2 ships provider plumbing; an end-user upload
path is an upstream
ai_api_explorer/ai_chatbotchange. - Per-block cache breakpoints — needs an upstream
ChatMessagemarking mechanism. - Compaction, token counting, citations — a later phase.
Closes #3590963