Skip to content

content: null trips up local AI servers in message history and tool calls for OpenAI compatible endpoints #736

Closed

Description

@philippeback

Issue

having content: null is trigger 500 Server Error on e.g. Lemonade Server.

Version and model info

No response

Activity

  1. philippeback commented on Nov 11, 2026

    @philippeback
    Author

    The investigation into cecli revealed exactly why and where "content": null is produced, serialized, and sent
    over the wire:
    ──────

    1. Root Cause Analysis

    1. Where "content": null is minted:
      When the model returns tool calls without text content, Message.content is None. In
      cecli/helpers/llms/litellm_compat.py:227-235:
      def _message_to_dict(message: Message) -> Dict[str, Any]:
      res = {
      "role": message.role,
      "content": message.content, # <--- None
      "tool_calls": [_tool_call_to_dict(tc) for tc in message.tool_calls] or None,
      ...
      }
      This is dumped via response.model_dump() in cecli/coders/base_coder.py:3815-3827 and committed to conversation
      history.
    2. Why it stays null in history:
      In cecli/helpers/conversation/base_message.py:118-135, BaseMessage.to_dict() retains "content": None.
    3. Where messages are formatted before dispatch:
      In cecli/models.py:1327:
      messages = model_request_parser(self, messages, tools)
      Inside cecli/helpers/requests.py:219-229, model_request_parser runs stages like thought_signature,
      ensure_alternating_roles, and add_reasoning_content.
      In cecli/sendchat.py:163-170:
      if (
      role == "assistant"
      and not msg.get("content", None)
      and not msg.get("tool_calls", None) # <-- skips if tool_calls present!
      and not msg.get("function_call", None)
      ):
      msg["content"] = "(empty response)"
      Because tool_calls is present, msg["content"] remains None.
    4. Where the HTTP call is made:
      cecli replaced raw litellm with its own lightweight dispatcher in cecli.helpers.llms.
      • In cecli/helpers/llms/domains/chat.py:42-58, chat_payload(...) builds payload = {"model": ...,
      "messages": messages, ...}.
      • It makes the HTTP request via make_client(...) in cecli/helpers/llms/runtime.py:42-64 (httpx.
      AsyncClient).
      • Because msg["content"] is None, httpx serializes it as "content": null, which strict endpoints (Lemonade,
      vLLM, Aphrodite, LM Studio) reject.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions