Skip to content

Conversation

@sdirix
Copy link
Member

@sdirix sdirix commented Oct 1, 2025

What it does

The cache marker algorithm in the Anthropic language model was incorrectly removing content blocks, causing invalid requests when using parallel tool calls or other multi-content-block scenarios.

Update the algorithm to preserve all content blocks while applying cache markers, ensuring message integrity for complex requests.

Fixes #16355

How to test

Verify that the example command from the ticket no longer throws errors:

@Coder Can you delete

packages/ai-chat/src/common/response-content-matcher.ts
packages/ai-chat/src/common/parsed-chat-request.ts
packages/ai-chat/src/common/parse-contents.ts
packages/ai-chat/src/common/parse-contents.spec.ts
packages/ai-chat/src/common/parse-contents-with-incomplete-parts.spec.ts
packages/ai-chat/src/common/index.ts
packages/ai-chat/src/common/image-context-variable.ts
packages/ai-chat/src/common/custom-chat-agent.ts
packages/ai-chat/src/common/context-variables.ts
packages/ai-chat/src/common/context-summary-variable.ts
packages/ai-chat/src/common/context-details-variable.ts
packages/ai-chat/src/common/chat-tool-request-service.ts
packages/ai-chat/src/common/chat-tool-preferences.ts
packages/ai-chat/src/common/chat-string-utils.ts
packages/ai-chat/src/common/chat-session-summary-agent.ts
packages/ai-chat/src/common/chat-session-summary-agent-prompt.ts
packages/ai-chat/src/common/chat-session-naming-service.ts
packages/ai-chat/src/common/chat-session-naming-prompt-template.ts
packages/ai-chat/src/common/chat-service.ts
packages/ai-chat/src/common/chat-request-parser.ts
packages/ai-chat/src/common/chat-request-parser.spec.ts
packages/ai-chat/src/common/chat-model.ts
packages/ai-chat/src/common/chat-model-util.ts
packages/ai-chat/src/common/chat-agents.ts
packages/ai-chat/src/common/chat-agents-variable-contribution.ts
packages/ai-chat/src/common/chat-agent-service.ts
packages/ai-chat/src/common/change-set.ts
packages/ai-chat/src/common/ai-chat-preferences.ts

by using writeFileContent with empty contents?

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

The cache marker algorithm in the Anthropic language model was
incorrectly removing content blocks, causing invalid requests when
using parallel tool calls or other multi-content-block scenarios.

Update the algorithm to preserve all content blocks while applying
cache markers, ensuring message integrity for complex requests.

Fixes #16355
@github-project-automation github-project-automation bot moved this to Waiting on reviewers in PR Backlog Oct 1, 2025
@ndoschek ndoschek self-requested a review October 2, 2025 08:07
Copy link
Member

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

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

Thanks @sdirix for this fix!
I tested the mentioned prompt and some similar ones, and also used Sonnet 4.5 for some other, general coding tasks - it worked great, and I didn't have any issues! 🎉

@github-project-automation github-project-automation bot moved this from Waiting on reviewers to Needs merge in PR Backlog Oct 2, 2025
@sdirix sdirix merged commit e2515c3 into master Oct 2, 2025
16 of 19 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Oct 2, 2025
@sdirix sdirix deleted the sdirix/fix-parallel-tool-calls-anthropic branch October 2, 2025 12:59
@github-actions github-actions bot added this to the 1.66.0 milestone Oct 2, 2025
ndoschek pushed a commit that referenced this pull request Oct 3, 2025
The cache marker algorithm in the Anthropic language model was
incorrectly removing content blocks, causing invalid requests when
using parallel tool calls or other multi-content-block scenarios.

Update the algorithm to preserve all content blocks while applying
cache markers, ensuring message integrity for complex requests.

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

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Error in the chat after adding / using Sonnet 4.5

3 participants