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 TextBlockParam with cache_control when 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-11 beta header via per-request RequestOptions::extraHeaders.
  • cache_creation_input_tokens surfaced through ChatOutput::getMetadata()['cache_creation_tokens'].

PDF input

  • buildMessageContent() detects application/pdf files on a ChatMessage and emits a typed DocumentBlockParam + Base64PDFSource.
  • getConfiguredModels() gains an anthropic:pdf_input capability filter.

SDK + infrastructure

  • Composer constraint ^0.16>=0.16,<1.0 (tested on v0.23.0).
  • Module-local phpunit.xml.dist with scoped <source> coverage.

Commits

  1. faebdcc SDK constraint bump + drop redundant method_exists guard
  2. 7c3de9c PDF input — capability filter + document blocks
  3. 87b662c Caching UI + TTL + beta opt-in + cache_creation reporting
  4. dfd9fbf Cache the system prompt as a typed block (live-test fix)
  5. 8548859 Review fixes — buildCacheControl helper + PDF caution doc
  6. 28b2479 Module-local phpunit.xml.dist with scoped coverage
  7. 8f84ed7 Iterator + helper unit tests — coverage 36% → 47%

Verification

  • PHPUnit: 82 tests / 148 assertions / 0 failures
  • PHPCS (Drupal + DrupalPractice): clean on src/ and tests/
  • 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_chatbot change.
  • Per-block cache breakpoints — needs an upstream ChatMessage marking mechanism.
  • Compaction, token counting, citations — a later phase.

Closes #3590963

Merge request reports

Loading