Skip to content

fix#9

Draft
hyeongyun0916 wants to merge 1 commit intodisable-inferencefrom
fix-harmony-render
Draft

fix#9
hyeongyun0916 wants to merge 1 commit intodisable-inferencefrom
fix-harmony-render

Conversation

@hyeongyun0916
Copy link

@hyeongyun0916 hyeongyun0916 commented Jan 30, 2026

Purpose

Fix /v1/chat/completions/render endpoint to properly serialize Harmony model messages.

The render endpoint was failing with TypeError: Object of type Message is not JSON serializable when used with Harmony models (e.g., openai/gpt-oss-20b). This is because Harmony models return OpenAIMessage Pydantic objects in the conversation, which cannot be directly serialized to JSON.

This PR:

Adds proper serialization logic in api_router.py to handle both Pydantic models (via model_dump()) and TypedDict objects
Updates test assertions to handle both standard message format (role key) and Harmony format (nested author dict)

Test Plan

pytest tests/entrypoints/openai/test_render_no_inference.py -v
pytest tests/entrypoints/openai/test_render.py -v

Test Result

tests/entrypoints/openai/test_render_no_inference.py::test_health_check PASSED
tests/entrypoints/openai/test_render_no_inference.py::test_chat_completion_render_works_without_inference PASSED
tests/entrypoints/openai/test_render_no_inference.py::test_completion_render_works_without_inference PASSED
tests/entrypoints/openai/test_render_no_inference.py::test_inference_disabled PASSED
tests/entrypoints/openai/test_render.py::test_completion_render_basic PASSED
tests/entrypoints/openai/test_render.py::test_chat_completion_render_basic PASSED
tests/entrypoints/openai/test_render.py::test_completion_render_multiple_prompts PASSED
tests/entrypoints/openai/test_render.py::test_chat_completion_render_multi_turn PASSED
tests/entrypoints/openai/test_render.py::test_completion_render_error_invalid_model PASSED
tests/entrypoints/openai/test_render.py::test_chat_completion_render_error_invalid_model PASSED
tests/entrypoints/openai/test_render.py::test_completion_render_no_generation PASSED

================== 11 passed ==================

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: HyunKyun Moon <mhg5303@gmail.com>
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