You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
content: null trips up local AI servers in message history and tool calls for OpenAI compatible endpoints #736
The investigation into cecli revealed exactly why and where "content": null is produced, serialized, and sent
over the wire:
──────
1. Root Cause Analysis
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.
Why it stays null in history:
In cecli/helpers/conversation/base_message.py:118-135, BaseMessage.to_dict() retains "content": None.
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.
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.
Activity
philippeback commentedon Nov 11, 2026
The investigation into cecli revealed exactly why and where "content": null is produced, serialized, and sent
over the wire:
──────
1. Root Cause Analysis
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.
In cecli/helpers/conversation/base_message.py:118-135, BaseMessage.to_dict() retains "content": None.
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.
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.