Skip to content

OpenAI backend silently returns empty string when model produces no text content (content=None) #1060

Closed

Description

@planetf1

Observed behaviour

When using OpenAIBackend with a thinking model that returns content=null (i.e. the model emits reasoning tokens only, no text output), result.value is silently "". The sampling loop reports SUCCESS, finish_reason is stop, and token usage is non-zero — there is no signal that anything went wrong.

Reproducer

from mellea import start_session

# Qwen3 models default to thinking mode; without disable, content=None
session = start_session(
    "openai",
    model_id="Qwen/Qwen3-Coder-Next-FP8",
    base_url="http://localhost:59691/v1",
    api_key="unused",
)
result = session.instruct("What is 2 + 2?")
print(repr(result.value))        # ''  ← silent empty string
print(result.generation.usage)   # {'completion_tokens': 9, ...}  ← tokens were generated

Confirmed with a raw openai SDK call:

resp = client.chat.completions.create(model="Qwen/Qwen3-Coder-Next-FP8", ...)
print(resp.choices[0].message.content)   # None
print(resp.choices[0].finish_reason)     # 'stop'

Root cause

In mellea/backends/openai.py, processing() does:

content_chunk = message.content
if content_chunk is not None:
    mot._underlying_value += content_chunk

When content is None, accumulation is silently skipped, leaving _underlying_value = "". The ComputedModelOutputThunk constructor checks for None but not for empty string, so the empty result propagates up unchecked.

Expected behaviour

When content=None and finish_reason=stop, mellea should raise a MelleaError (or at minimum emit a warning) indicating the model returned no text content — likely because the model is operating in thinking-only mode. The error message should suggest passing enable_thinking: False via model_options for OpenAI-compatible thinking models:

session = start_session(
    "openai",
    model_id="Qwen/Qwen3-Coder-Next-FP8",
    base_url="http://localhost:59691/v1",
    api_key="unused",
    model_options={"extra_body": {"chat_template_kwargs": {"enable_thinking": False}}},
)

Environment

  • Backend: OpenAIBackend (OpenAI-compatible)
  • Model: Qwen/Qwen3-Coder-Next-FP8
  • Inference server: vLLM 0.20.2, flags: --reasoning-parser qwen3 --enable-auto-tool-choice --tool-call-parser hermes --tensor-parallel-size 2 --quantization fp8 --max-model-len 262144

Activity

  1. self-assigned this
    on May 12, 2026
  2. added 3 commits that reference this issue on May 12, 2026
    601a224
    7f3aeea
    ae70f9a
  3. added a commit that references this issue on May 20, 2026
    801bbfd
  4. added a commit that references this issue on May 27, 2026
    658159a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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