Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions tests/entrypoints/openai/test_render_no_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ...utils import RemoteOpenAIServer

MODEL_NAME = "hmellor/tiny-random-LlamaForCausalLM"
MODEL_NAME = "openai/gpt-oss-20b"


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -60,9 +60,25 @@ async def test_chat_completion_render_works_without_inference(client):

conversation, engine_prompts = data

# Verify conversation is preserved
assert conversation[0]["role"] == "user"
assert "Hello" in conversation[0]["content"]
# Verify conversation contains messages
assert len(conversation) > 0

# Find the user message (Harmony models use 'author' dict instead of 'role')
user_msg = None
for msg in conversation:
# Check for direct 'role' key (standard format)
if msg.get("role") == "user":
user_msg = msg
break
# Check for nested 'author' dict (Harmony format)
author = msg.get("author")
if isinstance(author, dict) and author.get("role") == "user":
user_msg = msg
break

assert user_msg is not None, (
f"User message not found in conversation: {conversation}"
)

# Verify tokenization occurred
assert len(engine_prompts) > 0
Expand Down
7 changes: 6 additions & 1 deletion vllm/entrypoints/openai/chat_completion/api_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ async def render_chat_completion(request: ChatCompletionRequest, raw_request: Re
if isinstance(result, ErrorResponse):
return JSONResponse(content=result.model_dump(), status_code=result.error.code)

return JSONResponse(content=result)
conversation, engine_prompts = result
# Serialize Pydantic models (Harmony) or pass through TypedDicts as-is
serialized_conversation = [
getattr(msg, "model_dump", lambda m=msg: m)() for msg in conversation
]
return JSONResponse(content=[serialized_conversation, engine_prompts])


def attach_router(app: FastAPI):
Expand Down