Skip to content

fix(Anthropic Chat Model Node): Fix LmChatAnthropic node to work when both thinking is enabled and tools used #16010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ggozad
Copy link
Contributor

@ggozad ggozad commented Jun 4, 2025

Summary

This PR fixes a problem that occurs when Anthropic models are used with thinking enabled and tools.
The issues is fixed by updating @langchain/antropic to 0.3.21, @langchain/core to 0.3.48

As part of the upgrade, the following changes have been made to adapt to the new versions:

  • Updated formatToOpenAIAssistantTool, mcpToolToDynamicTool, ToolExecutor.node.ts to accept Tool
  • Made sure we have an object schemas for MCP tools to maintain type safety

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/AI-988/community-issue-anthropic-models-with-enable-thinking-fail-in-ai-agent
Closes #15715

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)

@ggozad ggozad changed the title fix(Anthropic Chat Model): fix LmChatAnthropic node to work when both thinking is enabled and tools used fix(Anthropic Chat Model Node): fix LmChatAnthropic node to work when both thinking is enabled and tools used Jun 4, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic reviewed 1 file and found no issues. Review PR in cubic.dev.

@ggozad ggozad changed the title fix(Anthropic Chat Model Node): fix LmChatAnthropic node to work when both thinking is enabled and tools used fix(Anthropic Chat Model Node): Fix LmChatAnthropic node to work when both thinking is enabled and tools used Jun 4, 2025
@ggozad ggozad marked this pull request as draft June 4, 2025 09:37
@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Jun 4, 2025
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...es-langchain/nodes/agents/OpenAiAssistant/utils.ts 0.00% 2 Missing ⚠️
...-langchain/nodes/ToolExecutor/ToolExecutor.node.ts 50.00% 0 Missing and 1 partial ⚠️
...n/nodes-langchain/nodes/mcp/McpClientTool/utils.ts 80.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@ggozad ggozad force-pushed the ai-988-community-issue-anthropic-models-with-enable-thinking-fail branch from 6b9a1b3 to 1ac30db Compare June 4, 2025 12:11
@ggozad ggozad marked this pull request as ready for review June 4, 2025 12:21
@ggozad ggozad requested review from a team and burivuhster and removed request for a team June 4, 2025 12:22
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 3 issues across 6 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

burivuhster
burivuhster previously approved these changes Jun 5, 2025
Copy link
Contributor

@burivuhster burivuhster left a comment

Choose a reason for hiding this comment

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

Looks good to me! 🚀

@shortstacked
Copy link
Contributor

Workflow Test Results 📊 🔴 2 Failed, ⚠️ 4 Warnings, 👍 77 Successful out of 83 total workflows.

Detail: Workflows failing: 237: Workflow contains 1 deleted data. View full workflow run

Tested Ref: 1ea19d58f32595393ec8cf4c26bce98a2b8f2772 by @burivuhster

❌ Failed Tests (2)

Workflow ID Workflow Name Reason
237 BasicLLMChain:AzureChat Workflow contains 1 deleted data.
84 Matrix:Room:create invite kick leave:RoomMember:ge... Too Many Requests on node Matrix1

⚠️ Warnings (4)

Workflow ID Workflow Name Reason
35 Slack:User:getPresence info:UserProfile:get update... Workflow contains new data that previously did not exist.
257 Agent:auto-fix:anthropic Workflow contains new data that previously did not exist.
48 Asana:Project:getAll get:Task:create update move g... Workflow contains new data that previously did not exist.
53 ConvertKit:CustomField:create getAll update delete... Workflow contains new data that previously did not exist.

Copy link
Contributor

github-actions bot commented Jun 5, 2025

✅ All Cypress E2E specs passed

@ggozad ggozad force-pushed the ai-988-community-issue-anthropic-models-with-enable-thinking-fail branch from 1ea19d5 to c1d02c4 Compare June 5, 2025 10:59
@shortstacked
Copy link
Contributor

Workflow Test Results 📊 🔴 2 Failed, ⚠️ 3 Warnings, 👍 78 Successful out of 83 total workflows.

Detail: Workflows failing: 237: Workflow contains 1 deleted data. View full workflow run

Tested Ref: c1d02c42d6686fc401017a07d94467568f62b7c3 by @burivuhster

❌ Failed Tests (2)

Workflow ID Workflow Name Reason
237 BasicLLMChain:AzureChat Workflow contains 1 deleted data.
84 Matrix:Room:create invite kick leave:RoomMember:ge... Too Many Requests on node Matrix1

⚠️ Warnings (3)

Workflow ID Workflow Name Reason
257 Agent:auto-fix:anthropic Workflow contains new data that previously did not exist.
48 Asana:Project:getAll get:Task:create update move g... Workflow contains new data that previously did not exist.
53 ConvertKit:CustomField:create getAll update delete... Workflow contains new data that previously did not exist.

Copy link
Contributor

github-actions bot commented Jun 5, 2025

✅ All Cypress E2E specs passed

@ggozad ggozad merged commit e662998 into master Jun 5, 2025
36 checks passed
@ggozad ggozad deleted the ai-988-community-issue-anthropic-models-with-enable-thinking-fail branch June 5, 2025 11:33
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.

Anthropic Models with "Enable Thinking" Fail in AI Agent When Using Tools Due to Message Formatting
3 participants