Skip to content

fix(openai): fix content in AIMessage for tool and function calls#9636

Merged
Christian Bromann (christian-bromann) merged 2 commits into
mainfrom
cb/convertMessagesToCompletionsMessageParams-fix
Dec 12, 2025
Merged

fix(openai): fix content in AIMessage for tool and function calls#9636
Christian Bromann (christian-bromann) merged 2 commits into
mainfrom
cb/convertMessagesToCompletionsMessageParams-fix

Conversation

@christian-bromann

@christian-bromann Christian Bromann (christian-bromann) commented Dec 12, 2025

Copy link
Copy Markdown
Member

Removed the lines that set completionParam.content = "". The content is already correctly set earlier in the function from message.content, and the OpenAI API allows content to be present alongside tool calls. In fact, preserving the content helps the model maintain context about why it made the tool call, leading to better responses in multi-turn conversations.

fixes #9612

@changeset-bot

changeset-bot Bot commented Dec 12, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0c0a9a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@langchain/openai Patch
@langchain/classic Patch
@langchain/community Patch
@langchain/deepseek Patch
@langchain/xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hntrl Hunter Lovell (hntrl) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

glad they finally support this in completions 🙏

@github-actions github-actions Bot added the ready label Dec 12, 2025
@christian-bromann Christian Bromann (christian-bromann) merged commit 5a01b5b into main Dec 12, 2025
34 checks passed
@christian-bromann Christian Bromann (christian-bromann) deleted the cb/convertMessagesToCompletionsMessageParams-fix branch December 12, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AzureChatOpenAI sets content to "" for AI Messages with tool_calls leading to poorer agent performance

2 participants