Skip to content

fix(openai): allow null message content for tool_calls#41

Open
Fan-sx wants to merge 1 commit intoTQZHR:mainfrom
Fan-sx:fix-openai-null-content-tool-calls
Open

fix(openai): allow null message content for tool_calls#41
Fan-sx wants to merge 1 commit intoTQZHR:mainfrom
Fan-sx:fix-openai-null-content-tool-calls

Conversation

@Fan-sx
Copy link

@Fan-sx Fan-sx commented Mar 1, 2026

What

Allow messages[].content to be null for assistant/tool roles to match OpenAI Chat Completions behavior when tool_calls are present.

Why

OpenAI-compatible clients may send an assistant message with tool_calls and content: null. Current Pydantic validation rejects it with:
ValidationError: body.messages.content.str - Input should be a valid string.

This breaks tool-call flows.

Changes

  • MessageItem.content: Union[str, list, None] (default None)
  • validate_request: accept content is None for assistant and tool roles; keep rejecting empty content for user/system/developer.

Notes

Minimal change; no behavior change for normal string/list content.

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.

1 participant