Skip to content

[Platform][Anthropic] Support cache_control on system prompt block#2117

Open
4lxndr wants to merge 1 commit into
symfony:mainfrom
4lxndr:feature/anthropic-system-prompt-cache-control
Open

[Platform][Anthropic] Support cache_control on system prompt block#2117
4lxndr wants to merge 1 commit into
symfony:mainfrom
4lxndr:feature/anthropic-system-prompt-cache-control

Conversation

@4lxndr

@4lxndr 4lxndr commented May 26, 2026

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
Docs? yes
Issues Fix #2111
License MIT
  • MessageBagNormalizer now emits the system prompt as a typed content-block array ([{type: text, text: ...}]) instead of a bare string, so a cache marker can be attached. Anthropic accepts both shapes, so callers see no difference.
  • ModelClient attaches a cache_control marker to the system block when cacheRetention is short/long (skipped for none), mirroring the existing tool-definition caching.

@4lxndr 4lxndr marked this pull request as ready for review May 26, 2026 07:29
@carsonbot carsonbot added Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review labels May 26, 2026
Comment on lines +140 to +142
$cacheControl = 'long' === $this->cacheRetention
? ['type' => 'ephemeral', 'ttl' => '1h']
: ['type' => 'ephemeral'];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about extracting this into getCacheControl(): array for synergy with injectCacheControl usage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Platform][Anthropic] Add cache_control on system prompt to enable caching when no tools are used

3 participants