Conversation
schrothbn
force-pushed
the
ai-2182-strip-empty-text-content-blocks-when-using-openai-node-with
branch
from
March 11, 2026 11:56
14aecda to
498bc9b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This comment has been minimized.
This comment has been minimized.
schrothbn
force-pushed
the
ai-2182-strip-empty-text-content-blocks-when-using-openai-node-with
branch
from
March 12, 2026 07:46
4d1bb0e to
32b9783
Compare
Bundle ReportBundle size has no change ✅ Affected Assets, Files, and Routes:view changes for bundle: editor-ui-esmAssets Changed:
|
schrothbn
marked this pull request as ready for review
March 12, 2026 08:24
schrothbn
requested review from
a team and
mutdmour
and removed request for
a team
March 12, 2026 08:24
Contributor
There was a problem hiding this comment.
No issues found across 3 files
Architecture diagram
sequenceDiagram
participant User as "User / Workflow"
participant Node as "n8n AI Node (OpenAI Model)"
participant Core as "@langchain/core (v1.1.31)"
participant API as "LLM Endpoint (Anthropic/OpenAI)"
Note over User,API: Message Flow with Tool Calling
User->>Node: Execute Agent with Tool
Node->>Core: formatMessages(history)
Note over Core: CHANGED: convertToV1FromChatCompletions()
Core->>Core: Inspect message blocks
alt Content is empty ('') AND Tool Calls present
Core->>Core: NEW: Strip empty text block
else Content is non-empty
Core->>Core: Preserve text block
end
Core-->>Node: Sanitized Message Object
Node->>API: POST /chat/completions
Note right of API: Payload now lacks empty 'content' strings
alt Anthropic-compatible Backend
API-->>Node: 200 OK (Success)
else Legacy Behavior (pre-fix)
Note right of API: Would return 400 Bad Request if content: ''
API-->>Node: 400 Error
end
Node-->>User: Tool Output / Agent Response
DeveloperTheExplorer
approved these changes
Mar 12, 2026
schrothbn
deleted the
ai-2182-strip-empty-text-content-blocks-when-using-openai-node-with
branch
March 12, 2026 10:42
cstuncsik
pushed a commit
that referenced
this pull request
Mar 16, 2026
Contributor
|
Got released with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bumps @langchain/core from 1.1.8 to 1.1.31 to pick up the fix for langchain-ai/langchainjs#9995, which strips empty text content blocks before sending
messages to the API.
Root cause: When an AI Agent uses tool-calling with an Anthropic model via the OpenAI Chat Model node, the assistant message was constructed with "content": "" alongside the tool_calls block. Anthropic (and Anthropic-compatible) endpoints reject this with 400. OpenAI ignores empty content silently, so only Anthropic-compatible backends were affected.
The fix in @langchain/core@1.1.22+ adds a content.length > 0 guard in convertToV1FromChatCompletions before pushing a text block, so empty strings are never sent.
Additional package bumps pulled in alongside the core upgrade:
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/AI-2182
Review / Merge checklist
release/backport(if the PR is an urgent fix that needs to be backported)