Skip to content

fix(openai): ensure assistant messages always have a content field to prevent 400 errors#1273

Open
jujn wants to merge 4 commits intoagentscope-ai:mainfrom
jujn:fix_1270
Open

fix(openai): ensure assistant messages always have a content field to prevent 400 errors#1273
jujn wants to merge 4 commits intoagentscope-ai:mainfrom
jujn:fix_1270

Conversation

@jujn
Copy link
Copy Markdown
Contributor

@jujn jujn commented Apr 23, 2026

Description

Close #1268 #1270

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@jujn jujn requested review from a team and Copilot April 23, 2026 15:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes OpenAI-compatible API request failures (e.g., vLLM Qwen3 reasoning mode and DashScope compatible-mode) by ensuring assistant messages always include a content field, preventing 400 Bad Request errors when an assistant message contains only tool calls / reasoning blocks.

Changes:

  • Ensure OpenAIMessageConverter.convertAssistantMessage() sets content to "" when extracted text content is null/empty.
  • Add a regression test to validate assistant messages with tool-only content serialize with non-null content.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
agentscope-core/src/main/java/io/agentscope/core/formatter/openai/OpenAIMessageConverter.java Always sets assistant content (falls back to empty string) to satisfy strict OpenAI-compatible endpoints.
agentscope-core/src/test/java/io/agentscope/core/formatter/openai/OpenAIMessageConverterTest.java Adds a regression test covering tool-only assistant messages to prevent content-missing requests.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:OpenAIMessageConverter produces assistant messages with null content when using vLLM + Qwen3 thinking mode

2 participants