Skip to content

Backport: fix(openai, openai-compatible): send null content for tool-only assistant messages#14613

Merged
3 commits merged into
release-v6.0from
backport-pr-13744-to-release-v6.0
Apr 20, 2026
Merged

Backport: fix(openai, openai-compatible): send null content for tool-only assistant messages#14613
3 commits merged into
release-v6.0from
backport-pr-13744-to-release-v6.0

Conversation

@ghost

@ghost ghost commented Apr 17, 2026

Copy link
Copy Markdown

This is an automated backport of #13744 to the release-v6.0 branch. FYI @dancer

…tant messages (#13744)

## background

when an assistant message contains only tool-call parts (no text),
`convertToOpenAICompatibleChatMessages` and
`convertToOpenAIChatMessages` send `content: ""`. providers backed by
AWS Bedrock reject this with `ValidationException: messages: text
content blocks must be non-empty`

## summary

- change `content: text` to `content: text || null` for assistant
messages in both `@ai-sdk/openai-compatible` and `@ai-sdk/openai`
- update tests to expect `null` instead of `""` for tool-only assistant
messages

## checklist

- [x] tests have been added / updated (for bug fixes / features)
- [ ] documentation has been added / updated (for bug fixes / features)
- [x] a _patch_ changeset for relevant packages has been added (run
`pnpm changeset` in root)
- [x] i have reviewed this pull request (self-review)

## Future work

The same `content: text` pattern exists in `@ai-sdk/xai`,
`@ai-sdk/deepseek`, `@ai-sdk/groq`, and `@ai-sdk/mistral` and will hit
the same Bedrock error under equivalent routing. Tracked separately in
#14612.

## related issues

fixes #13466
@ghost ghost assigned gr2m Apr 17, 2026
@ghost ghost enabled auto-merge (squash) April 17, 2026 19:25
@tigent tigent Bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/openai Issues related to the @ai-sdk/openai provider provider/openai-compatible Issues related to the @ai-sdk/openai-compatible provider labels Apr 17, 2026
@ghost ghost merged commit 408a2ad into release-v6.0 Apr 20, 2026
16 checks passed
@ghost ghost deleted the backport-pr-13744-to-release-v6.0 branch April 20, 2026 13:33
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 6.0.169
@ai-sdk/alibaba 1.0.18
@ai-sdk/amazon-bedrock 4.0.97
@ai-sdk/angular 2.0.170
@ai-sdk/anthropic 3.0.72
@ai-sdk/assemblyai 2.0.30
@ai-sdk/azure 3.0.55
@ai-sdk/baseten 1.0.45
@ai-sdk/black-forest-labs 1.0.30
@ai-sdk/bytedance 1.0.11
@ai-sdk/cerebras 2.0.46
@ai-sdk/codemod 3.0.5
@ai-sdk/cohere 3.0.31
@ai-sdk/deepgram 2.0.30
@ai-sdk/deepinfra 2.0.46
@ai-sdk/deepseek 2.0.30
@ai-sdk/devtools 0.0.16
@ai-sdk/elevenlabs 2.0.30
@ai-sdk/fal 2.0.31
@ai-sdk/fireworks 2.0.47
@ai-sdk/gateway 3.0.105
@ai-sdk/gladia 2.0.30
@ai-sdk/google 3.0.65
@ai-sdk/google-vertex 4.0.113
@ai-sdk/groq 3.0.36
@ai-sdk/huggingface 1.0.44
@ai-sdk/hume 2.0.30
@ai-sdk/klingai 3.0.15
@ai-sdk/langchain 2.0.175
@ai-sdk/llamaindex 2.0.169
@ai-sdk/lmnt 2.0.30
@ai-sdk/luma 2.0.30
@ai-sdk/mcp 1.0.37
@ai-sdk/mistral 3.0.31
@ai-sdk/moonshotai 2.0.17
@ai-sdk/open-responses 1.0.12
@ai-sdk/openai 3.0.54
@ai-sdk/openai-compatible 2.0.42
@ai-sdk/perplexity 3.0.30
@ai-sdk/prodia 1.0.28
@ai-sdk/provider 3.0.9
@ai-sdk/provider-utils 4.0.24
@ai-sdk/react 3.0.171
@ai-sdk/replicate 2.0.30
@ai-sdk/revai 2.0.30
@ai-sdk/rsc 2.0.169
@ai-sdk/svelte 4.0.169
@ai-sdk/test-server 1.0.4
@ai-sdk/togetherai 2.0.46
@ai-sdk/valibot 2.0.25
@ai-sdk/vercel 2.0.44
@ai-sdk/voyage 1.0.1
@ai-sdk/vue 3.0.169
@ai-sdk/xai 3.0.84

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/openai Issues related to the @ai-sdk/openai provider provider/openai-compatible Issues related to the @ai-sdk/openai-compatible provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants