[Bugfix] Fix Responses API crash when ResponseReasoningItem has content=None#36839
[Bugfix] Fix Responses API crash when ResponseReasoningItem has content=None#36839rranabha wants to merge 1 commit intovllm-project:mainfrom
Conversation
…nt=None Handle the case where ResponseReasoningItem.content is None by falling back to the summary field. This occurs in multi-turn requests when previous response reasoning items are passed back as input.
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run You ask your reviewers to trigger select CI tests on top of Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. 🚀 |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
Hi @rranabha, the pre-commit checks have failed. Please run: uv pip install pre-commit
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, Tip Is
|
alvinttang
left a comment
There was a problem hiding this comment.
The root cause is correctly identified — content=None is a valid API state when encrypted_content is used, so the hard assert was wrong. The fallback to summary is a reasonable recovery strategy, but joining multiple summary items with a single space (e.g., "First thought. Second thought.") could produce grammatically awkward output depending on punctuation; a newline separator might be more faithful to the original reasoning structure. The remaining assert len(content) == 1 in the non-None branch is still a potential crash if the API ever returns multi-entry content arrays — worth converting to a more defensive approach (e.g., joining or taking the first item). Test coverage is thorough and the edge cases are well exercised.
|
/cc @qandrew PTAL. |
|
I believe this attempts to fix the same issues as #34499, but 34499 properly handles the summary field which is only meant to be user-visible summaries but not supposed to make its way back into the model's prompt. |
|
This pull request has merge conflicts that must be resolved before it can be |
|
@rranabha 34499 just merged. If you're willing, please take a look at the changes merged there to ensure they fix your issue and if so we can close this PR. If you're not sure or want to chat about that, I'm happy to do that as well. |
Summary
TypeError: object of type 'NoneType' has no len()crash inresponse_input_to_harmony()when aResponseReasoningItemhascontent=Nonesummaryfield (joining all summary texts) whencontentisNone, which occurs in multi-turn Responses API requests where previous reasoning output is passed back as inputTest plan
tests/entrypoints/openai/responses/test_harmony_utils.pypassTestResponseInputToHarmonyReasoningtest class covers all content/summary combinationsResponseReasoningItem(content=None)in input no longer crash