Skip to content

fix: strip CacheControl from messages during compaction#2236

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/cache-control-blocks-limit-in-anthropic-a48b23eb
Mar 25, 2026
Merged

fix: strip CacheControl from messages during compaction#2236
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/cache-control-blocks-limit-in-anthropic-a48b23eb

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 25, 2026

When compaction runs, doCompact calls sess.GetMessages(a) which returns messages with CacheControl=true on the last invariant and last context system messages. These markers were preserved through compaction.BuildPrompt into the summarization session, which then added its own system message marker plus 2 more from applyMessageCacheControl, totaling 5 cache control breakpoints — exceeding Anthropic's limit of 4.

Fix: Strip CacheControl from cloned messages in BuildPrompt, just like Cost is already zeroed.

When compaction runs, the original session's system messages carry
CacheControl=true markers. These were preserved through BuildPrompt
into the summarization session, which then added its own markers plus
applyMessageCacheControl's 2 markers, exceeding Anthropic's limit of 4
cache control breakpoints.

Assisted-By: docker-agent
@dgageot dgageot requested a review from a team as a code owner March 25, 2026 07:02
@dgageot dgageot merged commit 513e243 into docker:main Mar 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants