Skip to content

fix(ai-builder): Strip cache_control markers from persisted tool messages and responder input#2081

Closed
everettbu wants to merge 3 commits into
masterfrom
ai-2087-cache-control-issue
Closed

fix(ai-builder): Strip cache_control markers from persisted tool messages and responder input#2081
everettbu wants to merge 3 commits into
masterfrom
ai-2087-cache-control-issue

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of n8n-io/n8n#26132
Original author: mike12345567


Summary

Fixes an issue where the workflow builder would error with "A maximum of 4 blocks with cache_control may be provided" during multi-step conversations (e.g. building a workflow then following up with "Also send to Slack").

applySubgraphCacheMarkers() mutates subgraph messages in-place, adding cache_control markers to ToolMessages. When these messages were persisted to parent state via extractToolMessagesForPersistence(), the markers came along. The responder then received these stale markers in state.messages alongside its own system prompt marker, exceeding Anthropic's 4-marker limit.

Strip cache markers in extractToolMessagesForPersistence() before returning to parent state.

Strip cache markers in invokeResponderAgent() before passing messages to the LLM.

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@everettbu everettbu added n8n team Authored by the n8n team release/backport Changes that need to be backported to older releases. release/backport-to-beta and removed release/backport Changes that need to be backported to older releases. release/backport-to-beta labels Feb 23, 2026
@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Feb 23, 2026
@everettbu
everettbu deleted the ai-2087-cache-control-issue branch February 23, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants